Commit c089422c authored by leon.huang's avatar leon.huang

modify MQtt Package

parent be6916d5
...@@ -134,27 +134,34 @@ namespace ModbusDemo.Modular ...@@ -134,27 +134,34 @@ namespace ModbusDemo.Modular
} }
} }
for (byte j = 0; j < byX18xReadTypeNumber; j++) for (byte j = 0; j < byX18xReadTypeNumber ; j++)
{ {
switch (cx18x.beChannelType[i, j]) if (ModbusErrorCode == ModbusComm.eModbusErrorCode.MB_EMASTERNOERR)
{
switch (cx18x.beChannelType[i, j])
{
case modual.eX18xSensorChannelType.Weiertai:
cx18x.sX18xDataStruct[i].dNowConvertData[j] = 8 - ((double.Parse(sTempString[i][j]) - 4) / 16 * 8);
break;
case modual.eX18xSensorChannelType.Mike_5:
cx18x.sX18xDataStruct[i].dNowConvertData[j] = 5 - ((double.Parse(sTempString[i][j]) - 4) / 16 * 5);
break;
case modual.eX18xSensorChannelType.Mike_6:
cx18x.sX18xDataStruct[i].dNowConvertData[j] = 6 - ((double.Parse(sTempString[i][j]) - 4) / 16 * 6);
break;
case modual.eX18xSensorChannelType.Mike_7:
cx18x.sX18xDataStruct[i].dNowConvertData[j] = 7 - ((double.Parse(sTempString[i][j]) - 4) / 16 * 7);
break;
case modual.eX18xSensorChannelType.Null:
cx18x.sX18xDataStruct[i].dNowConvertData[j] = 0;
break;
default:
break;
}
}
else
{ {
case modual.eX18xSensorChannelType.Weiertai: cx18x.sX18xDataStruct[i].dNowConvertData[j] = 0;
cx18x.sX18xDataStruct[i].dNowConvertData[j] = 8- ((double.Parse(sTempString[i][j]) - 4) / 16 * 8);
break;
case modual.eX18xSensorChannelType.Mike_5:
cx18x.sX18xDataStruct[i].dNowConvertData[j] = 5 - ((double.Parse(sTempString[i][j]) - 4) / 16 * 5);
break;
case modual.eX18xSensorChannelType.Mike_6:
cx18x.sX18xDataStruct[i].dNowConvertData[j] = 6 - ((double.Parse(sTempString[i][j]) - 4) / 16 * 6);
break;
case modual.eX18xSensorChannelType.Mike_7:
cx18x.sX18xDataStruct[i].dNowConvertData[j] = 7 - ((double.Parse(sTempString[i][j]) - 4) / 16 * 7);
break;
case modual.eX18xSensorChannelType.Null:
cx18x.sX18xDataStruct[i].dNowConvertData[j] = 0;
break;
default:
break;
} }
if (cx18x.sX18xAlarmstruct[i].bDataNotFirstIncreaseOrDecrease == true) if (cx18x.sX18xAlarmstruct[i].bDataNotFirstIncreaseOrDecrease == true)
{ {
...@@ -238,6 +245,7 @@ namespace ModbusDemo.Modular ...@@ -238,6 +245,7 @@ namespace ModbusDemo.Modular
WTDR78C OneNodeJsonPackage = new WTDR78C(stIdString, InputConvert[0], InputConvert[1],InputConvert[2], InputConvert[3], InputConvert[4], InputConvert[5],InputConvert[6], InputConvert[7], OutPutConver[0], OutPutConver[1], OutPutConver[2], OutPutConver[3], OutPutConver[4], OutPutConver[5], OutPutConver[6], OutPutConver[7],Form1.GetTimeStamp()); WTDR78C OneNodeJsonPackage = new WTDR78C(stIdString, InputConvert[0], InputConvert[1],InputConvert[2], InputConvert[3], InputConvert[4], InputConvert[5],InputConvert[6], InputConvert[7], OutPutConver[0], OutPutConver[1], OutPutConver[2], OutPutConver[3], OutPutConver[4], OutPutConver[5], OutPutConver[6], OutPutConver[7],Form1.GetTimeStamp());
stPollString += JsonConvert.SerializeObject(OneNodeJsonPackage) + ","; stPollString += JsonConvert.SerializeObject(OneNodeJsonPackage) + ",";
} }
for (sbyte i = 0; i < byX66cNumber; i++) for (sbyte i = 0; i < byX66cNumber; i++)
{ {
string stIdString = cx66c.byModbusID[i].ToString(); string stIdString = cx66c.byModbusID[i].ToString();
...@@ -245,7 +253,7 @@ namespace ModbusDemo.Modular ...@@ -245,7 +253,7 @@ namespace ModbusDemo.Modular
int[] sRelayConvert; int[] sRelayConvert;
sRelayConvert = cBoolConvertInt.IO(cx66c.sX66cRegStatusStruct[i].bRegRelayStatus); sRelayConvert = cBoolConvertInt.IO(cx66c.sX66cRegStatusStruct[i].bRegRelayStatus);
WTDR66C OneNodeJsonPackage = new WTDR66C(stIdString, sRelayConvert[0], sRelayConvert[1], sRelayConvert[2], sRelayConvert[3], sRelayConvert[4], sRelayConvert[5], Form1.GetTimeStamp()); WTDR66C OneNodeJsonPackage = new WTDR66C(stIdString, sRelayConvert[0], sRelayConvert[1], sRelayConvert[2], sRelayConvert[3], sRelayConvert[4], sRelayConvert[5], Form1.GetTimeStamp());
if (i >= byX66cNumber) if (i >= byX66cNumber -1)
{ {
stPollString += JsonConvert.SerializeObject(OneNodeJsonPackage) + "]"; stPollString += JsonConvert.SerializeObject(OneNodeJsonPackage) + "]";
return stPollString; return stPollString;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment