public static string CreateRandomTempDataXML(uint time) { AOUStateData data = ValueGenerator.GetRandomStateData(time); string xml = AOUInputParser.CreateStateXmlString(data) + "\r\n"; return(xml); }
public static string CreateStateXmlString(AOUStateData data) { string temp = CreateStateTempXmlString(data.heaterTemp, data.hotTankTemp, data.retTemp, data.bufHotTemp, data.bufMidTemp, data.bufColdTemp, data.coolerTemp, data.coldTankTemp, data.BearHot); return "<state>" + CreateTimeXmlString(data.time_hours, data.time_sek_x_10_of_hour) + temp + "</state>"; }
public static bool ParseState(string tagText, out AOUStateData stateData) { /* <state><Time>19</Time><temp><Heat>34</Heat><Hot>31</Hot><Ret>27</Ret><BuHot>30</BuHot><BuMid>29</BuMid><BuCold>27</BuCold><Cool>32</Cool><Cold>30</Cold><BearHot>0</BearHot> <ch9>0</ch9><ch10>0</ch10><ch11>0</ch11><ch12>0</ch12><ch13>0</ch13><ch14>0</ch14><ch15>0</ch15><avg>28</avg></temp></stateData> // Arduino data ASCII format from AOU. // MASK_STATE = 2 hex digits MASK (e.g. “3F”), and 2 hex digits STATE (e.g. “12”). Optional tags except Time <state><Time>104898416</Time> // Number of 1/10 second ticks since RESET (32bits unsigned). Not Optional <temp> <Heat>120</Heat><Hot>122</Hot><Ret>68</Ret><BuHot>56</BuHot><BuMid>56</BuMid><BuCold>56</BuCold><Cool>40</Cool><Cold>56</Cold><BearHot>40</BearHot> </temp> // // 16bits signed <Pow>127</Pow> // 8bits unsigned <Valves>MMSS</Valves> // MASK_STATE, Bits: 0/Hot valve, 1/Cold valve, 2/Return valve <Energy>MMSS</Energy> // MASK_STATE, <UI>MMSS</UI> // MASK_STATE, BUTTON_ONOFF = 0x0001 (Soft on/Off); BUTTON_EMERGENCYOFF = 0x0002 (Hard Off); BUTTON_MANUALOPHEAT = 0x0004 (Forced Heating); // BUTTON_MANUALOPCOOL = 0x0008 (Forced Cooling); BUTTON_CYCLE = 0x0010 (Forced Cycling); BUTTON_RUN = 0x0020 (Run with IMM) <IMM>MMSS</IMM> // MASK_STATE, IMM_OutIMMError = 0x01; IMM_OutIMMBlockInject = 0x02; IMM_OutIMMBlockOpen = 0x04; IMM_InIMMStop = 0x08 // IMM_InCycleAuto = 0x10; IMM_InIMMInjecting = 0x20; IMM_InIMMEjecting = 0x40; IMM_InIMMToolClosed = 0x80 <Mode>MMSS</Mode> // MASK_STATE, <Mode>1</Mode>(int); HT_STATE_INVALID = -999; HT_STATE_COLD = -1; HT_STATE_UNKNOWN = 0; HT_STATE_HOT = 1 <Seq>117</Seq> // </state> <state><Time>4711</Time> <Valves>0101</Valves> // Example Hot feed valve “on” (i.e. feeds hot tempering fluid) </state> <state><Time>4721</Time> // One second (or 10 x 1/10 second) later <Valves>0100</Valves> // Hot feed valve “off” (i.e. stopped feeding hot tempering fluid) </state> */ stateData.time_sek_x_10_of_hour = 0; stateData.time_hours = 0; stateData.coldTankTemp = AOUDataTypes.UInt16_NaN; stateData.hotTankTemp = AOUDataTypes.UInt16_NaN; stateData.retTemp = AOUDataTypes.UInt16_NaN; stateData.coolerTemp = AOUDataTypes.UInt16_NaN; stateData.heaterTemp = AOUDataTypes.UInt16_NaN; stateData.bufColdTemp = AOUDataTypes.UInt16_NaN; stateData.bufMidTemp = AOUDataTypes.UInt16_NaN; stateData.bufHotTemp = AOUDataTypes.UInt16_NaN; stateData.seqState = AOUDataTypes.UInt16_NaN; stateData.BearHot = AOUDataTypes.UInt16_NaN; stateData.Power = AOUDataTypes.UInt16_NaN; stateData.Energy = AOUDataTypes.UInt16_NaN; stateData.IMM = AOUDataTypes.UInt16_NaN; stateData.Valves = AOUDataTypes.UInt16_NaN; stateData.Mode = Int16.MaxValue; stateData.UIButtons = AOUDataTypes.UInt16_NaN; ParseWordTime_sek_x_10(tagText, out stateData.time_hours, out stateData.time_sek_x_10_of_hour); ParseWord(tagTempSubTagHot, tagText, out stateData.hotTankTemp); ParseWord(tagTempSubTagCold, tagText, out stateData.coldTankTemp); ParseWord(tagTempSubTagRet, tagText, out stateData.retTemp); ParseWord(tagTempBuCold, tagText, out stateData.bufColdTemp); ParseWord(tagTempBuMid, tagText, out stateData.bufMidTemp); ParseWord(tagTempBuHot, tagText, out stateData.bufHotTemp); ParseWord(tagTempSubTagCool, tagText, out stateData.coolerTemp); ParseWord(tagTempSubTagHeat, tagText, out stateData.heaterTemp); ParseWord(tagTempSubTagBearHot, tagText, out stateData.BearHot); ParseWord(tagSeqState, tagText, out stateData.seqState); ParseWord(tagPower, tagText, out stateData.Power); byte mask; byte state; long temp; if (ParseMMSS(tagValves, tagText, out mask, out state)) { stateData.Valves = state; } if (ParseMMSS(tagEnergy, tagText, out mask, out state)) { stateData.Energy = state; } if (ParseMMSS(tagUI, tagText, out mask, out state)) { int hiAndLow = ((int)mask << 8) | state; stateData.UIButtons = (UInt16)hiAndLow; } if (ParseMMSS(tagIMM, tagText, out mask, out state)) { stateData.IMM = state; } if (ParseMMSS(tagMode, tagText, out mask, out state)) { stateData.Mode = state; } else if (ParseLong(tagMode, tagText, out temp)) { stateData.Mode = (Int16)temp; } return true; }
public static string CreateStateXmlString(AOUStateData data) { string temp = CreateStateTempXmlString(data.heaterTemp, data.hotTankTemp, data.retTemp, data.bufHotTemp, data.bufMidTemp, data.bufColdTemp, data.coolerTemp, data.coldTankTemp, data.BearHot); return("<state>" + CreateTimeXmlString(data.time_hours, data.time_sek_x_10_of_hour) + temp + "</state>"); }
public static bool ParseState(string tagText, out AOUStateData stateData) { /* * <state><Time>19</Time><temp><Heat>34</Heat><Hot>31</Hot><Ret>27</Ret><BuHot>30</BuHot><BuMid>29</BuMid><BuCold>27</BuCold><Cool>32</Cool><Cold>30</Cold><BearHot>0</BearHot> * <ch9>0</ch9><ch10>0</ch10><ch11>0</ch11><ch12>0</ch12><ch13>0</ch13><ch14>0</ch14><ch15>0</ch15><avg>28</avg></temp></stateData> // Arduino data * * ASCII format from AOU. // MASK_STATE = 2 hex digits MASK (e.g. “3F”), and 2 hex digits STATE (e.g. “12”). Optional tags except Time * * <state><Time>104898416</Time> // Number of 1/10 second ticks since RESET (32bits unsigned). Not Optional * <temp> <Heat>120</Heat><Hot>122</Hot><Ret>68</Ret><BuHot>56</BuHot><BuMid>56</BuMid><BuCold>56</BuCold><Cool>40</Cool><Cold>56</Cold><BearHot>40</BearHot> </temp> // // 16bits signed * <Pow>127</Pow> // 8bits unsigned * <Valves>MMSS</Valves> // MASK_STATE, Bits: 0/Hot valve, 1/Cold valve, 2/Return valve * <Energy>MMSS</Energy> // MASK_STATE, * * <UI>MMSS</UI> // MASK_STATE, BUTTON_ONOFF = 0x0001 (Soft on/Off); BUTTON_EMERGENCYOFF = 0x0002 (Hard Off); BUTTON_MANUALOPHEAT = 0x0004 (Forced Heating); * // BUTTON_MANUALOPCOOL = 0x0008 (Forced Cooling); BUTTON_CYCLE = 0x0010 (Forced Cycling); BUTTON_RUN = 0x0020 (Run with IMM) * * <IMM>MMSS</IMM> // MASK_STATE, IMM_OutIMMError = 0x01; IMM_OutIMMBlockInject = 0x02; IMM_OutIMMBlockOpen = 0x04; IMM_InIMMStop = 0x08 * // IMM_InCycleAuto = 0x10; IMM_InIMMInjecting = 0x20; IMM_InIMMEjecting = 0x40; IMM_InIMMToolClosed = 0x80 * * <Mode>MMSS</Mode> // MASK_STATE, <Mode>1</Mode>(int); HT_STATE_INVALID = -999; HT_STATE_COLD = -1; HT_STATE_UNKNOWN = 0; HT_STATE_HOT = 1 * <Seq>117</Seq> // * </state> * * <state><Time>4711</Time> * <Valves>0101</Valves> // Example Hot feed valve “on” (i.e. feeds hot tempering fluid) * </state> * <state><Time>4721</Time> // One second (or 10 x 1/10 second) later * <Valves>0100</Valves> // Hot feed valve “off” (i.e. stopped feeding hot tempering fluid) * </state> */ stateData.time_sek_x_10_of_hour = 0; stateData.time_hours = 0; stateData.coldTankTemp = AOUDataTypes.UInt16_NaN; stateData.hotTankTemp = AOUDataTypes.UInt16_NaN; stateData.retTemp = AOUDataTypes.UInt16_NaN; stateData.coolerTemp = AOUDataTypes.UInt16_NaN; stateData.heaterTemp = AOUDataTypes.UInt16_NaN; stateData.bufColdTemp = AOUDataTypes.UInt16_NaN; stateData.bufMidTemp = AOUDataTypes.UInt16_NaN; stateData.bufHotTemp = AOUDataTypes.UInt16_NaN; stateData.seqState = AOUDataTypes.UInt16_NaN; stateData.BearHot = AOUDataTypes.UInt16_NaN; stateData.Power = AOUDataTypes.UInt16_NaN; stateData.Energy = AOUDataTypes.UInt16_NaN; stateData.IMM = AOUDataTypes.UInt16_NaN; stateData.Valves = AOUDataTypes.UInt16_NaN; stateData.Mode = Int16.MaxValue; stateData.UIButtons = AOUDataTypes.UInt16_NaN; ParseWordTime_sek_x_10(tagText, out stateData.time_hours, out stateData.time_sek_x_10_of_hour); ParseWord(tagTempSubTagHot, tagText, out stateData.hotTankTemp); ParseWord(tagTempSubTagCold, tagText, out stateData.coldTankTemp); ParseWord(tagTempSubTagRet, tagText, out stateData.retTemp); ParseWord(tagTempBuCold, tagText, out stateData.bufColdTemp); ParseWord(tagTempBuMid, tagText, out stateData.bufMidTemp); ParseWord(tagTempBuHot, tagText, out stateData.bufHotTemp); ParseWord(tagTempSubTagCool, tagText, out stateData.coolerTemp); ParseWord(tagTempSubTagHeat, tagText, out stateData.heaterTemp); ParseWord(tagTempSubTagBearHot, tagText, out stateData.BearHot); ParseWord(tagSeqState, tagText, out stateData.seqState); ParseWord(tagPower, tagText, out stateData.Power); byte mask; byte state; long temp; if (ParseMMSS(tagValves, tagText, out mask, out state)) { stateData.Valves = state; } if (ParseMMSS(tagEnergy, tagText, out mask, out state)) { stateData.Energy = state; } if (ParseMMSS(tagUI, tagText, out mask, out state)) { int hiAndLow = ((int)mask << 8) | state; stateData.UIButtons = (UInt16)hiAndLow; } if (ParseMMSS(tagIMM, tagText, out mask, out state)) { stateData.IMM = state; } if (ParseMMSS(tagMode, tagText, out mask, out state)) { stateData.Mode = state; } else if (ParseLong(tagMode, tagText, out temp)) { stateData.Mode = (Int16)temp; } return(true); }