private void configItemDeviceID_ButtonWriteClick(object sender, EventArgs e) { UInt16[] dat = UserApp.ConvertStrinbg2U16(configItemDeviceID.Text1); userSerial.sendCommand((byte)FuntionCode.ConfigSetDeviceID, dat, 3); formProcess = new FormProcess("Write Device ID!"); DialogResult res = formProcess.ShowDialog(); if (res == DialogResult.No) { configItemDeviceID.setMessage("Write Timeout!", ConfigMessageIconEnum.Error); } }
private void configItemServer_ButtonWriteClick(object sender, EventArgs e) { UInt16[] data = UserApp.ConvertServer2U16(configItemServer.Text1, configItemServer.Text2); userSerial.sendCommand((byte)FuntionCode.ServerSetDAQ, data, (byte)data.Length); formProcess = new FormProcess("Write Server DAQ"); DialogResult res = formProcess.ShowDialog(); if (res == DialogResult.No) { configItemServer.setMessage("Write Timeout!", ConfigMessageIconEnum.Error); } }
private void ProcessServerCommand(CommandType command) { switch (command.Funtion) { case (byte)FuntionCode.ServerSetDAQ: if (command.NumArgs < 2) { formProcess.closeDiablog(false); configItemServer.setMessage("Write Error!", ConfigMessageIconEnum.Error); break; } configItemServer.setText1(command.Args[0].ToString()); configItemServer.setText2(UserApp.ConvertByte2String(command.Args, 1, command.NumArgs - 1)); formProcess.closeDiablog(true); configItemServer.setMessage("Write OK!", ConfigMessageIconEnum.Ok); configItemServer.setButtonWriteEnable(false); break; case (byte)FuntionCode.ServerGetDAQ: if (command.NumArgs < 2) { formProcess.closeDiablog(false); configItemServer.setMessage("Read Error!", ConfigMessageIconEnum.Error); break; } configItemServer.setText1(command.Args[0].ToString()); configItemServer.setText2(UserApp.ConvertByte2String(command.Args, 1, command.NumArgs - 1)); formProcess.closeDiablog(true); configItemServer.setMessage("Read OK!", ConfigMessageIconEnum.Ok); configItemServer.setButtonWriteEnable(false); break; default: break; } }
private void callProcessData(byte[] data) { setRXSignal(); int len = data[(int)CMDIndex.LenghtRes] * 2 + 4; if (IsChecksum(data, 0, len, data[len], data[len + 1]) == false) { Console.WriteLine("Response Error Checksum!", LogTextColor.Error); return; } UserApp.parseArgCommand(data, commandType); if (commandType.Type == 0x03) { switch (commandType.Funtion & 0xF0) { case (byte)FuntionCode.DeviceFuntion: if (ProcessDeviceCommand != null) { ProcessDeviceCommand?.Invoke(commandType); } break; case (byte)FuntionCode.ConfigFuntion: if (ProcessConfigCommand != null) { ProcessConfigCommand?.Invoke(commandType); } break; case (byte)FuntionCode.TestFuntion: if (ProcessTestCommand != null) { ProcessTestCommand?.Invoke(commandType); } break; case (byte)FuntionCode.GSMFuntion: if (ProcessGSMCommand != null) { ProcessGSMCommand?.Invoke(commandType); } break; case (byte)FuntionCode.ServerFuntion: if (ProcessServerCommand != null) { ProcessServerCommand?.Invoke(commandType); } break; case (byte)FuntionCode.BatteryFuntion: if (ProcessBatteryCommand != null) { ProcessBatteryCommand?.Invoke(commandType); } break; case (byte)FuntionCode.ReadParamFuntion: if (ProcessReadParamCommand != null) { ProcessReadParamCommand?.Invoke(commandType); } break; case (byte)FuntionCode.FlashFuntion: if (ProcessFlashCommand != null) { ProcessFlashCommand?.Invoke(commandType); } break; default: break; } } else if (commandType.Type == 0x04) { } }
private void ProcessConfigcommand(CommandType command) { if (command.Error != 0) { switch (command.Funtion) { case (byte)FuntionCode.ConfigEnter: break; case (byte)FuntionCode.ConfigExit: break; case (byte)FuntionCode.ConfigSetSamplingSendingRate: //configItemSamplingSendding.MessageText = formProcess.closeDiablog(false); configItemSamplingSendding.setMessage("Write Error!", ConfigMessageIconEnum.Error); break; case (byte)FuntionCode.ConfigGetSamplingSendingRate: formProcess.closeDiablog(false); configItemSamplingSendding.setMessage("Read Error!", ConfigMessageIconEnum.Error); break; case (byte)FuntionCode.ConfigSetSerialID: formProcess.closeDiablog(false); configItemSerialID.setMessage("Write Error!", ConfigMessageIconEnum.Error); break; case (byte)FuntionCode.ConfigGetSerialID: formProcess.closeDiablog(false); configItemSerialID.setMessage("Read Error!", ConfigMessageIconEnum.Error); break; case (byte)FuntionCode.ConfigSetDeviceID: formProcess.closeDiablog(false); configItemDeviceID.setMessage("Write Error!", ConfigMessageIconEnum.Error); break; case (byte)FuntionCode.ConfigGetDeviceID: formProcess.closeDiablog(false); configItemDeviceID.setMessage("Read Error!", ConfigMessageIconEnum.Error); break; case (byte)FuntionCode.ConfigSetLoggingMode: formProcess.closeDiablog(false); configItemLogging.setMessage("Write Error!", ConfigMessageIconEnum.Error); break; case (byte)FuntionCode.ConfigGetLoggingMode: formProcess.closeDiablog(false); configItemLogging.setMessage("Read Error!", ConfigMessageIconEnum.Error); break; case (byte)FuntionCode.ConfigGetAllSetting: break; default: break; } return; } switch (command.Funtion) { case (byte)FuntionCode.ConfigEnter: formProcess.closeDiablog(true); break; case (byte)FuntionCode.ConfigExit: formProcess.closeDiablog(true); break; case (byte)FuntionCode.ConfigSetSamplingSendingRate: configItemSamplingSendding.setText1(command.Args[0].ToString()); configItemSamplingSendding.setText2(command.Args[1].ToString()); formProcess.closeDiablog(true); configItemSamplingSendding.setMessage("Write OK!", ConfigMessageIconEnum.Ok); configItemSamplingSendding.setButtonWriteEnable(false); saveFlash = false; break; case (byte)FuntionCode.ConfigGetSamplingSendingRate: configItemSamplingSendding.setText1(command.Args[0].ToString()); configItemSamplingSendding.setText2(command.Args[1].ToString()); //configItemSamplingSendding.Text1 = command.Args[0].ToString(); //configItemSamplingSendding.Text2 = command.Args[2].ToString(); formProcess.closeDiablog(true); configItemSamplingSendding.setMessage("Read OK!", ConfigMessageIconEnum.Ok); configItemSamplingSendding.setButtonWriteEnable(false); break; case (byte)FuntionCode.ConfigSetSerialID: configItemSerialID.setText1(UserApp.ConvertByte2String(command.Args, 0, 2)); formProcess.closeDiablog(true); configItemSerialID.setMessage("Write OK!", ConfigMessageIconEnum.Ok); configItemSerialID.setButtonWriteEnable(false); saveFlash = false; break; case (byte)FuntionCode.ConfigGetSerialID: configItemSerialID.setText1(UserApp.ConvertByte2String(command.Args, 0, 2)); formProcess.closeDiablog(true); configItemSerialID.setMessage("Read OK!", ConfigMessageIconEnum.Ok); configItemSerialID.setButtonWriteEnable(false); break; case (byte)FuntionCode.ConfigSetDeviceID: formProcess.closeDiablog(true); configItemDeviceID.setText1(UserApp.ConvertByte2String(command.Args, 0, 3)); configItemDeviceID.setMessage("Write OK!", ConfigMessageIconEnum.Ok); configItemDeviceID.setButtonWriteEnable(false); saveFlash = false; break; case (byte)FuntionCode.ConfigGetDeviceID: formProcess.closeDiablog(true); configItemDeviceID.setText1(UserApp.ConvertByte2String(command.Args, 0, 3)); configItemDeviceID.setMessage("Read OK!", ConfigMessageIconEnum.Ok); configItemDeviceID.setButtonWriteEnable(false); break; case (byte)FuntionCode.ConfigSetLoggingMode: formProcess.closeDiablog(true); if (command.Args[0] == 'E') { configItemLogging.setText("Enable"); } else if (command.Args[0] == 'D') { configItemLogging.setText("Disable"); } configItemLogging.setMessage("Write OK!", ConfigMessageIconEnum.Ok); configItemLogging.setButtonWriteEnable(false); saveFlash = false; break; case (byte)FuntionCode.ConfigGetLoggingMode: formProcess.closeDiablog(true); if (command.Args[0] == 'E') { configItemLogging.setText("Enable"); } else if (command.Args[0] == 'D') { configItemLogging.setText("Disable"); } configItemLogging.setMessage("Read OK!", ConfigMessageIconEnum.Ok); configItemLogging.setButtonWriteEnable(false); break; case (byte)FuntionCode.ConfigGetAllSetting: formProcess.closeDiablog(true); break; default: break; } }