Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 1577 → Rev 1578

/dongfang_FC_rewrite_tool/configsets/ADXRS610/config.xml
2,7 → 2,7
<parameter name="bitConfig">
<bit name="CFG_SIMPLE_HEIGHT_CONTROL" value="1" />
<bit name="CFG_SIMPLE_HC_HOLD_SWITCH" value="1" />
<bit name="CFG_HEADING_HOLD" value="0" />
<bit name="CFG_HEADING_HOLD" value="1" />
<bit name="CFG_COMPASS_ENABLED" value="1" />
<bit name="CFG_UNUSED" value="0" />
<bit name="CFG_GPS_ENABLED" value="1" />
28,9 → 28,10
<parameter name="gyroDFilterConstant" value="1" />
<parameter name="accFilterConstant" value="15" />
 
<parameter name="maxAccVector" value="100" />
<parameter name="maxControlActivity" value="80" />
<parameter name="zerothOrderCorrection" value="1" />
<parameter name="zerothOrderCorrection" value="10" />
<parameter name="zerothOrderCorrectionAccTolerance" value="60" />
<parameter name="zerothOrderCorrectionControlTolerance" value="60" />
 
<parameter name="driftCompDivider" value="2" />
<parameter name="driftCompLimit" value="0" />
 
132,10 → 133,10
</parameter>
<parameter name="output1Timing" value="14" />
<parameter name="outputDebugMask">
<bit name="DEBUG_MAINLOOP_TIMER" value="0" />
<bit name="DEBUG_MAINLOOP_TIMER" value="1" />
<bit name="DEBUG_HEIGHT_DIFF" value="0" />
<bit name="DEBUG_HOVERTHROTTLE" value="0" />
<bit name="DEBUG_ACC0THORDER" value="1" />
<bit name="DEBUG_ACC0THORDER" value="0" />
<bit name="DEBUG_COMPASS" value="0" />
<bit name="DEBUG_PRESSURERANGE" value="0" />
<bit name="DEBUG_CLIP" value="0" />
153,12 → 154,12
</parameter>
 
<parameter name="naviMode" value="var0" />
<parameter name="naviStickThreshold" value="2" />
<parameter name="naviStickThreshold" value="5" />
<parameter name="naviStickLimit" value="50" />
<parameter name="GPSMinimumSatellites" value="6" />
<parameter name="naviP" value="50" />
<parameter name="naviI" value="0" />
<parameter name="naviD" value="50" />
<parameter name="naviI" value="1" />
<parameter name="naviD" value="0" />
 
<parameter name="userparam0" value="0" />
<parameter name="userparam1" value="0" />
/dongfang_FC_rewrite_tool/configsets/templates/v3.xml
1,4 → 1,4
<parametertemplate eepromVersion="3" length="78">
<parametertemplate eepromVersion="3" length="80">
<section name="config" title="Configuration">
<parameter name="bitConfig" type="bitset">
<bit name="CFG_SIMPLE_HEIGHT_CONTROL" />
31,14 → 31,14
<parameter name="gyroDFilterConstant" />
<parameter name="accFilterConstant" />
 
<parameter name="maxAccVector" />
<parameter name="maxControlActivity" />
<parameter name="zerothOrderCorrection" />
<parameter name="zerothOrderCorrectionAccTolerance" />
<parameter name="zerothOrderCorrectionControlTolerance" />
<parameter name="driftCompDivider" />
<parameter name="driftCompLimit" />
 
<parameter name="levelCorrectionPitch" type="dynamic"/>
<parameter name="levelCorrectionRoll" type="dynamic"/>
<parameter name="levelCorrectionPitch" staticCodeName="levelCorrection[0]" dynamicCodeName="levelCorrection[0]" type="dynamic"/>
<parameter name="levelCorrectionRoll" staticCodeName="levelCorrection[1]" dynamicCodeName="levelCorrection[1]" type="dynamic"/>
</section>
 
<section name="control" title="Control">
63,8 → 63,10
<parameter name="IFactor" />
<parameter name="yawIFactor" />
 
