Merge remote-tracking branch 'origin/master'

This commit is contained in:
rusefi 2021-01-02 17:20:58 -05:00
commit 87bd9a4320
80 changed files with 101 additions and 30003 deletions

View File

@ -616,7 +616,7 @@ typedef enum {
/**
* only one injector located in throttle body
*/
IM_SINGLE_POINT = 3,
IM_SINGLE_POINT = IM_IM_SINGLE_POINT,
Force_4_bytes_size_injection_mode = ENUM_32_BITS,

View File

@ -120,6 +120,16 @@ static void doRunFuel(int humanIndex, const char *delayStr, const char * onTimeS
pinbench(delayStr, onTimeStr, offTimeStr, countStr, &enginePins.injectors[humanIndex - 1], b);
}
static void doTestSolenoid(int humanIndex, const char *delayStr, const char * onTimeStr, const char *offTimeStr,
const char *countStr) {
if (humanIndex < 1 || humanIndex > TCU_SOLENOID_COUNT) {
scheduleMsg(logger, "Invalid index: %d", humanIndex);
return;
}
brain_pin_e b = CONFIG(tcu_solenoid)[humanIndex - 1];
pinbench(delayStr, onTimeStr, offTimeStr, countStr, &enginePins.tcuSolenoids[humanIndex - 1], b);
}
static void doBenchTestFsio(int humanIndex, const char *delayStr, const char * onTimeStr, const char *offTimeStr,
const char *countStr) {
if (humanIndex < 1 || humanIndex > FSIO_COMMAND_COUNT) {
@ -140,6 +150,16 @@ static void fuelbench2(const char *delayStr, const char *indexStr, const char *
doRunFuel(index, delayStr, onTimeStr, offTimeStr, countStr);
}
/**
* delay 100, solenoid #2, 1000ms ON, 1000ms OFF, repeat 3 times
* tcusolbench 100 2 1000 1000 3
*/
static void tcusolbench(const char *delayStr, const char *indexStr, const char * onTimeStr, const char *offTimeStr,
const char *countStr) {
int index = atoi(indexStr);
doTestSolenoid(index, delayStr, onTimeStr, offTimeStr, countStr);
}
/**
* delay 100, channel #1, 5ms ON, 1000ms OFF, repeat 3 times
* fsiobench2 100 1 5 1000 3
@ -409,6 +429,7 @@ void initBenchTest(Logging *sharedLogger) {
addConsoleAction(CMD_HPFP_BENCH, hpfpValveBench);
addConsoleActionSSSSS("fuelbench2", fuelbench2);
addConsoleActionSSSSS("tcusolbench", tcusolbench);
addConsoleActionSSSSS("fsiobench2", fsioBench2);
addConsoleActionSSSSS("sparkbench2", sparkbench2);
instance.setPeriod(200 /*ms*/);

View File

@ -1,2 +1,2 @@
#pragma once
#define VCS_DATE 20210101
#define VCS_DATE 20210102

View File

@ -1,4 +1,4 @@
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.sh integration/rusefi_config.txt Fri Jan 01 16:20:01 UTC 2021
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.sh integration/rusefi_config.txt Sat Jan 02 21:44:47 UTC 2021
// by class com.rusefi.output.FileFsioSettingsConsumer
FSIO_SETTING_FANONTEMPERATURE = 1000,

View File

@ -1,4 +1,4 @@
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.sh integration/rusefi_config.txt Fri Jan 01 16:20:01 UTC 2021
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.sh integration/rusefi_config.txt Sat Jan 02 21:44:47 UTC 2021
// by class com.rusefi.output.FileFsioSettingsConsumer
case FSIO_SETTING_FANONTEMPERATURE:

View File

@ -1,4 +1,4 @@
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.sh integration/rusefi_config.txt Fri Jan 01 16:20:01 UTC 2021
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.sh integration/rusefi_config.txt Sat Jan 02 21:44:47 UTC 2021
// by class com.rusefi.output.FileFsioSettingsConsumer
static LENameOrdinalPair lefanOnTemperature(FSIO_SETTING_FANONTEMPERATURE, "cfg_fanOnTemperature");

View File

@ -1,4 +1,4 @@
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.sh integration/rusefi_config.txt Fri Jan 01 16:20:01 UTC 2021
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on gen_config.sh integration/rusefi_config.txt Sat Jan 02 21:44:47 UTC 2021
// by class com.rusefi.output.FileFsioSettingsConsumer
case FSIO_SETTING_FANONTEMPERATURE:

View File

@ -3,6 +3,6 @@
//
#define SIGNATURE_BOARD all
#define SIGNATURE_DATE 2021.01.01
#define SIGNATURE_HASH 2718166867
#define TS_SIGNATURE "rusEFI 2021.01.01.all.2718166867"
#define SIGNATURE_DATE 2021.01.02
#define SIGNATURE_HASH 772210171
#define TS_SIGNATURE "rusEFI 2021.01.02.all.772210171"

View File

@ -3,6 +3,6 @@
//
#define SIGNATURE_BOARD frankenso_na6
#define SIGNATURE_DATE 2021.01.01
#define SIGNATURE_HASH 879976104
#define TS_SIGNATURE "rusEFI 2021.01.01.frankenso_na6.879976104"
#define SIGNATURE_DATE 2021.01.02
#define SIGNATURE_HASH 3094760448
#define TS_SIGNATURE "rusEFI 2021.01.02.frankenso_na6.3094760448"

View File

@ -3,6 +3,6 @@
//
#define SIGNATURE_BOARD hellen_cypress
#define SIGNATURE_DATE 2021.01.01
#define SIGNATURE_HASH 1811040656
#define TS_SIGNATURE "rusEFI 2021.01.01.hellen_cypress.1811040656"
#define SIGNATURE_DATE 2021.01.02
#define SIGNATURE_HASH 3891747640
#define TS_SIGNATURE "rusEFI 2021.01.02.hellen_cypress.3891747640"

View File

@ -3,6 +3,6 @@
//
#define SIGNATURE_BOARD kin
#define SIGNATURE_DATE 2021.01.01
#define SIGNATURE_HASH 988705642
#define TS_SIGNATURE "rusEFI 2021.01.01.kin.988705642"
#define SIGNATURE_DATE 2021.01.02
#define SIGNATURE_HASH 3068879298
#define TS_SIGNATURE "rusEFI 2021.01.02.kin.3068879298"

View File

@ -3,6 +3,6 @@
//
#define SIGNATURE_BOARD mre_f4
#define SIGNATURE_DATE 2021.01.01
#define SIGNATURE_HASH 3050516778
#define TS_SIGNATURE "rusEFI 2021.01.01.mre_f4.3050516778"
#define SIGNATURE_DATE 2021.01.02
#define SIGNATURE_HASH 970335106
#define TS_SIGNATURE "rusEFI 2021.01.02.mre_f4.970335106"

View File

@ -3,6 +3,6 @@
//
#define SIGNATURE_BOARD mre_f7
#define SIGNATURE_DATE 2021.01.01
#define SIGNATURE_HASH 3050516778
#define TS_SIGNATURE "rusEFI 2021.01.01.mre_f7.3050516778"
#define SIGNATURE_DATE 2021.01.02
#define SIGNATURE_HASH 970335106
#define TS_SIGNATURE "rusEFI 2021.01.02.mre_f7.970335106"

View File

@ -3,6 +3,6 @@
//
#define SIGNATURE_BOARD prometheus_405
#define SIGNATURE_DATE 2021.01.01
#define SIGNATURE_HASH 3772508418
#define TS_SIGNATURE "rusEFI 2021.01.01.prometheus_405.3772508418"
#define SIGNATURE_DATE 2021.01.02
#define SIGNATURE_HASH 1826552746
#define TS_SIGNATURE "rusEFI 2021.01.02.prometheus_405.1826552746"

View File

@ -3,6 +3,6 @@
//
#define SIGNATURE_BOARD prometheus_469
#define SIGNATURE_DATE 2021.01.01
#define SIGNATURE_HASH 3772508418
#define TS_SIGNATURE "rusEFI 2021.01.01.prometheus_469.3772508418"
#define SIGNATURE_DATE 2021.01.02
#define SIGNATURE_HASH 1826552746
#define TS_SIGNATURE "rusEFI 2021.01.02.prometheus_469.1826552746"

View File

@ -3,6 +3,6 @@
//
#define SIGNATURE_BOARD proteus_f4
#define SIGNATURE_DATE 2021.01.01
#define SIGNATURE_HASH 1806280077
#define TS_SIGNATURE "rusEFI 2021.01.01.proteus_f4.1806280077"
#define SIGNATURE_DATE 2021.01.02
#define SIGNATURE_HASH 3886855973
#define TS_SIGNATURE "rusEFI 2021.01.02.proteus_f4.3886855973"

View File

@ -3,6 +3,6 @@
//
#define SIGNATURE_BOARD proteus_f7
#define SIGNATURE_DATE 2021.01.01
#define SIGNATURE_HASH 1806280077
#define TS_SIGNATURE "rusEFI 2021.01.01.proteus_f7.1806280077"
#define SIGNATURE_DATE 2021.01.02
#define SIGNATURE_HASH 3886855973
#define TS_SIGNATURE "rusEFI 2021.01.02.proteus_f7.3886855973"

View File

@ -429,6 +429,8 @@ end_struct
! todo https://github.com/rusefi/rusefi/issues/2102
#define DBG_DBG_LOGIC_ANALYZER 45
! todo https://github.com/rusefi/rusefi/issues/2102
#define IM_IM_SINGLE_POINT 3
! todo https://github.com/rusefi/rusefi/issues/2102
#define ET_DODGE_NEON_1995 2
@ -1427,9 +1429,9 @@ tChargeMode_e tChargeMode;
float etbIdleThrottleRange; ETB idle authority; "%", 1, 0, 0, 15, 0
uint8_t[4] unusedvref;;"units", 1, 0, -20, 100, 0
uint8_t[4] unusedsw;;"units", 1, 0, -20, 100, 0
int[3] unused_alFIn;;"units", 1, 0, -20, 100, 0
uint8_t[INJECTION_PIN_COUNT iterate] cylinderBankSelect;+Select which fuel correction bank this cylinder belongs to. Group cylinders that share the same O2 sensor; "", 1, 1, 1, 2, 0
int[2] unused4028;;"units", 1, 0, -20, 100, 0
uint8_t triggerCompCenterVolt;+Trigger comparator center point voltage;"V", @@VOLTAGE_1_BYTE_PACKING_DIV@@, 0, 0.0, 5.1, 2
uint8_t triggerCompHystMin;+Trigger comparator hysteresis voltage (Min);"V", @@VOLTAGE_1_BYTE_PACKING_DIV@@, 0, 0.0, 5.1, 2

View File

@ -1524,6 +1524,7 @@ menuDialog = main
subMenu = multisparkSettings, "Multispark", 0, {isIgnitionEnabled == 1}
subMenu = mc33Dialog, "GDI Dreams"
subMenu = widebandConfig, "rusEFI Wideband Controller", 0, { canReadEnabled && canWriteEnabled }
subMenu = cylinderBankSelect, "Cylinder Bank Selection"
subMenu = std_separator
subMenu = hipFunction, "HIP9011 settings (knock sensor) (alpha version)" @@if_ts_show_hip9011
@ -1812,10 +1813,10 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
field = "Use only first half of pins for batch mode"
field = "Injection Pin 1", injectionPins1, {isInjectionEnabled == 1}
field = "Injection Pin 2", injectionPins2, {isInjectionEnabled == 1 && injectionMode != 3 && cylindersCount > 1}
field = "Injection Pin 3", injectionPins3, {isInjectionEnabled == 1 && injectionMode != 3 && cylindersCount > 2}
field = "Injection Pin 3", injectionPins3, {isInjectionEnabled == 1 && injectionMode != @@IM_IM_SINGLE_POINT@@ && cylindersCount > 2}
field = "Injection Pin 4", injectionPins4, {isInjectionEnabled == 1 && injectionMode != 3 && cylindersCount > 3}
field = "Injection Pin 5 ", injectionPins5, {isInjectionEnabled == 1 && injectionMode != 3 && cylindersCount > 4}
field = "Injection Pin 6 ", injectionPins6, {isInjectionEnabled == 1 && injectionMode != 3 && cylindersCount > 5}
field = "Injection Pin 5 ", injectionPins5, {isInjectionEnabled == 1 && injectionMode != @@IM_IM_SINGLE_POINT@@ && cylindersCount > 4}
field = "Injection Pin 6 ", injectionPins6, {isInjectionEnabled == 1 && injectionMode != @@IM_IM_SINGLE_POINT@@ && cylindersCount > 5}
field = "Injection Pin 7 ", injectionPins7, {isInjectionEnabled == 1 && injectionMode != 3 && cylindersCount > 6}
field = "Injection Pin 8 ", injectionPins8, {isInjectionEnabled == 1 && injectionMode != 3 && cylindersCount > 7}
field = "Injection Pin 9 ", injectionPins9, {isInjectionEnabled == 1 && cylindersCount > 8}
@ -1825,6 +1826,20 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
field = ""
field = "injection Pin Mode", injectionPinMode, {isInjectionEnabled == 1}
dialog = cylinderBankSelect, "Cylinder Banks", yAxis
field = "Cylinder 1", cylinderBankSelect1, {isInjectionEnabled == 1}
field = "Cylinder 2", cylinderBankSelect2, {isInjectionEnabled == 1 && injectionMode != @@IM_IM_SINGLE_POINT@@ && cylindersCount > 1}
field = "Cylinder 3", cylinderBankSelect3, {isInjectionEnabled == 1 && injectionMode != @@IM_IM_SINGLE_POINT@@ && cylindersCount > 2}
field = "Cylinder 4", cylinderBankSelect4, {isInjectionEnabled == 1 && injectionMode != 3 && cylindersCount > 3}
field = "Cylinder 5 ", cylinderBankSelect5, {isInjectionEnabled == 1 && injectionMode != 3 && cylindersCount > 4}
field = "Cylinder 6 ", cylinderBankSelect6, {isInjectionEnabled == 1 && injectionMode != 3 && cylindersCount > 5}
field = "Cylinder 7 ", cylinderBankSelect7, {isInjectionEnabled == 1 && injectionMode != 3 && cylindersCount > 6}
field = "Cylinder 8 ", cylinderBankSelect8, {isInjectionEnabled == 1 && injectionMode != 3 && cylindersCount > 7}
field = "Cylinder 9 ", cylinderBankSelect9, {isInjectionEnabled == 1 && cylindersCount > 8}
field = "Cylinder 10 ", cylinderBankSelect10, {isInjectionEnabled == 1 && cylindersCount > 9}
field = "Cylinder 11 ", cylinderBankSelect11, {isInjectionEnabled == 1 && cylindersCount > 10}
field = "Cylinder 12 ", cylinderBankSelect12, {isInjectionEnabled == 1 && cylindersCount > 11}
dialog = testFsio, "FSIO Test"
commandButton = "FSIO#1", cmd_test_fsio1
commandButton = "FSIO#2", cmd_test_fsio2

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -28,6 +28,7 @@ public class BenchTestPane {
content.add(createFuelPumpTest());
content.add(createSparkTest());
content.add(createInjectorTest());
content.add(createSolenoidTest());
content.add(createMILTest());
content.add(createIdleTest());
content.add(createStarterTest());
@ -105,7 +106,7 @@ public class BenchTestPane {
}
private Component createSparkTest() {
final JComboBox<Integer> indexes = createIndexCombo();
final JComboBox<Integer> indexes = createIndexCombo(Fields.IGNITION_PIN_COUNT);
CommandControl panel = new CommandControl(uiContext,"Spark #", "spark.jpg", TEST, indexes) {
@Override
protected String getCommand() {
@ -116,7 +117,7 @@ public class BenchTestPane {
}
private Component createInjectorTest() {
final JComboBox<Integer> indexes = createIndexCombo();
final JComboBox<Integer> indexes = createIndexCombo(Fields.INJECTION_PIN_COUNT);
CommandControl panel = new CommandControl(uiContext,"Injector #", "injector.png", TEST, indexes) {
@Override
protected String getCommand() {
@ -126,10 +127,21 @@ public class BenchTestPane {
return panel.getContent();
}
private Component createSolenoidTest() {
final JComboBox<Integer> indexes = createIndexCombo(Fields.TCU_SOLENOID_COUNT);
CommandControl panel = new CommandControl(uiContext,"TCU Solenoid #", "solenoid.jpg", TEST, indexes) {
@Override
protected String getCommand() {
return "tcusolbench 1000 " + indexes.getSelectedItem() + " 1000 1000 3";
}
};
return panel.getContent();
}
@NotNull
private JComboBox<Integer> createIndexCombo() {
private JComboBox<Integer> createIndexCombo(Integer count) {
JComboBox<Integer> indexes = new JComboBox<>();
for (int i = 1; i <= 12; i++) {
for (int i = 1; i <= count; i++) {
indexes.addItem(i);
}
return indexes;
@ -139,4 +151,4 @@ public class BenchTestPane {
return content;
}
}
}

Binary file not shown.

View File

@ -1 +0,0 @@
CmpMerge

View File

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac" />
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>

View File

@ -1,5 +0,0 @@
<component name="CopyrightManager">
<settings default="">
<module2copyright />
</settings>
</component>

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
</project>

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
<component name="SvnBranchConfigurationManager">
<option name="mySupportsUserInfoFilter" value="true" />
</component>
</project>

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/CmpMerge.iml" filepath="$PROJECT_DIR$/CmpMerge.iml" />
</modules>
</component>
</project>

View File

@ -1,5 +0,0 @@
<component name="DependencyValidationManager">
<state>
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</state>
</component>

View File

@ -1,125 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="svn" />
</component>
</project>

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -1,24 +0,0 @@
<project default="jar">
<target name="clean">
<delete dir="build"/>
</target>
<target name="compile">
<mkdir dir="build/classes"/>
<javac destdir="build/classes" classpath="lib/junit.jar:lib/annotations.jar">
<src path="src"/>
</javac>
</target>
<target name="jar" depends="compile">
<mkdir dir="build/jar"/>
<jar destfile="../cmp_merge.jar" basedir="build/classes">
<manifest>
<attribute name="Main-Class" value="rusefi.CmpMerge"/>
</manifest>
<zipfileset dir="build/classes" includes="**/*.class"/>
</jar>
</target>
</project>

View File

@ -1,63 +0,0 @@
package rusefi;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
/**
* 12/8/13
* (c) Andrey Belomutskiy
*/
public class CmpMerge {
private CmpMerge() {
}
public static void main(String[] args) throws IOException {
if (args.length < 2) {
System.out.println("This tool merges .cmp KiCad component mappting files");
System.out.println("usage:");
System.out.println("NetListMerge DEST_FILE SOURCE_1 SOURCE_2 [SOURCE_x]*");
return;
}
String destinationFile = args[0];
System.out.println("Writing result into " + destinationFile);
BufferedWriter bw = new BufferedWriter(new FileWriter(destinationFile));
bw.write("Cmp-Mod V01 Created by CvPcb (2013-07-07 BZR 4022)-stable date = 01/12/2013 21:54:01\r\n");
for (int i = 1; i < args.length; i++) {
String sourceFile = args[i];
List<String> list = readFileToList(sourceFile);
for (String line : list.subList(1, list.size() - 2))
bw.write(line + "\r\n");
}
bw.write("\r\nEndListe\r\n");
bw.close();
}
static List<String> readFileToList(String fileName) throws IOException {
checkExistence(fileName);
List<String> result = new ArrayList<String>();
System.out.println("Reading " + fileName);
String line;
BufferedReader br = new BufferedReader(new FileReader(fileName));
while (((line = br.readLine()) != null))
result.add(line);
return result;
}
private static void checkExistence(String fileName) {
if (!new File(fileName).isFile()) {
System.err.println("File not found: " + fileName);
System.exit(-1);
}
}
}

Binary file not shown.

View File

@ -1 +0,0 @@
net_list_merge

View File

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac" />
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>

View File

@ -1,5 +0,0 @@
<component name="CopyrightManager">
<settings default="">
<module2copyright />
</settings>
</component>

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
</project>

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
<component name="SvnBranchConfigurationManager">
<option name="mySupportsUserInfoFilter" value="true" />
</component>
</project>

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/net_list_merge.iml" filepath="$PROJECT_DIR$/net_list_merge.iml" />
</modules>
</component>
</project>

View File

@ -1,5 +0,0 @@
<component name="DependencyValidationManager">
<state>
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</state>
</component>

View File

@ -1,125 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="svn" />
</component>
</project>

View File

@ -1,24 +0,0 @@
<project default="jar">
<target name="clean">
<delete dir="build"/>
</target>
<target name="compile">
<mkdir dir="build/classes"/>
<javac destdir="build/classes" classpath="lib/junit.jar:lib/annotations.jar">
<src path="src"/>
</javac>
</target>
<target name="jar" depends="compile">
<mkdir dir="build/jar"/>
<jar destfile="../net_list_merge.jar" basedir="build/classes">
<manifest>
<attribute name="Main-Class" value="rusefi.NetListMerge"/>
</manifest>
<zipfileset dir="build/classes" includes="**/*.class"/>
</jar>
</target>
</project>

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -1,123 +0,0 @@
package rusefi;
import java.io.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static rusefi.NetListMergeUtil.validateSection;
/**
* 12/8/13
* (c) Andrey Belomutskiy
*/
public class NetListMerge {
private static final Pattern GET_HEADER = Pattern.compile("(.*)\\(components(.*)\\s*$", Pattern.DOTALL);
private static final Pattern GET_COMPONENTS = Pattern.compile("(.*)\\)\\s*\\(libparts(.*)\\)\\)\\s*$", Pattern.DOTALL);
private static final Pattern GET_LIBRARTS = Pattern.compile("(.*)\\)\\s*\\(libraries(.*)", Pattern.DOTALL);
private static final Pattern GET_LIBRARIES = Pattern.compile("(.*)\\)\\s*\\(nets(.*)", Pattern.DOTALL);
private NetListMerge() {
}
public static void main(String[] args) throws IOException {
if (args.length < 2) {
System.out.println("This tool takes 'components' sections of multiple KiCad .net files and merges them into one");
System.out.println("usage:");
System.out.println("NetListMerge DEST_FILE SOURCE_1 SOURCE_2 [SOURCE_x]*");
return;
}
String destinationFile = args[0];
NetContent destination = parse(NetListMergeUtil.readFile(destinationFile));
StringBuilder components = new StringBuilder();
StringBuilder libparts = new StringBuilder();
StringBuilder libraries = new StringBuilder();
StringBuilder nets = new StringBuilder();
for (int i = 1; i < args.length; i++) {
String sourceFile = args[i];
NetContent source = parse(NetListMergeUtil.readFile(sourceFile));
components.append(source.components);
libparts.append(source.libparts);
libraries.append(source.libraries);
nets.append(source.nets);
}
System.out.println("Total " + components.length() + " bytes of components");
System.out.println("Total " + libparts.length() + " bytes of libparts");
System.out.println("Total " + libraries.length() + " bytes of libraries");
System.out.println("Total " + nets.length() + " bytes of nets");
StringBuilder result = new StringBuilder(destination.header);
result.append(" (components").append(components).append(")\r\n");
result.append(" (libparts").append(libparts).append(")\n");
result.append(" (libraries").append(libraries).append(")\n");
result.append(" (nets").append(nets).append(")");
result.append(")");
validateSection(result.toString());
NetListMergeUtil.writeResult(result.toString(), "out.txt");
}
private static class NetContent {
private final String header;
private final String components;
private final String libparts;
private final String nets;
private final String libraries;
private NetContent(String header, String components, String libparts, String libraries, String nets) {
this.header = header;
this.components = components;
this.libparts = libparts;
this.nets = nets;
this.libraries = libraries;
System.out.println("Got " + components.length() + " bytes of components");
System.out.println("Got " + libparts.length() + " bytes of libparts");
System.out.println("Got " + libraries.length() + " bytes of libraries");
System.out.println("Got " + nets.length() + " bytes of nets");
}
}
private static NetContent parse(String content) {
Matcher headerMatcher = GET_HEADER.matcher(content);
headerMatcher.find();
if (!headerMatcher.matches())
throw new IllegalStateException("Does not match expected patten for header");
String header = headerMatcher.group(1);
String nonHeader = headerMatcher.group(2);
Matcher componentsMatcher = GET_COMPONENTS.matcher(nonHeader);
if (!componentsMatcher.matches())
throw new IllegalStateException("Does not match expected patten for components");
String components = componentsMatcher.group(1);
String nonComponents = componentsMatcher.group(2);
validateSection(components);
Matcher libpartsMatcher = GET_LIBRARTS.matcher(nonComponents);
if (!libpartsMatcher.matches())
throw new IllegalStateException("Does not match expected patten for libparts");
String libparts = libpartsMatcher.group(1);
String nonlibparts = libpartsMatcher.group(2);
validateSection(libparts);
Matcher librariesMatcher = GET_LIBRARIES.matcher(nonlibparts);
if (!librariesMatcher.matches())
throw new IllegalStateException("Does not match expected patten for nets");
String libraries = librariesMatcher.group(1);
String nets = librariesMatcher.group(2);
validateSection(libraries);
validateSection(nets);
// System.out.println("components: " + components);
return new NetContent(header, components, libparts, libraries, nets);
}
}

View File

@ -1,51 +0,0 @@
package rusefi;
import java.io.*;
/**
* 12/8/13
* (c) Andrey Belomutskiy
*/
public class NetListMergeUtil {
static void writeResult(String content, String fileName) throws IOException {
System.out.println("Writing result into " + fileName);
BufferedWriter bw = new BufferedWriter(new FileWriter(fileName));
bw.write(content);
bw.close();
}
static String readFile(String fileName) throws IOException {
checkExistence(fileName);
System.out.println("Reading " + fileName);
StringBuilder sb = new StringBuilder();
String line;
BufferedReader br = new BufferedReader(new FileReader(fileName));
while (((line = br.readLine()) != null))
sb.append(line).append("\r\n");
return sb.toString();
}
private static void checkExistence(String fileName) {
if (!new File(fileName).isFile()) {
System.err.println("File not found: " + fileName);
System.exit(-1);
}
}
static void validateSection(String section) {
int counter = 0;
for (int i = 0; i < section.length(); i++) {
char c = section.charAt(i);
if (c == '(')
counter++;
else if (c == ')')
counter--;
if (counter < 0)
throw new IllegalStateException("Invalid section: " + section);
}
if (counter != 0)
throw new IllegalStateException("Invalid section: " + section + " balance: " + counter);
}
}

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +0,0 @@
# move_module P353 -50 0
add adc_amp_divider.kicad_pcb
remove P_VOID1

Binary file not shown.

View File

@ -1,36 +0,0 @@
package com.rusefi;
import com.rusefi.misc.ChangesModel;
import com.rusefi.pcb.PcbMergeTool;
import com.rusefi.pcb.PcbNode;
import java.io.IOException;
/**
* @author Andrey Belomutskiy
* 1/24/14
*/
public class PcbCopyTool {
public static void main(String[] args) throws IOException {
if (args.length != 2) {
System.out.println("Two parameters expected: SOURCE DESTINATION");
return;
}
ChangesModel.readConfiguration("pcb_merge_changes.txt");
String input = args[0];
String output = args[1];
copy(input, output);
}
public static void copy(String input, String output) throws IOException {
System.out.println("From " + input + " to " + output);
PcbNode node = PcbNode.readFromFile(input);
PcbMergeTool.removeNodes(node);
node.write(output);
}
}

View File

@ -1,105 +0,0 @@
package com.rusefi.misc;
import com.rusefi.util.FileUtils;
import java.io.File;
import java.io.IOException;
import java.util.*;
import static com.rusefi.pcb.PcbMergeTool.log;
/**
* 1/19/14
* (c) Andrey Belomutskiy
*/
public class ChangesModel {
private static final ChangesModel instance = new ChangesModel();
private static final String REMOVE = "remove";
private static final String ADD = "add";
private static final String MOVE = "move_module";
private static final String OPTIMIZE = "optimize";
private static final String COPY = "copy";
private static final String MERGE_NET = "merge_net";
public final Set<String> DEL_REQUESTS = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
public final List<NameAndOffset> ADD_REQUESTS = new ArrayList<NameAndOffset>();
public final List<NameAndOffset> MOVE_REQUESTS = new ArrayList<NameAndOffset>();
public final List<TwoFileRequest> OPTIMIZE_REQUESTS = new ArrayList<TwoFileRequest>();
public final List<TwoFileRequest> COPY_REQUESTS = new ArrayList<TwoFileRequest>();
/**
* Old net name > New net name
*/
public final Map<String, String> NET_MERGE_REQUESTS = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
public static ChangesModel getInstance() {
return instance;
}
public static void readConfiguration(String fileName) throws IOException {
if (!new File(fileName).isFile()) {
log("No such file: " + fileName);
return;
}
log("Reading commands from " + fileName);
List<String> a = FileUtils.readFileToList(fileName);
getInstance().read(a);
}
public void read(List<String> lines) {
int lineIndex = 0;
for (String line : lines) {
lineIndex++;
line = line.trim();
if (line.isEmpty())
continue;
if (line.startsWith("#"))
continue; // this line is a comment
if (line.toLowerCase().startsWith(REMOVE)) {
DEL_REQUESTS.add(line.substring(REMOVE.length()).trim());
continue;
} else if (line.toLowerCase().startsWith(ADD)) {
addAddRequest(line.substring(ADD.length()).trim());
continue;
} else if (line.toLowerCase().startsWith(MOVE)) {
addMoveRequest(line.substring(MOVE.length()).trim());
continue;
} else if (line.toLowerCase().startsWith(OPTIMIZE)) {
OPTIMIZE_REQUESTS.add(TwoFileRequest.parseTwoFile(line.substring(OPTIMIZE.length()).trim(), lineIndex));
continue;
} else if (line.toLowerCase().startsWith(COPY)) {
COPY_REQUESTS.add(TwoFileRequest.parseTwoFile(line.substring(COPY.length()).trim(), lineIndex));
continue;
} else if (line.toLowerCase().startsWith(MERGE_NET)) {
TwoFileRequest req = TwoFileRequest.parseTwoFile(line.substring(MERGE_NET.length()).trim(), lineIndex);
NET_MERGE_REQUESTS.put(req.input, req.output);
log("Net " + req.input + " to be merged into " + req.output);
continue;
}
System.err.println("ChangesModel: Ignoring invalid line: " + line);
}
log("Got " + DEL_REQUESTS.size() + " remove request(s)");
log("Got " + ADD_REQUESTS.size() + " add request(s)");
log("Got " + OPTIMIZE_REQUESTS.size() + " optimize request(s)");
log("Got " + NET_MERGE_REQUESTS.size() + " merge net request(s)");
}
private void addMoveRequest(String request) {
MOVE_REQUESTS.add(NameAndOffset.parseNameAndOffset(request));
}
private void addAddRequest(String request) {
ADD_REQUESTS.add(NameAndOffset.parseNameAndOffset(request));
}
public void clear() {
DEL_REQUESTS.clear();
ADD_REQUESTS.clear();
OPTIMIZE_REQUESTS.clear();
MOVE_REQUESTS.clear();
}
}

View File

@ -1,36 +0,0 @@
package com.rusefi.misc;
/**
* @author Andrey Belomutskiy
* 1/24/14
*/
public class NameAndOffset {
private final String name;
public final double x;
public final double y;
public NameAndOffset(String name, double x, double y) {
this.name = name;
this.x = x;
this.y = y;
}
static NameAndOffset parseNameAndOffset(String request) {
String[] tokens = request.split(" ");
NameAndOffset result;
if (tokens.length == 1) {
result = new NameAndOffset(tokens[0], 0, 0);
} else if (tokens.length == 3) {
double x = Double.parseDouble(tokens[1]);
double y = Double.parseDouble(tokens[2]);
result = new NameAndOffset(tokens[0], x, y);
} else {
throw new IllegalArgumentException("Invalid: " + request);
}
return result;
}
public String getName() {
return name;
}
}

View File

@ -1,138 +0,0 @@
package com.rusefi.misc;
import com.rusefi.pcb.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* @author Andrey Belomutskiy
* 1/21/14
*/
public class RemoveUnneededTraces {
private final static Set<String> alreadyRemoved = new HashSet<String>();
public static void main(String[] args) throws IOException {
if (args.length != 2) {
System.out.println("two parameters expected: INPUT_FILE OUTPUT_FILE");
return;
}
String input = args[0];
String output = args[1];
optimize(input, output);
}
public static void optimize(String input, String output) throws IOException {
PcbNode destNode = PcbNode.readFromFile(input);
while (removeUnusedSegments(destNode) || removeUnusedVias(destNode)) {
System.out.println("Still removing...");
}
destNode.write(output);
}
private static boolean removeUnusedVias(PcbNode destNode) {
List<ViaNode> unused = findUnusedVias(destNode);
for (ViaNode via : unused) {
System.out.println("Removing via: " + via);
boolean removed = destNode.removeChild(via);
if (!removed)
throw new IllegalStateException("not removed: " + removed);
}
return !unused.isEmpty();
}
private static List<ViaNode> findUnusedVias(PcbNode destNode) {
List<ViaNode> result = new ArrayList<ViaNode>();
List<PcbNode> stuff = destNode.iterate("segment");
// stuff.addAll(destNode.iterate("segment"));
for (PcbNode n : destNode.iterate("via")) {
ViaNode via = (ViaNode) n;
int count = 0;
for (PcbNode segment : stuff)
if (segment.isConnected(via.location))
count++;
if (via.netId == NetNode.GND_NET_ID) {
if (count == 0)
result.add(via);
} else {
if (count < 2)
result.add(via);
}
}
return result;
}
private static boolean removeUnusedSegments(PcbNode destNode) {
List<PcbNode> stuff = new ArrayList<PcbNode>(destNode.iterate("module"));
stuff.addAll(destNode.iterate("via"));
Object o = destNode.iterate("segment");
List<SegmentNode> segments = (List<SegmentNode>) o;
System.out.println(segments.size() + " segment(s)");
List<SegmentNode> unused = findUnusedSegments(segments, stuff);
for (SegmentNode segment : unused) {
boolean removed = destNode.removeChild(segment);
if (!removed)
throw new IllegalStateException();
String netName = segment.net.id;
if (!alreadyRemoved.contains(netName)) {
alreadyRemoved.add(netName);
System.out.println("Unused segment in network " + netName + ": " + segment);
}
}
return !unused.isEmpty();
}
private static List<SegmentNode> findUnusedSegments(List<SegmentNode> segments, List<PcbNode> modules) {
List<SegmentNode> unused = new ArrayList<SegmentNode>();
for (SegmentNode segment : segments) {
if (isUnused(segments, segment, modules)) {
// System.out.println("Unused on " + segment.net.id + ": " + segment);
unused.add(segment);
}
}
return unused;
}
public static boolean isUnused(List<SegmentNode> segments, SegmentNode segment, List<PcbNode> modules) {
PointNode start = segment.start;
PointNode end = segment.end;
if (isConnected(start, segments, segment) == null && isConnected(start, modules, null) == null) {
System.out.println("Not connected start: " + segment);
return true;
}
PcbNode endModule = isConnected(end, modules, null);
if (isConnected(end, segments, segment) == null && endModule == null) {
System.out.println("Not connected end: " + segment);
return true;
}
return false;
}
private static PcbNode isConnected(PointNode point, List<? extends PcbNode> elements, SegmentNode parent) {
for (PcbNode segmentNode : elements) {
if (segmentNode == parent)
continue;
if (segmentNode.isConnected(point))
return segmentNode;
}
return null;
}
}

View File

@ -1,23 +0,0 @@
package com.rusefi.misc;
/**
* @author Andrey Belomutskiy
* 1/24/14
*/
public class TwoFileRequest {
public final String input;
public final String output;
public TwoFileRequest(String input, String output) {
this.input = input;
this.output = output;
}
static TwoFileRequest parseTwoFile(String request, int lineIndex) {
String[] tokens = request.split(" ");
if (tokens.length != 2)
throw new IllegalArgumentException("Unexpected token count in [" + request + "] @" + lineIndex);
return new TwoFileRequest(tokens[0], tokens[1]);
}
}

View File

@ -1,13 +0,0 @@
package com.rusefi.pcb;
import java.util.List;
/**
* (c) Andrey Belomutskiy
* 5/30/2014
*/
public class AddNetNode extends PcbNode {
public AddNetNode(String nodeName, int i, List<Object> children) {
super(nodeName, i, children);
}
}

View File

@ -1,22 +0,0 @@
package com.rusefi.pcb;
import java.util.List;
/**
* (c) Andrey Belomutskiy
* 1/21/14.
*/
public class CirclePadNode extends PadNode {
public CirclePadNode(String nodeName, int i, List<Object> children) {
super(nodeName, i, children);
}
@Override
public String toString() {
return "CirclePadNode{" +
"at=" + at +
", size=" + size +
'}';
}
}

View File

@ -1,15 +0,0 @@
package com.rusefi.pcb;
import java.util.List;
/**
* @author Andrey Belomutskiy
* 2/7/14.
*/
public class GrLineNode extends PcbNode {
public final LayerNode layerNode;
public GrLineNode(String nodeName, int i, List<Object> children) {
super(nodeName, i, children);
layerNode = (LayerNode) find("layer");
}
}

View File

@ -1,20 +0,0 @@
package com.rusefi.pcb;
import java.util.List;
/**
* @author Andrey Belomutskiy
* 2/7/14.
*/
public class LayerNode extends PcbNode {
public final String name;
public LayerNode(String nodeName, int closingIndex, List<Object> children) {
super(nodeName, closingIndex, children);
name = (String) children.get(0);
}
boolean isSikscreenLayer() {
return name.equals("B.SilkS") || name.equals("F.SilkS");
}
}

View File

@ -1,45 +0,0 @@
package com.rusefi.pcb;
import java.util.List;
/**
* @author Andrey Belomutskiy
* 1/21/14
*/
public class ModuleNode extends PcbNode {
final List<PadNode> pads;
public final PointNode at;
private final String reference;
public ModuleNode(String nodeName, int i, List<Object> children) {
super(nodeName, i, children);
Object o = iterate("pad");
pads = (List<PadNode>) o;
at = (PointNode) find("at");
reference = iterate("fp_text").get(0).getChild(1);
}
public String getReference() {
return reference;
}
@Override
public String toString() {
return "ModuleNode{" +
"reference=" + reference +
", pads.size=" + pads.size() +
'}';
}
@Override
public boolean isConnected(PointNode point) {
PointNode offsetPoint = at.translate(point);
for (PadNode pad : pads) {
if (pad.isConnected(offsetPoint))
return true;
}
return false;
}
}

View File

@ -1,31 +0,0 @@
package com.rusefi.pcb;
import java.util.List;
/**
* @author Andrey Belomutskiy
* 1/21/14
*/
public class NetNode extends PcbNode {
public final String id;
final String name;
public static int GND_NET_ID;
public NetNode(String nodeName, int i, List<Object> children) {
super(nodeName, i, children);
id = getChild(0);
name = children.size() > 1 ? getChild(1) : null;
if (name != null)
System.out.println("NetNode(" + name + " network: " + id + ")");
if ("GND".equalsIgnoreCase(name))
GND_NET_ID = Integer.parseInt(id);
}
@Override
public String toString() {
return "NetNode{" +
"id='" + id + '\'' +
'}';
}
}

View File

@ -1,44 +0,0 @@
package com.rusefi.pcb;
import java.util.List;
/**
* (c) Andrey Belomutskiy
* 1/21/14.
*/
public abstract class PadNode extends PcbNode {
protected final PointNode at;
protected final SizeNode size;
protected final String name;
public PadNode(String nodeName, int i, List<Object> children) {
super(nodeName, i, children);
name = (String) children.get(0);
at = (PointNode) find("at");
size = (SizeNode) find("size");
}
@Override
public boolean isConnected(PointNode point) {
return point.isConnected(at, size);
}
public static PcbNode parse(String nodeName, int i, List<Object> children) {
Object shape = children.get(2);
if ("rect".equals(shape))
return new RectPadNode(nodeName, i, children);
if ("circle".equals(shape))
return new CirclePadNode(nodeName, i, children);
if ("oval".equals(shape))
return new CirclePadNode(nodeName, i, children); // yes, let's treat oval as circle. good enough
throw new IllegalStateException("Unknown pad shape: " + shape.toString());
}
@Override
public String toString() {
return "PadNode{" +
"at=" + at +
", size=" + size +
'}';
}
}

View File

@ -1,260 +0,0 @@
package com.rusefi.pcb;
import com.rusefi.PcbCopyTool;
import com.rusefi.misc.NameAndOffset;
import com.rusefi.misc.ChangesModel;
import com.rusefi.misc.RemoveUnneededTraces;
import com.rusefi.misc.TwoFileRequest;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* (c) Andrey Belomutskiy
* 12/16/13.
*/
public class PcbMergeTool {
private static Networks networks = new Networks();
public static void main(String[] args) throws IOException {
if (args.length != 3) {
System.out.println("Three parameters expected: SOURCE_PCB_FILENAME DESTINATION_PCB_FILENAME CHANGES_LIST_FILENAME");
return;
}
String sourcePcb = args[0];
String destination = args[1];
String changes = args[2];
ChangesModel.readConfiguration(changes);
log("Running COPY commands");
for (TwoFileRequest or : ChangesModel.getInstance().COPY_REQUESTS)
PcbCopyTool.copy(or.input, or.output);
log("Running OPTIMIZE commands");
for (TwoFileRequest or : ChangesModel.getInstance().OPTIMIZE_REQUESTS)
RemoveUnneededTraces.optimize(or.input, or.output);
PcbNode destNode = PcbNode.readFromFile(sourcePcb);
for (PcbNode net : destNode.iterate("net")) {
String netName = net.getChild(1); // todo: nicer method?
if (!Networks.isLocalNetwork(netName))
networks.registerNetworkIfPcbSpecific(netName);
}
log("Running ADD commands");
for (NameAndOffset addRequest : ChangesModel.getInstance().ADD_REQUESTS) {
PcbNode node = PcbMoveTool.readAndMove(addRequest.getName(), addRequest.x, addRequest.y);
mergePcb(destNode, node);
}
log("Running MOVE commands");
for (NameAndOffset moveRequest : ChangesModel.getInstance().MOVE_REQUESTS) {
String moduleName = moveRequest.getName();
ModuleNode module = findModuleByName(destNode, moduleName);
if (module == null) {
log("Module not found: " + moduleName);
continue;
}
PointNode at = module.at;
at.setLocation(at.x + moveRequest.x, at.y + moveRequest.y);
}
removeNodes(destNode);
destNode.write(destination);
RemoveUnneededTraces.optimize(destination, destination);
}
private static ModuleNode findModuleByName(PcbNode destNode, String moduleName) {
for (PcbNode node : destNode.iterate("module")) {
ModuleNode mn = (ModuleNode) node;
if (moduleName.toLowerCase().equals(mn.getReference().toLowerCase()))
return mn;
}
return null;
}
private static void mergePcb(PcbNode destNode, PcbNode source) throws IOException {
/**
* original local net name > new net name in combined PCB
*/
Map<String, String> netNameMapping = new HashMap<>();
/**
* original local net ID (as string) > new net ID
*/
Map<String, Integer> netIdMapping = new HashMap<>();
for (PcbNode net : source.iterate("net")) {
String netId = net.getChild(0);
String netName = net.getChild(1); // todo: nicer method?
String newName = networks.registerNetworkIfPcbSpecific(netName);
netNameMapping.put(netName, newName);
netIdMapping.put(netId, networks.getId(newName));
}
List<PcbNode> zones = source.iterate("zone");
log("Processing " + zones.size() + " zone(s)");
for (PcbNode z : zones) {
ZoneNode zone = (ZoneNode) z;
if (zone.getLayerNode().isSikscreenLayer())
destNode.addChild(zone);
}
List<PcbNode> arcs = source.iterate("gr_arc");
log("Processing " + arcs.size() + " arc(s)");
for (PcbNode arc : arcs)
destNode.addChild(arc);
List<PcbNode> lines = source.iterate("gr_line");
log("Processing " + lines.size() + " line(s)");
for (PcbNode l : lines) {
GrLineNode line = (GrLineNode) l;
if (line.layerNode.isSikscreenLayer())
destNode.addChild(line);
}
List<PcbNode> labels = source.iterate("gr_text");
log("Processing " + labels.size() + " label(s)");
for (PcbNode label : labels) {
destNode.addChild(label);
}
List<PcbNode> modules = source.iterate("module");
log("Processing " + modules.size() + " module(s)");
for (PcbNode module : modules) {
for (PcbNode pad : module.iterate("pad")) {
if (!pad.hasChild("net"))
continue;
fixNetId(netIdMapping, netNameMapping, pad);
// PcbNode net = pad.find("net");
// String localName = netNameMapping.get(net.getChild(1));
// net.setString(1, localName);
// net.setInt(0, networks.getId(localName));
}
destNode.addChild(module);
}
List<PcbNode> segments = source.iterate("segment");
log("Processing " + segments.size() + " segments");
for (PcbNode segment : segments) {
// if (!segment.hasChild("net"))
// continue;
fixNetId(netIdMapping, netNameMapping, segment);
destNode.addChild(segment);
}
List<PcbNode> vias = source.iterate("via");
log("Processing " + vias.size() + " vias");
for (PcbNode via : vias) {
fixNetId(netIdMapping, netNameMapping, via);
destNode.addChild(via);
}
// for (PcbNode zone : source.iterate("zone")) {
// fixNetId(netIdMapping, zone);
// destNode.addChild(zone);
// }
}
public static void removeNodes(PcbNode source) {
for (PcbNode module : source.iterate("module")) {
if (shouldRemove((ModuleNode) module))
source.removeChild(module);
}
}
private static boolean shouldRemove(ModuleNode module) {
for (PcbNode fp_text : module.iterate("fp_text")) {
if ("reference".equals(fp_text.getChild(0))) {
String name = fp_text.getChild(1);
if (ChangesModel.getInstance().DEL_REQUESTS.contains(name))
return true;
}
}
return false;
}
private static void fixNetId(Map<String, Integer> netIdMapping, Map<String, String> netNameMapping, PcbNode node) {
NetNode net = (NetNode) node.find("net");
String originalId = net.id;
Integer currentNetId = netIdMapping.get(originalId);
String globalName = networks.nameById.get(currentNetId);
// String newName = netNameMapping.get(originalName);
// if (newName == null)
// throw new NullPointerException("?");
if (ChangesModel.getInstance().NET_MERGE_REQUESTS.containsKey(globalName)) {
String newName = ChangesModel.getInstance().NET_MERGE_REQUESTS.get(globalName);
log("Will merge " + globalName + " into " + newName + ". ID was " + currentNetId);
currentNetId = networks.networks.get(newName);
if (currentNetId == null)
throw new NullPointerException("Cannot find net: " + newName);
log("New ID: " + currentNetId);
globalName = newName;
}
net.setInt(0, currentNetId);
if (net.name != null)
net.setString(1, globalName);
}
private static class Networks {
/**
* Net name > Net Id
*/
private Map<String, Integer> networks = new HashMap<>();
private Map<Integer, String> nameById = new HashMap<>();
public String registerNetworkIfPcbSpecific(String name) {
if (isLocalNetwork(name)) {
String newName = "F-0000" + networks.size();
log("Board-specific net: " + name + " would be " + newName);
registerNet(newName);
int newId = networks.get(newName);
log(newName + " is " + newId);
return newName;
} else {
if (networks.containsKey(name)) {
log("Existing global net: " + name);
return name;
}
log("New global net: " + name);
registerNet(name);
return name;
}
}
private static boolean isLocalNetwork(String name) {
return name.startsWith("N-00");
}
private void registerNet(String name) {
networks.put(name, networks.size());
nameById.put(networks.get(name), name);
}
public int getId(String localName) {
Integer value = networks.get(localName);
if (value == null)
throw new NullPointerException("No id for " + localName);
return value;
}
}
public static void log(String s) {
System.out.println(s);
}
}

View File

@ -1,137 +0,0 @@
package com.rusefi.pcb;
import java.io.IOException;
import java.util.List;
/**
* (c) Andrey Belomutskiy
* 12/8/13
*/
public class PcbMoveTool {
public static void main(String[] args) throws IOException {
if (args.length != 4) {
System.out.println("Four parameters expected: SRC_FILENAME DST_FILENAME X Y");
return;
}
String srcFileName = args[0];
String dstFileName = args[1];
double x = Double.parseDouble(args[2]);
double y = Double.parseDouble(args[3]);
PcbNode node = readAndMove(srcFileName, x, y);
node.write(dstFileName);
}
public static PcbNode readAndMove(String fileName, double x, double y) throws IOException {
PcbNode node = PcbNode.readFromFile(fileName);
move(node, x, y);
return node;
}
public static void move(PcbNode pcbNode, double dx, double dy) {
System.out.println("Moving " + pcbNode + ": dx=" +dx + " dy=" + dy);
List<PcbNode> dimensions = pcbNode.iterate("dimension");
System.out.println("Moving " + dimensions.size() + " dimension");
for (PcbNode dimension : dimensions) {
moveAt(dx, dy, dimension.find("gr_text"));
movePts(dx, dy, dimension.find("feature1"));
movePts(dx, dy, dimension.find("feature2"));
movePts(dx, dy, dimension.find("crossbar"));
movePts(dx, dy, dimension.find("arrow1a"));
movePts(dx, dy, dimension.find("arrow1b"));
movePts(dx, dy, dimension.find("arrow2a"));
movePts(dx, dy, dimension.find("arrow2b"));
}
List<PcbNode> gr_lines = pcbNode.iterate("gr_line");
System.out.println("Moving " + gr_lines.size() + " gr_lines");
for (PcbNode gr_line : gr_lines)
moveStartEnd(dx, dy, gr_line);
List<PcbNode> gr_arcs = pcbNode.iterate("gr_arc");
System.out.println("Moving " + gr_arcs.size() + " gr_arcs");
for (PcbNode gr_arc : gr_arcs) {
PcbNode start = gr_arc.find("start");
moveCoordinatesInFirstChildren(dx, dy, start);
PcbNode end = gr_arc.find("end");
moveCoordinatesInFirstChildren(dx, dy, end);
}
List<PcbNode> gr_circles = pcbNode.iterate("gr_circle");
System.out.println("Moving " + gr_circles.size() + " gr_circles");
for (PcbNode gr_circle : gr_circles) {
PcbNode start = gr_circle.find("center");
moveCoordinatesInFirstChildren(dx, dy, start);
PcbNode end = gr_circle.find("end");
moveCoordinatesInFirstChildren(dx, dy, end);
}
List<PcbNode> gr_texts = pcbNode.iterate("gr_text");
System.out.println("Moving " + gr_texts.size() + " gr_texts");
for (PcbNode gr_text : gr_texts)
moveAt(dx, dy, gr_text);
List<PcbNode> zones = pcbNode.iterate("zone");
System.out.println("Moving " + zones.size() + " zones");
for (PcbNode zone : zones) {
List<PcbNode> filledPolygons = zone.iterate("filled_polygon");
for (PcbNode filledPolygon : filledPolygons)
movePts(dx, dy, filledPolygon);
List<PcbNode> polygons = zone.iterate("polygon");
for (PcbNode polygon : polygons)
movePts(dx, dy, polygon);
}
List<PcbNode> segments = pcbNode.iterate("segment");
System.out.println("Moving " + segments.size() + " segments");
for (PcbNode segment : segments)
moveStartEnd(dx, dy, segment);
List<PcbNode> vias = pcbNode.iterate("via");
System.out.println("Moving " + vias.size() + " vias");
for (PcbNode via : vias)
moveAt(dx, dy, via);
List<PcbNode> modules = pcbNode.iterate("module");
System.out.println("Moving " + modules.size() + " modules");
for (PcbNode module : modules)
moveAt(dx, dy, module);
}
public static void movePts(double dx, double dy, PcbNode polygon) {
PcbNode pts = polygon.find("pts");
for (PcbNode point : pts.nodes())
moveCoordinatesInFirstChildren(dx, dy, point);
}
public static void moveStartEnd(double dx, double dy, PcbNode segment) {
PcbNode start = segment.find("start");
moveCoordinatesInFirstChildren(dx, dy, start);
PcbNode end = segment.find("end");
moveCoordinatesInFirstChildren(dx, dy, end);
}
public static void moveAt(double dx, double dy, PcbNode module) {
PcbNode at = module.find("at");
moveCoordinatesInFirstChildren(dx, dy, at);
}
public static void moveCoordinatesInFirstChildren(double dx, double dy, PcbNode at) {
moveCoordinates(dx, dy, at, 0);
}
private static void moveCoordinates(double dx, double dy, PcbNode at, int index) {
double x = at.asDouble(index);
double y = at.asDouble(index + 1);
at.setDouble(index, x + dx);
at.setDouble(index + 1, y + dy);
}
}

View File

@ -1,247 +0,0 @@
package com.rusefi.pcb;
import com.rusefi.util.FileUtils;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* (c) Andrey Belomutskiy
* 12/8/13
*/
public class PcbNode {
public final String nodeName;
public final int closingIndex;
public final List<Object> children;
public PcbNode(String nodeName, int closingIndex, List<Object> children) {
this.nodeName = nodeName;
this.closingIndex = closingIndex;
this.children = children;
}
/**
* @see #write
*/
public static PcbNode readFromFile(String fileName) throws IOException {
String content = FileUtils.readFile(fileName);
PcbNode node = parse(content);
System.out.println("GND network: " + NetNode.GND_NET_ID);
return node;
}
@Override
public String toString() {
return "PcbNode{" +
nodeName +
", children=" + children.size() +
'}';
}
private static PcbNode parse(String s, int index, int depth) {
log("Reading node from " + index, depth);
if (s.charAt(index) != '(')
throw new IllegalStateException("opening bracket expected");
index++;
String nodeName = readToken(s, index, depth);
index += nodeName.length();
List<Object> children = new ArrayList<Object>();
while (true) {
while (isWhitespace(s.charAt(index)))
index++;
char c = s.charAt(index);
if (c == ')')
break;
if (s.charAt(index) == '(') {
PcbNode child = parse(s, index, depth + 1);
children.add(child);
index = child.closingIndex;
continue;
}
String child = readToken(s, index, depth);
children.add(child);
index += child.length();
}
if ("segment".equals(nodeName)) {
return new SegmentNode(nodeName, index + 1, children);
} else if ("pad".equals(nodeName)) {
return PadNode.parse(nodeName, index + 1, children);
} else if ("net".equals(nodeName)) {
return new NetNode(nodeName, index + 1, children);
} else if ("add_net".equals(nodeName)) {
return new AddNetNode(nodeName, index + 1, children);
} else if ("gr_line".equals(nodeName)) {
return new GrLineNode(nodeName, index + 1, children);
} else if ("layer".equals(nodeName)) {
return new LayerNode(nodeName, index + 1, children);
} else if ("module".equals(nodeName)) {
return new ModuleNode(nodeName, index + 1, children);
} else if ("size".equals(nodeName) || "width".equals(nodeName)) {
return new SizeNode(nodeName, index + 1, children);
} else if ("zone".equals(nodeName)) {
return new ZoneNode(nodeName, index + 1, children);
} else if ("via".equals(nodeName)) {
return new ViaNode(nodeName, index + 1, children);
} else if ("start".equals(nodeName) || "end".equals(nodeName) || "at".equals(nodeName)) {
return new PointNode(nodeName, index + 1, children);
}
return new PcbNode(nodeName, index + 1, children);
}
private static String readToken(String s, int index, int depth) {
log("Reading token from " + index, depth);
if (s.charAt(index) == '"') {
String result = s.substring(index, s.indexOf('"', index + 1) + 1);
log("Got quoted token: " + result, depth);
return result;
}
String result = "";
while (index < s.length()) {
char c = s.charAt(index);
if (c == ')' || isWhitespace(c))
break;
result += c;
index++;
}
if (result.length() == 0)
throw new IllegalStateException("Empty token");
log("Got token: " + result, depth);
return result;
}
private static void log(String s, int depth) {
// for (int i = 0; i < depth; i++)
// System.out.print(' ');
// System.out.println(s);
}
private static void log(String s) {
log(s, 0);
}
private static boolean isWhitespace(char c) {
return c == ' ' || c == '\r' || c == '\n';
}
public static PcbNode parse(String content) {
return parse(content, 0, 0);
}
public String pack() {
StringBuilder sb = new StringBuilder();
pack(sb, "");
return sb.toString();
}
private void pack(StringBuilder sb, String prefix) {
sb.append(prefix).append("(").append(nodeName);
for (Object child : children) {
if (child instanceof String) {
sb.append(" ").append(child);
continue;
}
PcbNode p = (PcbNode) child;
if (p == null)
throw new NullPointerException("Null child node");
sb.append("\r\n");
p.pack(sb, prefix + " ");
}
sb.append(")\r\n");
}
public void write(String fileName) throws IOException {
System.out.println("Writing to " + fileName);
String content = pack();
BufferedWriter bw = new BufferedWriter(new FileWriter(fileName));
bw.write(content);
bw.close();
}
public void setDouble(int i, double value) {
children.set(i, "" + value);
}
public double asDouble(int index) {
return Double.parseDouble((String) children.get(index));
}
public boolean hasChild(String key) {
return !iterate(key).isEmpty();
}
// @Nullable
public PcbNode findIfExists(String key) {
List<PcbNode> r = iterate(key);
if (r.isEmpty())
return null;
return find(key);
}
// @NotNull
public PcbNode find(String key) {
List<PcbNode> r = iterate(key);
if (r.size() != 1)
throw new IllegalStateException("More that one " + key + " in " + nodeName);
return r.get(0);
}
public List<PcbNode> nodes() {
List<PcbNode> result = new ArrayList<PcbNode>();
for (Object child : children) {
if (child instanceof String)
continue;
result.add((PcbNode) child);
}
return result;
}
public List<PcbNode> iterate(String key) {
List<PcbNode> result = new ArrayList<PcbNode>();
for (PcbNode p : nodes()) {
if (p.nodeName.equals(key))
result.add(p);
}
return result;
}
public void addChild(PcbNode node) {
children.add(node);
}
public List<Object> getChildren() {
return Collections.unmodifiableList(children);
}
public String getChild(int index) {
return (String) children.get(index);
}
public void setString(int index, String value) {
children.set(index, value);
}
public void setInt(int index, int value) {
children.set(index, "" + value);
}
public boolean removeChild(Object child) {
return children.remove(child);
}
public boolean isConnected(PointNode point) {
return false;
}
}

View File

@ -1,77 +0,0 @@
package com.rusefi.pcb;
import java.util.Collections;
import java.util.List;
/**
* @author Andrey Belomutskiy
* 1/21/14
*/
public class PointNode extends PcbNode {
public final double x;
public final double y;
public final double angle;
public PointNode(String nodeName, int i, List<Object> children) {
super(nodeName, i, children);
if (children.size() == 1) {
// xyz use-case
x = 0;
y = 0;
angle = 0;
return;
}
if (children.size() != 2 && children.size() != 3)
throw new IllegalStateException("Unexpected children count");
x = Double.parseDouble((String) children.get(0));
y = Double.parseDouble((String) children.get(1));
angle = children.size() == 2 ? 0 : Double.parseDouble((String) children.get(2));
}
public PointNode(double x, double y) {
this(x, y, 0);
}
public PointNode(double x, double y, double angle) {
super("", 0, Collections.emptyList());
this.x = x;
this.y = y;
this.angle = angle;
}
public boolean isConnected(PointNode at, SizeNode size) {
boolean isConnectedX = (x >= at.x - size.w / 2) && (x <= at.x + size.w / 2);
boolean isConnectedY = (y >= at.y - size.h / 2) && (y <= at.y + size.h / 2);
return isConnectedX && isConnectedY;
}
@Override
public String toString() {
return "PointNode{" +
"x=" + x +
", y=" + y +
", angle=" + angle +
'}';
}
// public boolean isSameLocation(PointNode point) {
// return x == point.x && y == point.y;
// }
public PointNode translate(PointNode at) {
double nx = at.x - x;
double ny = at.y - y;
double radian = angle / 180 * Math.PI;
double rx = Math.cos(radian) * nx - Math.sin(radian) * ny;
double ry = Math.sin(radian) * nx + Math.cos(radian) * ny;
return new PointNode(rx, ry);
}
public void setLocation(double x, double y) {
children.set(0, Double.toString(x));
children.set(1, Double.toString(y));
}
}

View File

@ -1,22 +0,0 @@
package com.rusefi.pcb;
import java.util.List;
/**
* (c) Andrey Belomutskiy
* 1/21/14.
*/
public class RectPadNode extends PadNode {
public RectPadNode(String nodeName, int i, List<Object> children) {
super(nodeName, i, children);
}
@Override
public String toString() {
return "RectPadNode{" +
"name=" + name +
", at=" + at +
", size=" + size +
'}';
}
}

View File

@ -1,35 +0,0 @@
package com.rusefi.pcb;
import java.util.List;
/**
* @author Andrey Belomutskiy
* 1/21/14
*/
public class SegmentNode extends PcbNode {
public final NetNode net;
public final PointNode start;
public final PointNode end;
private final SizeNode size;
public SegmentNode(String nodeName, int closingIndex, List<Object> children) {
super(nodeName, closingIndex, children);
net = (NetNode) find("net");
start = (PointNode) find("start");
end = (PointNode) find("end");
size = (SizeNode) find("width");
}
public boolean isConnected(PointNode point) {
return point.isConnected(start, size) || point.isConnected(end, size);
}
@Override
public String toString() {
return "SegmentNode{" +
"net=" + net +
", start=" + start +
", end=" + end +
'}';
}
}

View File

@ -1,33 +0,0 @@
package com.rusefi.pcb;
import java.util.List;
/**
* @author Andrey Belomutskiy
* 1/21/14
*/
public class SizeNode extends PcbNode {
public final double w;
public final double h;
public SizeNode(String nodeName, int i, List<Object> children) {
super(nodeName, i, children);
if (children.size() == 1) {
w = h = Double.parseDouble((String) children.get(0));
return;
}
if (children.size() != 2)
throw new IllegalStateException("Size: " + children.size());
w = Double.parseDouble((String) children.get(0));
h = Double.parseDouble((String) children.get(1));
}
@Override
public String toString() {
return "SizeNode{" +
"w=" + w +
", h=" + h +
'}';
}
}

View File

@ -1,32 +0,0 @@
package com.rusefi.pcb;
import java.util.List;
/**
* @author Andrey Belomutskiy
* 1/21/14
*/
public class ViaNode extends PcbNode {
public final PointNode location;
final SizeNode size;
public final int netId;
public ViaNode(String nodeName, int i, List<Object> children) {
super(nodeName, i, children);
location = (PointNode) find("at");
size = (SizeNode) find("size");
netId = Integer.parseInt(find("net").getChild(0));
}
@Override
public String toString() {
return "ViaNode{" +
"location=" + location +
'}';
}
@Override
public boolean isConnected(PointNode point) {
return point.isConnected(location, size);
}
}

View File

@ -1,20 +0,0 @@
package com.rusefi.pcb;
import java.util.List;
/**
* (c) Andrey Belomutskiy
* 2/11/14.
*/
public class ZoneNode extends PcbNode {
private final LayerNode layerNode;
public ZoneNode(String nodeName, int i, List<Object> children) {
super(nodeName, i, children);
layerNode = (LayerNode) find("layer");
}
public LayerNode getLayerNode() {
return layerNode;
}
}

View File

@ -1,40 +0,0 @@
package com.rusefi.pcb.test;
import com.rusefi.misc.NameAndOffset;
import com.rusefi.misc.ChangesModel;
import org.junit.Assert;
import org.junit.Test;
import java.util.Arrays;
import static junit.framework.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* @author Andrey Belomutskiy
* 1/24/14
*/
public class ChangesModelTest {
@Test
public void testConfigParser() {
ChangesModel model = ChangesModel.getInstance();
model.clear();
model.read(Arrays.asList("reMove c1", "add mmc_usb_1.kicad_pcb",
"adD mmc_usb_1.kicad_pcb 4 6",
"optimize mmc_usb_1.kicad_pcb out.x"));
assertEquals(1, model.DEL_REQUESTS.size());
assertTrue(model.DEL_REQUESTS.contains("C1"));
assertEquals(2, model.ADD_REQUESTS.size());
NameAndOffset ar = model.ADD_REQUESTS.get(1);
Assert.assertEquals(4.0, ar.x, 0);
Assert.assertEquals(6.0, ar.y, 0);
assertEquals(1, model.OPTIMIZE_REQUESTS.size());
}
}

View File

@ -1,271 +0,0 @@
package com.rusefi.pcb.test;
import com.rusefi.misc.RemoveUnneededTraces;
import com.rusefi.pcb.ModuleNode;
import com.rusefi.pcb.PcbNode;
import com.rusefi.pcb.SegmentNode;
import org.junit.Test;
import java.util.Arrays;
import java.util.Collections;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/**
* (c) Andrey Belomutskiy
* 12/8/13
*/
public class PcbNodeTest {
@Test
public void testParser() {
PcbNode n = PcbNode.parse("(version 3\r\n)");
assertEquals("version", n.nodeName);
assertEquals(1, n.getChildren().size());
assertEquals("(version 3)\r\n", n.pack());
n = PcbNode.parse("(host pcbnew \"(2013-07-07 BZR 4022)-stable\")");
assertEquals(2, n.getChildren().size());
assertEquals("pcbnew", n.getChildren().get(0));
assertEquals("\"(2013-07-07 BZR 4022)-stable\"", n.getChildren().get(1));
n = PcbNode.parse("(area 68.835001 116.9924 170.180001 180.5)");
assertEquals(4, n.getChildren().size());
n = PcbNode.parse("(kicad_pcb\n (version 3)\r\n (host pcbnew \"(2013-07-07 BZR 4022)-stable\")\n)");
assertEquals(2, n.getChildren().size());
assertEquals("(kicad_pcb\r\n" +
" (version 3)\r\n" +
"\r\n" +
" (host pcbnew \"(2013-07-07 BZR 4022)-stable\")\r\n" +
")\r\n", n.pack());
}
@Test
public void testParseModule() {
ModuleNode module = (ModuleNode) PcbNode.parse("(module SM0805 (layer F.Cu) (tedit 52BF06CE) (tstamp 52A5B5B5)\n" +
" (at 205.359 170.688 180)\n" +
" (path /52A59B3A)\n" +
" (attr smd)\n" +
" (fp_text reference R351 (at -0.127 0 270) (layer F.SilkS)\n" +
" (effects (font (size 0.50038 0.50038) (thickness 0.1016)))\n" +
" )\n" +
" (fp_text value 1M (at 0 -1.143 180) (layer F.SilkS) hide\n" +
" (effects (font (size 0.50038 0.50038) (thickness 0.10922)))\n" +
" )\n" +
" (fp_circle (center -1.651 0.762) (end -1.651 0.635) (layer F.SilkS) (width 0.09906))\n" +
" (fp_line (start -0.508 0.762) (end -1.524 0.762) (layer F.SilkS) (width 0.09906))\n" +
" (fp_line (start -1.524 0.762) (end -1.524 -0.762) (layer F.SilkS) (width 0.09906))\n" +
" (fp_line (start -1.524 -0.762) (end -0.508 -0.762) (layer F.SilkS) (width 0.09906))\n" +
" (fp_line (start 0.508 -0.762) (end 1.524 -0.762) (layer F.SilkS) (width 0.09906))\n" +
" (fp_line (start 1.524 -0.762) (end 1.524 0.762) (layer F.SilkS) (width 0.09906))\n" +
" (fp_line (start 1.524 0.762) (end 0.508 0.762) (layer F.SilkS) (width 0.09906))\n" +
" (pad 1 smd rect (at -0.9525 0 180) (size 0.889 1.397)\n" +
" (layers F.Cu F.Paste F.Mask)\n" +
" (net 18 N-000002)\n" +
" )\n" +
" (pad 2 smd rect (at 0.9525 0 180) (size 0.889 1.397)\n" +
" (layers F.Cu F.Paste F.Mask)\n" +
" (net 14 GND)\n" +
" )\n" +
" (model smd/chip_cms.wrl\n" +
" (at (xyz 0 0 0))\n" +
" (scale (xyz 0.1 0.1 0.1))\n" +
" (rotate (xyz 0 0 0))\n" +
" )\n" +
" )");
assertEquals("R351", module.getReference());
}
@Test
public void testConnected() {
ModuleNode p353 = (ModuleNode) PcbNode.parse("(module PIN_ARRAY_10X2 (layer F.Cu) (tedit 52BF05FA) (tstamp 52B9B18D)\n" +
" (at 179.07 166.37 270)\n" +
" (path /52B479E1)\n" +
" (fp_text reference P353 (at 2.667 -3.048 360) (layer F.SilkS)\n" +
" (effects (font (size 0.50038 0.50038) (thickness 0.1016)))\n" +
" )\n" +
" (fp_text value CONN_10X2 (at 0.254 4.318 270) (layer F.SilkS) hide\n" +
" (effects (font (size 1.016 1.016) (thickness 0.2032)))\n" +
" )\n" +
" (fp_line (start 12.49934 2.49936) (end 12.49934 -2.49936) (layer F.SilkS) (width 0.09906))\n" +
" (fp_line (start 12.49934 -2.49936) (end -12.7508 -2.49936) (layer F.SilkS) (width 0.09906))\n" +
" (fp_line (start -12.7508 -2.49936) (end -12.7508 2.49936) (layer F.SilkS) (width 0.09906))\n" +
" (fp_line (start -12.7508 2.49936) (end 12.49934 2.49936) (layer F.SilkS) (width 0.09906))\n" +
" (pad 1 thru_hole rect (at -11.47064 1.27 270) (size 1.524 1.524) (drill 0.8128)\n" +
" (layers *.Cu *.Mask F.SilkS)\n" +
" (net 3 /CAN_TX)\n" +
" )\n" +
" (pad 2 thru_hole circle (at -11.47064 -1.27 270) (size 1.524 1.524) (drill 1.016)\n" +
" (layers *.Cu *.Mask F.SilkS)\n" +
" (net 5 /CS2)\n" +
" )\n" +
" (pad 3 thru_hole circle (at -8.93064 1.27 270) (size 1.524 1.524) (drill 1.016)\n" +
" (layers *.Cu *.Mask F.SilkS)\n" +
" (net 9 /SPI_MISO)\n" +
" )\n" +
" (pad 4 thru_hole circle (at -8.93064 -1.27 270) (size 1.524 1.524) (drill 1.016)\n" +
" (layers *.Cu *.Mask F.SilkS)\n" +
" (net 10 /SPI_MOSI)\n" +
" )\n" +
" (pad 5 thru_hole circle (at -6.39064 1.27 270) (size 1.524 1.524) (drill 1.016)\n" +
" (layers *.Cu *.Mask F.SilkS)\n" +
" (net 4 /CS1)\n" +
" )\n" +
" (pad 6 thru_hole circle (at -6.39064 -1.27 270) (size 1.524 1.524) (drill 1.016)\n" +
" (layers *.Cu *.Mask F.SilkS)\n" +
" (net 11 /SPI_SCK)\n" +
" )\n" +
" (pad 7 thru_hole circle (at -3.85064 1.27 270) (size 1.524 1.524) (drill 1.016)\n" +
" (layers *.Cu *.Mask F.SilkS)\n" +
" (net 6 /CS3)\n" +
" )\n" +
" (pad 8 thru_hole circle (at -3.85064 -1.27 270) (size 1.524 1.524) (drill 1.016)\n" +
" (layers *.Cu *.Mask F.SilkS)\n" +
" )\n" +
" (pad 9 thru_hole circle (at -1.31064 1.27 270) (size 1.524 1.524) (drill 1.016)\n" +
" (layers *.Cu *.Mask F.SilkS)\n" +
" (net 7 /CS4)\n" +
" )\n" +
" (pad 10 thru_hole circle (at -1.31064 -1.27 270) (size 1.524 1.524) (drill 1.016)\n" +
" (layers *.Cu *.Mask F.SilkS)\n" +
" (net 8 /CS_SD_MODULE)\n" +
" )\n" +
" (pad 11 thru_hole circle (at 1.22936 1.27 270) (size 1.524 1.524) (drill 1.016)\n" +
" (layers *.Cu *.Mask F.SilkS)\n" +
" )\n" +
" (pad 12 thru_hole circle (at 1.22936 -1.27 270) (size 1.524 1.524) (drill 1.016)\n" +
" (layers *.Cu *.Mask F.SilkS)\n" +
" )\n" +
" (pad 13 thru_hole circle (at 3.76936 1.27 270) (size 1.524 1.524) (drill 1.016)\n" +
" (layers *.Cu *.Mask F.SilkS)\n" +
" )\n" +
" (pad 14 thru_hole circle (at 3.76936 -1.27 270) (size 1.524 1.524) (drill 1.016)\n" +
" (layers *.Cu *.Mask F.SilkS)\n" +
" )\n" +
" (pad 15 thru_hole circle (at 6.30936 1.27 270) (size 1.524 1.524) (drill 1.016)\n" +
" (layers *.Cu *.Mask F.SilkS)\n" +
" (net 13 /USART_TX)\n" +
" )\n" +
" (pad 16 thru_hole circle (at 6.30936 -1.27 270) (size 1.524 1.524) (drill 1.016)\n" +
" (layers *.Cu *.Mask F.SilkS)\n" +
" (net 12 /USART_RX)\n" +
" )\n" +
" (pad 17 thru_hole circle (at 8.84936 1.27 270) (size 1.524 1.524) (drill 1.016)\n" +
" (layers *.Cu *.Mask F.SilkS)\n" +
" )\n" +
" (pad 18 thru_hole circle (at 8.84936 -1.27 270) (size 1.524 1.524) (drill 1.016)\n" +
" (layers *.Cu *.Mask F.SilkS)\n" +
" )\n" +
" (pad 19 thru_hole circle (at 11.38936 1.27 270) (size 1.524 1.524) (drill 1.016)\n" +
" (layers *.Cu *.Mask F.SilkS)\n" +
" )\n" +
" (pad 20 thru_hole circle (at 11.38936 -1.27 270) (size 1.524 1.524) (drill 1.016)\n" +
" (layers *.Cu *.Mask F.SilkS)\n" +
" )\n" +
" (model lib/3d/M_header_10x2.wrl\n" +
" (at (xyz 0 0 0))\n" +
" (scale (xyz 1 1 1))\n" +
" (rotate (xyz -90 0 0))\n" +
" )\n" +
" )\n");
SegmentNode segment = (SegmentNode) PcbNode.parse("(segment (start 221.32036 156.21) (end 222.631 154.89936) (width 0.254) (layer B.Cu) (net 5) (tstamp 52BE7B1B))");
assertFalse(p353.isConnected(segment.end));
assertFalse(p353.isConnected(segment.start));
}
@Test
public void testSegmentConnected() {
SegmentNode s1 = (SegmentNode) PcbNode.parse("(segment (start 219.075 162.941) (end 219.075 163.322) (width 0.254) (layer F.Cu) (net 7) (tstamp 52BC5D9B))");
SegmentNode s0 = (SegmentNode) PcbNode.parse("(segment (start 216.662 161.544) (end 217.678 161.544) (width 0.254) (layer B.Cu) (net 7) (tstamp 52BC5D95))");
SegmentNode s2 = (SegmentNode) PcbNode.parse("(segment (start 219.075 162.941) (end 219.075 163.322) (width 0.254) (layer F.Cu) (net 7) (tstamp 52BC5D9B))");
assertFalse(RemoveUnneededTraces.isUnused(Arrays.asList(s0, s2), s1, Collections.<PcbNode>emptyList()));
}
@Test
public void testSegmentConnected2() {
SegmentNode s = (SegmentNode) PcbNode.parse("(segment (start 213.106 171.069) (end 213.106 166.3065) (width 0.254) (layer F.Cu) (net 22))");
ModuleNode mn = (ModuleNode) PcbNode.parse("(module MINI-USB-5P-3400020P1 (layer F.Cu) (tedit 52C0C373) (tstamp 52BAC27E)\n" +
" (at 213.106 175.26)\n" +
" (descr OPL)\n" +
" (tags \"USB MINI 5 SMD-1\")\n" +
" (path /52C034E1)\n" +
" (attr smd)\n" +
" (fp_text reference J351 (at 0 -1.905) (layer F.SilkS)\n" +
" (effects (font (size 0.50038 0.50038) (thickness 0.1016)))\n" +
" )\n" +
" (fp_text value MINI-USB-5P-3400020P1 (at 0.762 -0.254) (layer F.SilkS) hide\n" +
" (effects (font (size 0.4318 0.4318) (thickness 0.0508)))\n" +
" )\n" +
" (fp_line (start 3.81 4.572) (end 3.81 3.103) (layer F.SilkS) (width 0.127))\n" +
" (fp_line (start -3.81 4.572) (end -3.81 3.103) (layer F.SilkS) (width 0.127))\n" +
" (fp_line (start 2.032 -4.572) (end 3.302 -4.572) (layer F.SilkS) (width 0.127))\n" +
" (fp_line (start 3.81 -2.297) (end 3.81 0.103) (layer F.SilkS) (width 0.127))\n" +
" (fp_line (start -3.81 4.572) (end 3.81 4.572) (layer F.SilkS) (width 0.127))\n" +
" (fp_line (start -3.81 -2.297) (end -3.81 0.103) (layer F.SilkS) (width 0.127))\n" +
" (fp_line (start -3.3 -4.572) (end -2.1 -4.572) (layer F.SilkS) (width 0.127))\n" +
" (pad 5 smd rect (at -1.6 -4.191) (size 0.508 2.54)\n" +
" (layers F.Cu F.Paste F.Mask)\n" +
" (net 14 GND)\n" +
" )\n" +
" (pad 4 smd rect (at -0.8 -4.191) (size 0.508 2.54)\n" +
" (layers F.Cu F.Paste F.Mask)\n" +
" )\n" +
" (pad 3 smd rect (at 0 -4.191) (size 0.508 2.54)\n" +
" (layers F.Cu F.Paste F.Mask)\n" +
" (net 22 N-0000056)\n" +
" )\n" +
" (pad 2 smd rect (at 0.8 -4.191) (size 0.508 2.54)\n" +
" (layers F.Cu F.Paste F.Mask)\n" +
" (net 19 N-000003)\n" +
" )\n" +
" (pad 1 smd rect (at 1.6 -4.191) (size 0.508 2.54)\n" +
" (layers F.Cu F.Paste F.Mask)\n" +
" (net 15 N-000001)\n" +
" )\n" +
" (pad 6 smd rect (at -4.5 1.603 90) (size 2.794 2)\n" +
" (layers F.Cu F.Paste F.Mask)\n" +
" (net 18 N-000002)\n" +
" )\n" +
" (pad 6 smd rect (at 4.5 1.603 90) (size 2.794 2)\n" +
" (layers F.Cu F.Paste F.Mask)\n" +
" (net 18 N-000002)\n" +
" )\n" +
" (pad 6 smd rect (at -4.5 -3.897 90) (size 2.794 2)\n" +
" (layers F.Cu F.Paste F.Mask)\n" +
" (net 18 N-000002)\n" +
" )\n" +
" (pad 6 smd rect (at 4.5 -3.897 90) (size 2.794 2)\n" +
" (layers F.Cu F.Paste F.Mask)\n" +
" (net 18 N-000002)\n" +
" )\n" +
" (pad \"\" np_thru_hole circle (at -2.159 -1.397 90) (size 1.016 1.016) (drill 0.762)\n" +
" (layers *.Mask F.SilkS)\n" +
" )\n" +
" (pad \"\" np_thru_hole circle (at 2.159 -1.397 90) (size 1.016 1.016) (drill 0.762)\n" +
" (layers *.Mask F.SilkS)\n" +
" )\n" +
" (model lib/3d/usb-2.wrl\n" +
" (at (xyz 0 0 0))\n" +
" (scale (xyz 1 1 1))\n" +
" (rotate (xyz -90 0 -90))\n" +
" )\n" +
" )");
assertTrue(mn.isConnected(s.start));
}
}

View File

@ -1,31 +0,0 @@
package com.rusefi.pcb.test;
import com.rusefi.pcb.PointNode;
import junit.framework.Assert;
import org.junit.Test;
/**
* (c) Andrey Belomutskiy
* 5/28/2014
*/
public class PointNodeTest {
private static final double EPS = 0.0000001;
@Test
public void testTurn() {
PointNode x10y50 = new PointNode(10, 50);
PointNode angle270 = new PointNode(0, 0, 270);
Assert.assertEquals("270 x", angle270.translate(x10y50).x, 50.0, EPS);
Assert.assertEquals(angle270.translate(x10y50).y, -10.0, EPS);
PointNode angle180 = new PointNode(0, 0, 180);
Assert.assertEquals("180 x", angle180.translate(x10y50).x, -10.0, EPS);
Assert.assertEquals("180 y", angle180.translate(x10y50).y, -50.0, EPS);
PointNode angle90 = new PointNode(0, 0, 90);
Assert.assertEquals(angle90.translate(x10y50).x, -50.0, EPS);
Assert.assertEquals(angle90.translate(x10y50).y, 10.0, EPS);
}
}

View File

@ -1,59 +0,0 @@
package com.rusefi.util;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* Generic file utilities
* <p/>
* 12/9/13
* (c) Andrey Belomutskiy
*/
public class FileUtils {
private FileUtils() {
}
/**
* @param fileName
* @return Full content of the file as one String
* @throws IOException
*/
public static String readFile(String fileName) throws IOException {
checkExistence(fileName);
System.out.println("Reading " + fileName);
StringBuilder sb = new StringBuilder();
String line;
BufferedReader br = new BufferedReader(new FileReader(fileName));
while (((line = br.readLine()) != null))
sb.append(line).append("\r\n");
br.close();
return sb.toString();
}
private static void checkExistence(String fileName) {
if (!new File(fileName).isFile()) {
System.err.println("File not found: " + fileName);
System.exit(-1);
}
}
public static List<String> readFileToList(String fileName) throws IOException {
checkExistence(fileName);
List<String> result = new ArrayList<String>();
System.out.println("Reading " + fileName);
String line;
BufferedReader br = new BufferedReader(new FileReader(fileName));
while (((line = br.readLine()) != null))
result.add(line);
return result;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
Here we have some tiny dev utilities - average rusEfi user would not need to use any of these!
Here we have some tiny dev utilities - average rusEFI user would not need to use any of these!
gcc_map_reader reads the .map file produced by GCC and prints some details on what is RAM used for
@ -7,4 +7,6 @@ ts2c reads a piece of TunerStudio map and produces a matching C language piece o
version2header creates a C language header containting current SVN version
enum2string
enum2string
KiCad tools have moved to https://github.com/rusefi/KiCad-utils

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB