private void fnMOVAndCompute(string[] pCOMMAND, cla_stPLCcs.stPLC_OBJ[] pPLC_OBJ, ref int piStackDepth) { if (pPLC_OBJ[piStackDepth - 1].status) { var getNumber = GetNumberKDTC(pCOMMAND[1]); var xmlD = new ClaXmlD(); xmlD.Modify(pCOMMAND[2], getNumber.ToString(CultureInfo.InvariantCulture)); } }
//Function_10 写多路寄存器 private byte[] createRespondMessage_10() { var bytesToSend = 0; bytesToSend = 8; var respondMessage = new byte[bytesToSend]; respondMessage[0] = _slaveAddress; respondMessage[1] = 16; respondMessage[2] = _messageReceived[2]; respondMessage[3] = _messageReceived[3]; respondMessage[4] = _messageReceived[4]; respondMessage[5] = _messageReceived[5]; var startAddress = (_messageReceived[2] << 8) | _messageReceived[3]; startAddress = startAddress - 4096; string CellNAme = "D" + (startAddress); // var numberOfPoints = (_messageReceived[4] << 8) | _messageReceived[5]; float setValue = IeeeToFloat(); _xmlD.Modify(CellNAme, setValue.ToString(CultureInfo.InvariantCulture)); var crcCalculation = Modbus.CRCStuff.calculateCRC(respondMessage, bytesToSend - 2); respondMessage[bytesToSend - 2] = crcCalculation[0]; respondMessage[bytesToSend - 1] = crcCalculation[1]; return(respondMessage); }
private int fnDADDAndCompute(string[] pCOMMAND, cla_stPLCcs.stPLC_OBJ[] pPLC_OBJ, ref int piStackDepth) { if (pPLC_OBJ[piStackDepth - 1].status) { var xmlD = new ClaXmlD(); double getNumbera = 0; if (pCOMMAND[1][0] == 'D') { string s = xmlD.ReadCell(pCOMMAND[1]); getNumbera = Convert.ToDouble(s); } else { getNumbera = GetNumberKDTC(pCOMMAND[1]); } double getNumberb = 0; if (pCOMMAND[2][0] == 'D') { getNumberb = Convert.ToDouble(xmlD.ReadCell(pCOMMAND[2])); } else { getNumberb = GetNumberKDTC(pCOMMAND[2]); } var numberC = getNumbera + getNumberb; xmlD.Modify(pCOMMAND[3], numberC.ToString(CultureInfo.InvariantCulture)); return(0); } return(0); }