<parameter name="compassMode" type="dynamic" />
<parameter name="compassYawCorrection" />
<parameter name="compassFixedHeading" type="dynamic"/>
<parameter name="compassBendingReturnSpeed" />
<parameter name="compassP" />
 
<parameter name="batteryVoltageWarning" />
<parameter name="emergencyThrottle" />
87,7 → 89,7
<section name="servos">
<parameter name="servoCount" />
<parameter name="servoManualMaxSpeed" />
<parameter name="pitchServoControl" type="dynamic"/>
<parameter name="pitchServoControl" staticCodeName="servoConfigurations[0].manualControl" dynamicCodeName="servoManualControl[0]" type="dynamic"/>
<parameter name="pitchServoStabilization" />
<parameter name="pitchServoMinValue" />
<parameter name="pitchServoMaxValue" />
101,7 → 103,7
<bit name="Unused" />
<bit name="Unused" />
</parameter>
<parameter name="rollServoControl" type="dynamic"/>
<parameter name="rollServoControl" staticCodeName="servoConfigurations[1].manualControl" dynamicCodeName="servoManualControl[1]" type="dynamic"/>
<parameter name="rollServoStabilization" />
<parameter name="rollServoMinValue" />
<parameter name="rollServoMaxValue" />
128,7 → 130,7
<bit name="t6" />
<bit name="t7" />
</parameter>
<parameter name="output0Timing" type="dynamic"/>
<parameter name="output0Timing" staticCodeName="outputFlash[0].timing" dynamicCodeName="output0Timing" type="dynamic"/>
<parameter name="output1BitMask" type="bitset">
<bit name="t0" />
<bit name="t1" />
139,7 → 141,7
<bit name="t6" />
<bit name="t7" />
</parameter>
<parameter name="output1Timing" type="dynamic"/>
<parameter name="output1Timing" staticCodeName="outputFlash[1].timing" dynamicCodeName="output1Timing" type="dynamic"/>
<parameter name="outputDebugMask" type="bitset">
<bit name="DEBUG_MAINLOOP_TIMER" />
<bit name="DEBUG_HEIGHT_DIFF" />
/dongfang_FC_rewrite_tool/src/dongfang/mkt/configuration/ConfigSet.java
22,7 → 22,7
public static final int NUMBER_OF_VARIABLES = 8;
String name;
int eepromVersion;
 
List<Section> declaredSections = new ArrayList<Section>();
List<ConfigEntry> entries = new ArrayList<ConfigEntry>();
 
29,7 → 29,7
public static class Section {
String name, title;
List<ConfigEntry> entries = new ArrayList<ConfigEntry>();
 
public Section(String name, String title) {
this.name = name;
this.title = title;
38,15 → 38,20
public void addConfigEntry(ConfigEntry e) {
this.entries.add(e);
}
 
public List<ConfigEntry> getEntries() {
return entries;
}
public String getName() { return name; }
public String getTitle() { return title; }
 
public String getName() {
return name;
}
 
public String getTitle() {
return title;
}
}
 
public static abstract class ConfigEntry {
String name;
 
71,13 → 76,11
}
}
 
