/// <summary> /// 验证连接号为clientNo的cnc是否存在 /// </summary> /// <param name="clientNo"></param> /// <returns></returns> public bool VerifyClient(short clientNo) { int ret = 0; string macSN = ""; bool flag = false; ret = m_Instance.HNC_SystemGetValue((int)HNCAPI.HncSystem.HNC_SYS_SN_NUM, ref macSN, clientNo); if (ret != 0) { return(false); } HNCData result = ncDatas.Find( delegate(HNCData temp) { return(String.Equals(temp.sysData.macSN, macSN, StringComparison.Ordinal)); } ); if (result == null) //没找到 { flag = true; } else //找到同SN的机床,以最新clientNo为准 { flag = true; if (result.sysData.clientNo != clientNo) { result.sysData.clientNo = clientNo; } } return(flag); }
public CollectHNCData(ref LineDevice.CNC cnc, ref List <HNCData> hncdatalist) { gatherSYS = new CollectSysData(); gatherCH = new CollectChanData(); gatherAXIS = new CollectAxisData(); hncdata = new HNCData(); hncdatalist.Add(hncdata); m_cnc = cnc; m_cnc.HCNCShareData = hncdata; hncdata.sysData.addr.ip = cnc.ip; hncdata.sysData.addr.port = cnc.port; hncdata.sysData.deviceCode = cnc.BujianID; bCollect = true; }
private static void UpdateLastProgStartTime(Int16 clientNo) { HNCData result = _ncDatas.Find( delegate(HNCData temp) { return(temp.sysData.clientNo == clientNo); } ); if (result == null) { return; } result.sysData.lastProgStartTime = DateTime.Now; }
public void StartCollectBase(Int16 clientNo) { string macSN = ""; int ret = 0; //开启一个线程隔N长事件收集一次 HNCData result = ncDatas.Find( delegate(HNCData temp) { return(temp.sysData.clientNo == clientNo); } ); if (result == null) { return; } ret = m_Instance.HNC_SystemGetValue((int)HNCAPI.HncSystem.HNC_SYS_SN_NUM, ref macSN, clientNo); if (ret != 0) { return; } CollectHNCData colresult = gatherHNCLst.Find( delegate(CollectHNCData temp) { return(String.Equals(temp.hncdata.sysData.macSN, macSN, StringComparison.Ordinal)); } ); if (colresult == null)//没有重复机床,第一次加入 { // CollectHNCData gatherHdata = new CollectHNCData(result); // gatherHNCLst.Add(gatherHdata); // gatherHdata.ThreadStart(); } else //以前有过同SN的机床 { if (colresult.collectThread == null) { // colresult.bCollect = true; // colresult.ThreadStart(); } } }
private static void UpdateCurrentAlarmLst(HNCData data, AlarmData alm) { if (alm.isOnOff == 1) { if (data.currentAlarmList.Count > 0) { bool find = false; for (Int32 i = 0; i < data.currentAlarmList.Count; i++) { if (data.currentAlarmList[i].alarmNo == alm.alarmNo && data.currentAlarmList[i].alarmTxt == alm.alarmTxt && data.currentAlarmList[i].isOnOff == 1) { find = true; break; } } if (!find) { data.currentAlarmList.Add(alm); } } else { data.currentAlarmList.Add(alm); } } else { for (Int32 i = 0; i < data.currentAlarmList.Count; i++) { if (data.currentAlarmList[i].alarmNo == alm.alarmNo && data.currentAlarmList[i].alarmTxt == alm.alarmTxt && data.currentAlarmList[i].isOnOff == 1) { data.currentAlarmList.RemoveAt(i); break; } } } data.alarmList.Add(alm); }