Skip to content

Commit

Permalink
Develop (#22)
Browse files Browse the repository at this point in the history
* rev 70
* Preserve on load popup menu
* Small bug fix, 2 extra decades of simulation values
  • Loading branch information
HendriXML authored Mar 30, 2022
1 parent 16cb2fe commit 1725494
Show file tree
Hide file tree
Showing 9 changed files with 202 additions and 137 deletions.
Binary file modified Interpreter/XMLScriptInterpreter.NLD
Binary file not shown.
Binary file modified Interpreter/XMLScriptInterpreter.exe
Binary file not shown.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ See [wiki](https://github.com/HendriXML/KiCad-BOM-reporter/wiki), [screenshots](
* Version 7.0 of the XML interpreter
* File restructuring, renaming and clean up
* Improved/changed config settings
* Configuration echo: shows which config values are actualy being used
* Improved capacitor technology items: aluminum electrolytic, tantalum electrolytic, niobium electrolytic
* Set matching, requested (schematic) components can specify multiple values on enumeration based fields like: "aluminum electrolytic, tantalum electrolytic"
* New tasks which determines the best combination of (available) components (resistors, capacitors of inductors) for a replacement value
Expand Down
218 changes: 123 additions & 95 deletions Script.Common.Electronics/Electronics enumerations.xml

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions Script.Common.Electronics/Electronics strings en-GB.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,13 @@
<Constant Identifier="cCombinationTargetTask" Type="string" Expression="'Combination target configuration'"/>
<Constant Identifier="cAvailableValuesInputTabTask" Type="string" Expression="'Available values provided by input tabsheet'"/>
<Constant Identifier="cAvailableValuesTextFileTask" Type="string" Expression="'Available values provided by a text file'"/>
<Constant Identifier="cAssertEitherEseriesOrAvailableValues" Type="string" Expression="'Available values should be provided or E-series should be used'"/>
<Constant Identifier="cValuesIncluded" Type="string" Expression="'Number of values included'"/>
<Constant Identifier="cValuesExcluded" Type="string" Expression="'Number of values excluded'"/>
<Constant Identifier="cMatchesSpecs" Type="string" Expression="'Matches specs'"/>
<Constant Identifier="cUsedESeries" Type="string" Expression="'Used E-series'"/>
<Constant Identifier="cRelativeDifference" Type="string" Expression="'Relative difference'"/>
<Constant Identifier="cRefined" Type="string" Expression="'Refined'"/>
<Constant Identifier="cResult" Type="string" Expression="'Result'"/>
</Constants>
</pkg:Library>
8 changes: 8 additions & 0 deletions Script.Common.Electronics/Electronics strings nl-NL.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,13 @@
<Constant Identifier="cCombinationTargetTask" Type="string" Expression="'Combinatie doel configuratie'"/>
<Constant Identifier="cAvailableValuesInputTabTask" Type="string" Expression="'Beschikbare waarden genomen van invoer tabblad'"/>
<Constant Identifier="cAvailableValuesTextFileTask" Type="string" Expression="'Beschikbare waarden genomen van een tekstbestand'"/>
<Constant Identifier="cAssertEitherEseriesOrAvailableValues" Type="string" Expression="'Beschikbare waarden dienen gelevert te worden of E-reeksen moeten gebruikt worden'"/>
<Constant Identifier="cValuesIncluded" Type="string" Expression="'Aantal geïncludeerde waarden'"/>
<Constant Identifier="cValuesExcluded" Type="string" Expression="'Aantal geëxcludeerde waarden'"/>
<Constant Identifier="cMatchesSpecs" Type="string" Expression="'Voldoet aan specs'"/>
<Constant Identifier="cUsedESeries" Type="string" Expression="'Gebruikte E-reeksen'"/>
<Constant Identifier="cRelativeDifference" Type="string" Expression="'Relatief verschil'"/>
<Constant Identifier="cRefined" Type="string" Expression="'Verfijnd'"/>
<Constant Identifier="cResult" Type="string" Expression="'Resultaat'"/>
</Constants>
</pkg:Library>
81 changes: 46 additions & 35 deletions Script.Common.Electronics/Electronics tasks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@
</DataClass>

<DataClass Identifier="TCombinationParameters">
<Field Identifier="MaxESerie" Type="TESerie"/>
<Field Identifier="UseESeries" Type="Boolean"/>
<Field Identifier="Granularity" Type="TValueGranularity"/>
<Field Identifier="MaxESerie" Type="TESerie"/>
<Field Identifier="Tolerance" Type="PercentageRatioDQ"/>
<Field Identifier="Refine" Type="Boolean"/>
<Field Identifier="RefineESerie" Type="TSerie"/>
Expand Down Expand Up @@ -92,6 +93,9 @@
<TryExcept>
<Try>
<Execute Statement="Ini.Section(Task.Name)"/>
<Execute Statement="UseESeries:= Ini.ReadBool('UseESeries', False)"/>
<Execute Statement="Granularity:= TValueGranularity.Fine"/>
<Execute Statement="Granularity:= Ini.ReadEnum('Granularity', Granularity, ValueGranularityEnumManager.NameRegister)"/>
<Execute Statement="MaxESerie:= TESerie.E24"/>
<Execute Statement="MaxESerie:= Ini.ReadEnum('MaxESerie', MaxESerie, ESerieEnumManager.NameRegister)"/>
<Execute Statement="Tolerance:= 40⌠%⌡"/>
Expand All @@ -118,13 +122,12 @@
<Execute Statement="Tolerance:= 0.5⌠%⌡"/>
</On>
</Case>
<Execute Statement="Granularity:= TValueGranularity.Fine"/>
<Execute Statement="Granularity:= Ini.ReadEnum('Granularity', Granularity, ValueGranularityEnumManager.NameRegister)"/>
<Execute Statement="Tolerance:= Ini.ReadDecimalQuantity('Tolerance', Tolerance)"/>
<Execute Statement="Refine:= Ini.ReadBool('Refine', True)"/>
<Execute Statement="RefineESerie:= GetESerie(MaxESerie)"/>
<rep:Reporter.LabelValue Label="'Tolerances'" Value="DQToStr(Tolerance, False)" Target="ElectronicsTasks"/>
<rep:Reporter.LabelValue Label="'UseESeries'" Value="IfElse(UseESeries, sYes, sNo)" Target="ElectronicsTasks"/>
<rep:Reporter.LabelValue Label="'Granularity'" Value="ValueGranularityEnumManager.NameRegister.Keys[Granularity]" Target="ElectronicsTasks"/>
<rep:Reporter.LabelValue Label="'Tolerances'" Value="DQToStr(Tolerance, False)" Target="ElectronicsTasks"/>
<rep:Reporter.LabelValue Label="'MaxESerie'" Value="ESerieEnumManager.NameRegister.Keys[MaxESerie]" Target="ElectronicsTasks"/>
<rep:Reporter.LabelValue Label="'Refine'" Value="IfElse(Refine, sYes, sNo)" Target="ElectronicsTasks"/>
<Task.MarkHandled/>
Expand Down Expand Up @@ -256,8 +259,7 @@
<Objects.Use>
<Object Identifier="Configuration" Type="TBaseComponentConfiguration" Expression="CreateCompConfigObject(ConfigurationKind)"/>
<Block>
<Variable Identifier="ValueSets" Type="TValueSets" Init="ValuesManager.GetValueSets(Configuration, CombinationParameters.Granularity, CombinationParameters.MaxESerie)"/>
<Variable Identifier="ESerieValues" Type="TESerieValues" Init="ValuesManager.GetValueSetsValues(ValueSets)"/>
<Task.Assert Expression="Assigned(AvailableInputTask) or CombinationParameters.UseEseries" FailMessage="cAssertEitherEseriesOrAvailableValues" FailTarget="ElectronicsTasks"/>
<!-- function MatchingValues(const TargetValue: Decimal; SerieValues: TESerieValues; out A, B, C, D: TSerieNode; out ScaleA, ScaleB, ScaleC, ScaleD: Int16; out Diff: Extended): Decimal;
-->
<Variable Identifier="TargetValue" Type="DecimalQuantity" Init="CombinationTarget.Value"/>
Expand All @@ -275,21 +277,43 @@
<Variable Identifier="ScaleD" Type="Int32"/>
<Variable Identifier="Diff" Type="Extended"/>
<Variable Identifier="HasRefined" Type="Boolean" Init="False"/>
<Variable Identifier="Rd" Type="Decimal" Init="Configuration.MatchingValues(TargetValue, ESerieValues, AvailableValues, NodeA, NodeB, NodeC, NodeD, ScaleA, ScaleB, ScaleC, ScaleD, Diff)"/>
<Task.Assert Expression="Assigned(NodeA)"/>
<Variable Identifier="HasFullSet" Type="Boolean" Init="False"/>
<Variable Identifier="Rd" Type="Decimal"/>
<Variable Identifier="Ad" Type="Decimal" Init="0"/>
<Variable Identifier="Bd" Type="Decimal" Init="0"/>
<Variable Identifier="Cd" Type="Decimal" Init="0"/>
<Variable Identifier="Dd" Type="Decimal" Init="0"/>

<Execute Statement="Ad:= ScaleDecimal(NodeA.Value, ScaleA)" Condition="Assigned(NodeA)"/>
<Execute Statement="Bd:= ScaleDecimal(NodeB.Value, ScaleB)" Condition="Assigned(NodeB)"/>
<Execute Statement="Cd:= ScaleDecimal(NodeC.Value, ScaleC)" Condition="Assigned(NodeC)"/>
<Execute Statement="Dd:= ScaleDecimal(NodeD.Value, ScaleD)" Condition="Assigned(NodeD)"/>
<Block Condition="CombinationParameters.Refine">
<Execute Statement="HasRefined:= Configuration.RefineValues(TargetValue, CombinationParameters.RefineESerie, AvailableValues, Ad, Bd, Cd, Dd, Rd, Diff)"/>
</Block>
<Execute Statement="InputCount:= Configuration.GetComponentCount"/>
<Choose>
<When Expression="CombinationParameters.UseEseries">
<Variable Identifier="ValueSets" Type="TValueSets" Init="ValuesManager.GetValueSets(Configuration, CombinationParameters.Granularity, CombinationParameters.MaxESerie)"/>
<Variable Identifier="SimulationValues" Type="TESerieValues" Init="ValuesManager.GetValueSetsValues(ValueSets)"/>
<Task.Assert Expression="Configuration.ESeriesSimulate(TargetValue, SimulationValues, AvailableValues, NodeA, NodeB, NodeC, NodeD, ScaleA, ScaleB, ScaleC, ScaleD, Rd, Diff)"/>
<Execute Statement="Ad:= ScaleDecimal(NodeA.Value, ScaleA)" Condition="Assigned(NodeA)"/>
<Execute Statement="Bd:= ScaleDecimal(NodeB.Value, ScaleB)" Condition="Assigned(NodeB)"/>
<Execute Statement="Cd:= ScaleDecimal(NodeC.Value, ScaleC)" Condition="Assigned(NodeC)"/>
<Execute Statement="Dd:= ScaleDecimal(NodeD.Value, ScaleD)" Condition="Assigned(NodeD)"/>
</When>
<Otherwise>
<Variable Identifier="IncludedValues" Type="TESerieValues"/>
<Variable Identifier="ExcludedValues" Type="TESerieValues"/>
<Choose>
<When Expression="ValuesManager.PreparedSimulationValues(Configuration, CombinationParameters.Granularity, AvailableValues, TargetValue, IncludedValues, ExcludedValues)">
<rep:Reporter.LabelValue Label="cValuesIncluded" Value="Format('%d', IncludedValues.Count)" Target="ElectronicsTasks"/>
<rep:Reporter.LabelValue Label="cValuesExcluded" Value="Format('%d', ExcludedValues.Count)" Target="ElectronicsTasks"/>
<Task.Assert Expression="Configuration.Simulate(TargetValue, IncludedValues, Ad, Bd, Cd, Dd, Rd, Diff)"/>
</When>
<Otherwise>
<rep:Reporter.LabelValue Label="cValuesIncluded" Value="Format('%d', AvailableValues.Count)" Target="ElectronicsTasks"/>
<Task.Assert Expression="Configuration.Simulate(TargetValue, AvailableValues, Ad, Bd, Cd, Dd, Rd, Diff)"/>
<Execute Statement="HasFullSet:= True"/>
</Otherwise>
</Choose>
</Otherwise>
</Choose>

<Execute Statement="HasRefined:= Configuration.RefineValues(TargetValue, CombinationParameters.RefineESerie, AvailableValues, Ad, Bd, Cd, Dd, Rd, Diff)" Condition="not HasFullSet and CombinationParameters.Refine"/>

<ForLoop Indexer="I" From="0" To="InputCount - 1">
<Case Expression="I" Optimalisation="integermapping">
<On Select="0">
Expand All @@ -307,14 +331,7 @@
</Case>
<Execute Statement="InputValues[I]:= InputValues[I] ± (InputValues[I] * ToleranceFrac)"/>
</ForLoop>
<!--<Variable Identifier="A" Type="DecimalQuantity" Init="Ad ~ UnitS" Condition="Assigned(NodeA)"/>
<Variable Identifier="B" Type="DecimalQuantity" Init="Bd ~ UnitS" Condition="Assigned(NodeB)"/>
<Variable Identifier="C" Type="DecimalQuantity" Init="Cd ~ UnitS" Condition="Assigned(NodeC)"/>
<Variable Identifier="D" Type="DecimalQuantity" Init="Dd ~ UnitS" Condition="Assigned(NodeD)"/>
<Execute Statement="A:= A ± (A * ToleranceFrac)" Condition="Assigned(NodeA)"/>
<Execute Statement="B:= B ± (B * ToleranceFrac)" Condition="Assigned(NodeB)"/>
<Execute Statement="C:= C ± (C * ToleranceFrac)" Condition="Assigned(NodeC)"/>
<Execute Statement="D:= D ± (D * ToleranceFrac)" Condition="Assigned(NodeD)"/>-->

<Choose>
<When Expression="Configuration is TConfig1">
<Execute Statement="ComboResult:= TConfig1(Configuration).GetValue(InputValues[0])"/>
Expand All @@ -332,17 +349,11 @@
<Execute Statement="ComboResult:= Rd ~ UnitS"/>
</Otherwise>
</Choose>
<!--<rep:Reporter.Information Text="'Output'" Markup="Header3" Target="ElectronicsTasks"/>-->
<rep:Reporter.LabelValue Label="'Matches specs'" Value="IfElse(MatchesSpec(ComboResult, TargetValue), 'YES', 'NO!')" Target="ElectronicsTasks"/>
<rep:Reporter.LabelValue Label="'Used E-series'" Value="(ValueSetsEnumManager.NameRegister.Objects[ValueSets] as TValueSetsEnumInfo).Description" Target="ElectronicsTasks"/>
<rep:Reporter.LabelValue Label="'Relative difference'" Value="StoreDecimalQuantityToStr(Diff * cFracToPerc, 5)" Target="ElectronicsTasks"/>
<rep:Reporter.LabelValue Label="'Refined'" Value="IfElse(HasRefined, sYes, sNo)" Target="ElectronicsTasks"/>
<rep:Reporter.LabelValue Label="'Result'" Value="DQToStr(ComboResult, True)" Target="ElectronicsTasks"/>
<!--<rep:Reporter.Information Text="'Input'" Markup="Header3" Target="ElectronicsTasks"/>-->
<!--<rep:Reporter.LabelValue Label="'A'" Value="DQToStr(A, True)" Target="ElectronicsTasks" Condition="Assigned(NodeA)"/>
<rep:Reporter.LabelValue Label="'B'" Value="DQToStr(B, True)" Target="ElectronicsTasks" Condition="Assigned(NodeB)"/>
<rep:Reporter.LabelValue Label="'C'" Value="DQToStr(C, True)" Target="ElectronicsTasks" Condition="Assigned(NodeC)"/>
<rep:Reporter.LabelValue Label="'D'" Value="DQToStr(D, True)" Target="ElectronicsTasks" Condition="Assigned(NodeD)"/>-->
<rep:Reporter.LabelValue Label="cMatchesSpecs" Value="IfElse(MatchesSpec(ComboResult, TargetValue), sYes, sNo)" Target="ElectronicsTasks"/>
<rep:Reporter.LabelValue Label="cUsedESeries" Value="(ValueSetsEnumManager.NameRegister.Objects[ValueSets] as TValueSetsEnumInfo).Description" Target="ElectronicsTasks" Condition="CombinationParameters.UseEseries"/>
<rep:Reporter.LabelValue Label="cRelativeDifference" Value="StoreDecimalQuantityToStr(Diff * cFracToPerc, 5)" Target="ElectronicsTasks"/>
<rep:Reporter.LabelValue Label="cRefined" Value="IfElse(HasRefined, sYes, sNo)" Target="ElectronicsTasks"/>
<rep:Reporter.LabelValue Label="cResult" Value="DQToStr(ComboResult, True)" Target="ElectronicsTasks"/>
<ForLoop Indexer="I" From="0" To="InputCount - 1">
<rep:Reporter.LabelValue Label="ListValue(I, '', 'A', 'B', 'C', 'D')" Value="DQToStr(InputValues[I], True)" Target="ElectronicsTasks"/>
</ForLoop>
Expand Down
6 changes: 5 additions & 1 deletion Script.Project.Libs/BOM enumerations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
<VirtualMethod Identifier="vmGetEnumBounds" Override="true"/>
</DataClass>

<Enumeration Identifier="TUseStock" Elements="No,Source,SourceAndMatch" LowAlias="Low" HighAlias="High"/>
<Enumeration Identifier="TUseStock" Elements="No,Source,SourceAndMatch, MatchOnly" LowAlias="Low" HighAlias="High"/>

<DataClass Identifier="TUseStockEnumInfo" ClassOfIdentifier="TTUseStockEnumInfo" Inherit="TEnumInfo" DefaultConstructor="createandsetfields">
<VirtualMethod Identifier="vmGetInfo" Override="true"/>
Expand Down Expand Up @@ -348,6 +348,7 @@
<Variable Identifier="cUseStockNo" Type="TUseStockEnumInfo" Init="TUseStockEnumInfo.Create(TUseStock.No, 'No')"/>
<Variable Identifier="cUseStockSource" Type="TUseStockEnumInfo" Init="TUseStockEnumInfo.Create(TUseStock.Source, 'Source')"/>
<Variable Identifier="cUseStockSourceAndMatch" Type="TUseStockEnumInfo" Init="TUseStockEnumInfo.Create(TUseStock.SourceAndMatch, 'SourceAndMatch')"/>
<Variable Identifier="cUseStockMatchOnly" Type="TUseStockEnumInfo" Init="TUseStockEnumInfo.Create(TUseStock.MatchOnly, 'MatchOnly')"/>
<Variable Identifier="UseStockEnumManager" Type="TEnumManager" Init="TEnumManager.Create(TUseStockEnumInfo)"/>
<Variable Identifier="UseStockNameRegister" Type="TEnumNameRegister"/>
</Variables>
Expand Down Expand Up @@ -1223,6 +1224,9 @@
<On Select="TUseStock.SourceAndMatch">
<Execute Statement="Result:= cUseStockSourceAndMatch"/>
</On>
<On Select="TUseStock.MatchOnly">
<Execute Statement="Result:= cUseStockMatchOnly"/>
</On>
<Otherwise>
<Raise Expression="Exception.Create(sErrorInvalidUseStock)"/>
</Otherwise>
Expand Down
17 changes: 11 additions & 6 deletions Script.Project/Generate BOM.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ MaxShowResistorVoltage=230V
Value = 123.0 Ω ± 2%

[ComponentCombinations.Stock]
;UseStock=No|Source|SourceAndMatch
;UseStock=No|Source|SourceAndMatch|MatchOnly
;UseStock=SourceAndMatch

[CombinationTarget.Input.Resistor]
Expand All @@ -81,11 +81,16 @@ ComponentKind=Inductor
;Source=None|InputTab|TextFile
;Source=None

[ElectronicsTasks.AvailableValues.TextFile]
;Filename=..\Resources.Project\Resistor values.txt

[ElectronicsTasks.CombinationParameters]
;MaxESerie=E1|E3|E6|E12|E24|E48|E96|E192
;MaxESerie=E24
;UseESeries=0|1
;UseESeries=0
;Granularity=ExtraCoarse|Coarse|Fine|ExtraFine
;Granularity=Fine
;MaxESerie=E1|E3|E6|E12|E24|E48|E96|E192
;MaxESerie=E24
;Refine=0|1
;Refine=1
;Tolerance=2%
Expand Down Expand Up @@ -214,7 +219,7 @@ ID = -1

<Constants>
<Constant Identifier="connsPartKeepr" Type="string" Expression="'Provider=MSDASQL.1;Persist Security Info=False;Data Source=PartKeepr;Initial Catalog=PartKeepr'"/>
<Constant Identifier="ScriptVersion" Type="string" Expression="'7.00.3.0.1.66'"/>
<Constant Identifier="ScriptVersion" Type="string" Expression="'7.4.3.0.3.70'"/>
</Constants>

<Variables>
Expand Down Expand Up @@ -928,7 +933,7 @@ ID = -1

<Task Identifier="ComponentCombinations.Stock">
<Variables>
<Variable Identifier="AvailableInputTask" Type="TTaskRef" Init="Task.InstanceObject as TTaskRef"/>
<Variable Identifier="AvailableInputTask" Type="TTaskRef" Init="Task.InstanceObject"/>
</Variables>
<Init>
<Task.Description Expression="cCompCombosTaskStock"/>
Expand Down Expand Up @@ -961,7 +966,7 @@ ID = -1
</Case>
</Object.Use>
<Case Expression="UseStock">
<On Select="TUseStock.SourceAndMatch">
<On Select="TUseStock.SourceAndMatch, TUseStock.MatchOnly">
<Task.AddDependency Task="ComponentCombinations.Stock" Condition="InFlags(TUnattendedTask.ComponentCombinations, TaskSelectionFlags)" InstanceObject="AvailableInputTask" IgnoreFailure="True"/>
</On>
<Otherwise>
Expand Down

0 comments on commit 1725494

Please sign in to comment.