private void timerHandShake_Tick(object sender, EventArgs e) { try { var device = srv.DU_Device_GetOneByDeviceId(srm.DEVICEID); if (device.WORKINGSTATUS == "堆垛机:正常") { stk.currentState = "正常"; lbCurrentState.BackColor = Color.White; lbCurrentState.ForeColor = Color.Lime; lbCurrentState.Text = "堆垛机:正常"; ChangeButtonEnable(true); } else if (device.WORKINGSTATUS == "WCS通讯未启动") { stk.currentState = "断线"; lbCurrentState.BackColor = Color.Red; lbCurrentState.ForeColor = Color.White; lbCurrentState.Text = "WCS通讯未启动"; ChangeButtonEnable(false); } else if (device.WORKINGSTATUS == "堆垛机:连线中断") { stk.currentState = "断线"; lbCurrentState.BackColor = Color.Red; lbCurrentState.ForeColor = Color.White; lbCurrentState.Text = "堆垛机:连线中断"; ChangeButtonEnable(false); } else if (device.WORKINGSTATUS == "堆垛机:脱机") { stk.currentState = "脱机"; lbCurrentState.BackColor = Color.Red; lbCurrentState.ForeColor = Color.White; lbCurrentState.Text = "堆垛机:脱机"; ChangeButtonEnable(false); } else { stk.currentState = "报警"; lbCurrentState.BackColor = Color.Red; lbCurrentState.ForeColor = Color.White; lbCurrentState.Text = "堆垛机:报警"; ChangeButtonEnable(false); } } catch (Exception) { stk.currentState = "未知"; lbCurrentState.BackColor = Color.White; lbCurrentState.ForeColor = Color.Lime; lbCurrentState.Text = "堆垛机:未知"; ChangeButtonEnable(true); } //////////////////////////////////////// }
/// <summary> /// 保持和WCS模块通讯的线程 /// </summary> /// <param name="obj"></param> private void SRM_Communicate() { string duStatus = ""; int n = 0; while (true) { try { using (ASRS_ServiceSoapClient srv = new ASRS_ServiceSoapClient()) { var srm_1 = srv.DU_Device_GetOneByDeviceId("SRM_1"); if (duStatus == srm_1.AISLE) { n++; } else { n = 0; duStatus = srm_1.AISLE; } if (n > 5)//3次 { tSLableWCS.Text = "堆垛机:通讯中断"; tSLableWCS.BackColor = Color.Red; tSLableWCS.ForeColor = Color.White; srmStatus = "堆垛机:通讯中断"; } else { tSLableWCS.Text = "堆垛机:正常"; tSLableWCS.ForeColor = Color.Lime; tSLableWCS.BackColor = Color.Transparent; srmStatus = "堆垛机:正常"; } } } catch (Exception ex) { } Thread.Sleep(800); } }