public void OpenHeadLight() { YJ_LmstMsg msg = new YJ_LmstMsg { c = "OpenLight" }; string str = JsonConvert.SerializeObject(msg); this.AppLayerSend(0xe0, str); }
public void SaveTraiFinOffset() { YJ_LmstMsg msg = new YJ_LmstMsg { c = "SaveTraiFinOffset" }; string str = JsonConvert.SerializeObject(msg); this.AppLayerSend(240, str); Thread.Sleep(40); }
public void SetTraiFinOffset(short Offset) { YJ_LmstMsg msg = new YJ_LmstMsg { c = "SetTraiFinOffset", value = Offset }; string str = JsonConvert.SerializeObject(msg); this.AppLayerSend(240, str); Thread.Sleep(40); }
private void HeaetBeatSendThrFunc() { YJ_LmstMsg msg = new YJ_LmstMsg(); while (true) { if (!this.IsConnection || (this.state_pl > 0)) { Thread.Sleep(10); } else { Thread.Sleep(200); } } }
private void UploadStateMachine()//上传状态机? { string str; YJ_LmstMsg msg = new YJ_LmstMsg(); switch (this.state_pl) { case 1: msg.c = "Reboot"; str = JsonConvert.SerializeObject(msg); this.AppLayerSend(this.addr_pl, str); this.TimeOut_pl.SetTime(500); this.state_pl = 2; this.UploadFirmwareState = 0; break; case 2: if (this.TimeOut_pl.IsTimeOut()) { msg.c = "UplaodFirmware"; msg.value = this.FileLen_pl; str = JsonConvert.SerializeObject(msg); this.AppLayerSend(this.addr_pl, 6, str); this.TimeOut_pl.SetTime(0xfa0); this.state_pl = 3; } break; case 3: if (!this.TimeOut_pl.IsTimeOut()) { if (this.flags_pl > 0) { this.flags_pl = 0; this.TimeOut_pl.SetTime(0xfa0); } break; } YJ_Log.DEBUG("Update fail!", 0); this.file_pl.Close(); this.reader_pl.Close(); this.UploadFirmwareState = -1; this.state_pl = 0; break; } }
public void StartToSendMsg(byte[] cm, int DivingNodeState) { YJ_LmstMsg msg = new YJ_LmstMsg(); this.CtrlMeasure = cm; msg.c = "SetSpeed"; msg.value = this.CtrlMeasure[0]; string str = JsonConvert.SerializeObject(msg); this.AppLayerSend(240, str); Thread.Sleep(40); msg.c = "SetDirection"; msg.value = this.CtrlMeasure[1]; str = JsonConvert.SerializeObject(msg); this.AppLayerSend(240, str); Thread.Sleep(40); msg.c = "SetSteerDirection_l"; msg.value = this.CtrlMeasure[2]; str = JsonConvert.SerializeObject(msg); this.AppLayerSend(0x10, str); Thread.Sleep(40); msg.c = "SetMotorSpeed_l"; msg.value = this.CtrlMeasure[3]; str = JsonConvert.SerializeObject(msg); this.AppLayerSend(0x10, str); Thread.Sleep(40); msg.c = "SetSteerDirection_r"; msg.value = this.CtrlMeasure[4]; str = JsonConvert.SerializeObject(msg); this.AppLayerSend(0x10, str); Thread.Sleep(40); msg.c = "SetMotorSpeed_r"; msg.value = this.CtrlMeasure[5]; str = JsonConvert.SerializeObject(msg); this.AppLayerSend(0x10, str); Thread.Sleep(40); msg.c = "SetDivingState"; msg.value = DivingNodeState; str = JsonConvert.SerializeObject(msg); this.AppLayerSend(0x30, str); }
private void StateMachineThrFunc() { int num = 0; string str = "msg"; byte[] buffer = new byte[this.Transport.MaxLtvPayload]; int addr = 0; int type = 0; while (true) { Thread.Sleep(1); if (this.IsRebootAllNode)//函数RebootAllNode()的作用 { YJ_LmstMsg msg = new YJ_LmstMsg(); this.IsRebootAllNode = false; msg.c = "Reboot"; string str2 = JsonConvert.SerializeObject(msg); this.AppLayerSend(240, str2); this.AppLayerSend(0x10, str2); this.AppLayerSend(0x20, str2); this.AppLayerSend(0x30, str2); } this.CheckeNodeTimeOut(); //检测超时? this.UploadStateMachine(); //上传状态机 switch (num) { case 0: if (this.Transport.IsConnection) { num = 1; this.IsConnection = true; } break; case 1: if (!this.Transport.IsConnection) { num = 0; this.IsConnection = false; } else if (this.AppLayerRecv(ref addr, ref type, ref str, ref buffer) > 0) { if (type == 5) { YJ_Log.ERR(str, addr); } else if (type == 4) { YJ_Log.DEBUG(str, addr); } else if ((type == 7) || (type == 9)) { this.ProUpload(str, addr); } else { this.ProNodeData(str, addr); YJ_Log.DATA(str, addr); } } break; } } }