public static class ByteEntry extends ConfigEntry {
ByteEntry(String name, boolean isDynamic) {
public static class StaticByteEntry extends ConfigEntry {
StaticByteEntry(String name) {
super(name);
this.isDynamic = isDynamic;
}
 
boolean isDynamic;
int value;
 
int getByteCount() {
99,10 → 102,58
 
void toXML(StringBuilder result) {
String s_value;
int numberOfHighestVariable = 255;
int numberOfLowestVariable = numberOfHighestVariable
- NUMBER_OF_VARIABLES;
if (isDynamic && value >= numberOfLowestVariable) {
s_value = Integer.toString(value);
result.append(" <parameter name=\"" + name + "\" value=\""
+ s_value + "\"/>\n");
}
}
 
public static class DynamicByteEntry extends StaticByteEntry {
int minValue = 0;
int maxValue = 255;
String staticCodeName;
String dynamicCodeName;
DynamicByteEntry(String name) {
super(name);
}
 
int getMinValue() {
return minValue;
}
 
int getMaxValue() {
return maxValue;
}
 
void setMinValue(int minValue) {
this.minValue = minValue;
}
 
void setMaxValue(int maxValue) {
this.maxValue = maxValue;
}
 
String getStaticCodeName() {
return staticCodeName;
}
 
String getDynamicCodeName() {
return dynamicCodeName;
}
 
void setStaticCodeName(String staticCodeName) {
this.staticCodeName = staticCodeName;
}
 
void setDynamicCodeName(String dynamicCodeName) {
this.dynamicCodeName = dynamicCodeName;
}
 
void toXML(StringBuilder result) {
String s_value;
int numberOfLowestVariable = 256 - NUMBER_OF_VARIABLES;
if (value >= numberOfLowestVariable) {
s_value = "var" + (value - numberOfLowestVariable);
} else
s_value = Integer.toString(value);
206,7 → 257,7
public List<Section> getDeclaredSections() {
return declaredSections;
}
 
public void setData(int[] data) {
int offset = 0;
for (ConfigEntry entry : entries) {
287,55 → 338,73
 
for (int i = 0; i < sectionNodes.getLength(); i++) {
Element sectionNode = (Element) sectionNodes.item(i);
Section section = new Section(sectionNode.getAttribute("name"), sectionNode.getAttribute("title"));
Section section = new Section(sectionNode.getAttribute("name"),
sectionNode.getAttribute("title"));
result.declaredSections.add(section);
NodeList parameterNodes = (NodeList) xpath.evaluate(
"parameter", sectionNode, XPathConstants.NODESET);
 
for (int j=0; j<parameterNodes.getLength(); j++) {
Element parameterNode = (Element) parameterNodes.item(j);
NodeList parameterNodes = (NodeList) xpath.evaluate(
"parameter", sectionNode, XPathConstants.NODESET);
 
ConfigEntry entry;
if (!sectionNode.hasAttribute("name")) {
throw new IOException("A parameter element (the " + j
+ "th in section "+sectionNode.getAttribute("name")+") had no name attribute!");
}
for (int j = 0; j < parameterNodes.getLength(); j++) {
Element parameterNode = (Element) parameterNodes.item(j);
 
String s_name = parameterNode.getAttribute("name");
String s_type;
ConfigEntry entry;
 
if (parameterNode.hasAttribute("type")) {
s_type = parameterNode.getAttribute("type");
} else {
s_type = "static";
}
if (!sectionNode.hasAttribute("name")) {
throw new IOException("A parameter element (the " + j
+ "th in section "
+ sectionNode.getAttribute("name")
+ ") had no name attribute!");
}
 
if ("static".equals(s_type)) {
entry = new ConfigSet.ByteEntry(s_name, false);
} else if ("dynamic".equals(s_type)) {
entry = new ConfigSet.ByteEntry(s_name, true);
} else if ("bitset".equals(s_type)) {
NodeList bitNodes = (NodeList) xpath.evaluate("bit", parameterNode, XPathConstants.NODESET);
String[] bitNames = new String[8];
for (int k=0; k<8; k++) {
Element bitNode = (Element) bitNodes.item(k);
if (bitNode != null) {
bitNames[k] = bitNode.getAttribute("name");
} else {
bitNames[k] = "Unused";
String s_name = parameterNode.getAttribute("name");
String s_type;
 
if (parameterNode.hasAttribute("type")) {
s_type = parameterNode.getAttribute("type");
} else {
s_type = "static";
}
 
if ("static".equals(s_type)) {
entry = new ConfigSet.StaticByteEntry(s_name);
} else if ("dynamic".equals(s_type)) {
ConfigSet.DynamicByteEntry de = new ConfigSet.DynamicByteEntry(s_name);
if (parameterNode.hasAttribute("minValue")) {
de.setMinValue(Integer.parseInt(parameterNode.getAttribute("minValue")));
}
if (parameterNode.hasAttribute("maxValue")) {
de.setMinValue(Integer.parseInt(parameterNode.getAttribute("maxValue")));
}
if (parameterNode.hasAttribute("staticCodeName")) {
de.setStaticCodeName(parameterNode.getAttribute("staticCodeName"));
} else de.setStaticCodeName(de.getName());
if (parameterNode.hasAttribute("dynamicCodeName")) {
de.setDynamicCodeName(parameterNode.getAttribute("dynamicCodeName"));
} else de.setDynamicCodeName(de.getName());
entry = de;
} else if ("bitset".equals(s_type)) {
NodeList bitNodes = (NodeList) xpath.evaluate("bit",
parameterNode, XPathConstants.NODESET);
String[] bitNames = new String[8];
for (int k = 0; k < 8; k++) {
Element bitNode = (Element) bitNodes.item(k);
if (bitNode != null) {
bitNames[k] = bitNode.getAttribute("name");
} else {
bitNames[k] = "Unused";
}
}
entry = new ConfigSet.BitSetEntry(s_name, bitNames);
} else {
throw new IOException("Unknown parameter type: "
+ s_type);
}
entry = new ConfigSet.BitSetEntry(s_name, bitNames);
} else {
throw new IOException("Unknown parameter type: " + s_type);
 
result.entries.add(entry);
section.addConfigEntry(entry);
}
result.entries.add(entry);
section.addConfigEntry(entry);
}
}
result.name = "" + version;
return result;
} catch (IOException ex) {
348,4 → 417,30
throw new IOException(ex);
}
}
 
public String generateDynamicSubstitutionCode() {
StringBuilder result = new StringBuilder(
"const MMXLATION XLATIONS[] = {\n");
boolean hasEntries = false;
for (ConfigEntry entry : entries) {
if (entry instanceof ConfigSet.DynamicByteEntry) {
if (hasEntries)
result.append(",\n");
else
hasEntries = true;
ConfigSet.DynamicByteEntry de = (ConfigSet.DynamicByteEntry) entry;
result.append("{offsetof(ParamSet_t, ");
result.append(de.getStaticCodeName());
result.append("), offsetof(DynamicParams_t, ");
result.append(de.getDynamicCodeName());
result.append("),");
result.append(Integer.toString(de.getMinValue()));
result.append(",");
result.append(Integer.toString(de.getMaxValue()));
result.append("}");
}
}
result.append("};");
return result.toString();
}
}
/dongfang_FC_rewrite_tool/src/dongfang/mkt/main/CodeGenerator.java
0,0 → 1,16
package dongfang.mkt.main;
 
import java.io.IOException;
 
import dongfang.mkt.configuration.ConfigSet;
 
public class CodeGenerator {
static void generateDynamicSubstitutionCode(int paramSetVersion) throws IOException {
ConfigSet cs = ConfigSet.parseXMLConfigSet(paramSetVersion);
System.out.println(cs.generateDynamicSubstitutionCode());
}
public static void main (String[] args) throws IOException {
CodeGenerator.generateDynamicSubstitutionCode(3);
}
}
/dongfang_FC_rewrite_tool/src/dongfang/mkt/main/UniversalConfigurator.java
121,13 → 121,11
 
private static int substituteVariables(String s_value) {
int numberOfHighestVar = 255;
int numberOfLowestVar = numberOfHighestVar
- ConfigSet.NUMBER_OF_VARIABLES;
int numberOfLowestVar = numberOfHighestVar - ConfigSet.NUMBER_OF_VARIABLES + 1;
for (int i = 0; i < ConfigSet.NUMBER_OF_VARIABLES; i++) {
String varName = "var" + i;
if (varName.equals(s_value)) {
System.out.println("Substing: " + s_value + "-->"
+ (numberOfLowestVar + i));
System.out.println("Substing: " + s_value + "-->" + (numberOfLowestVar + i));
return numberOfLowestVar + i;
}
}