private void OnReadPeripheralsCallback(PeripheralsLocateInfo periInfo, object userToken) { ShowGlobalProcessEnd(); for (int i = 0; i < periInfo.UseablePeripheralList.Count; i++) { UseablePeripheral peri = periInfo.UseablePeripheralList[i]; if (peri.SensorType == PeripheralsType.LightSensorOnSender || peri.SensorType == PeripheralsType.LightSensorOnFuncCardInPort) { PeripheralUIData data = new PeripheralUIData(); data.IsSelected = false; data.Location = peri; data.LocationString = GetLocationString(peri, _globalParams.AllBaseInfo); Application.Current.Dispatcher.Invoke(new Action(() => { PeripheralList.Add(data); })); } } UpdateUI(_oldData); }
/// <summary> /// 内部使用的,禁止调用(需在此增加方法超时后的处理方法) /// </summary> /// <param name="timerOut"></param> /// <param name="funcName"></param> private void UITimeOutExec(int timerOut, string funcName) { _autoEventIsTimeOut.Reset(); _autoEventIsTimeOut.WaitOne(timerOut, false); if (_isTimeOut) { switch (funcName) { case "RefreshAllFunctionCardInfos": if (GetFunctionCardPowerEvent != null) { if (_peripheralCfgDICDic == null) { _peripheralCfgDICDic = new SerializableDictionary<string, string>(); } else { _peripheralCfgDICDic.Clear(); } GetFunctionCardPowerEvent(null, null); } _fLogService.Error("FunctionCard Read Timeout!"); break; case "RefreshAllOpticalProbeInfos": if (GetLightProbeEvent != null) { if (AllOpticalProbeInfo == null || AllOpticalProbeInfo.UseablePeripheralList == null) { AllOpticalProbeInfo = new PeripheralsLocateInfo(); } else { AllOpticalProbeInfo.UseablePeripheralList.Clear(); } GetLightProbeEvent(null, null); } break; default: break; } } }
private void ExecSensorData(PeripheralsLocateInfo perInfos) { lock (_lockObj) { foreach (KeyValuePair <string, List <PeripheralsLocation> > keyValue in _sn_BrightSensors) { if (perInfos.UseablePeripheralList == null || perInfos.UseablePeripheralList.Count == 0) { AutoReadResultData auto = _autoReadResultDatas.Find(a => a.SN == keyValue.Key); if (auto != null) { auto.AutoSensorInfo.IsSucess = false; auto.AutoSensorInfo.SensorValue = 0; } else { _autoReadResultDatas.Add(new AutoReadResultData() { SN = keyValue.Key, AutoSensorInfo = new AutoGetSensorInfo() { IsSucess = false, SensorValue = 0 } }); } continue; } int value = 0; int count = 0; foreach (PeripheralsLocation per in keyValue.Value) { var resultItem = perInfos.UseablePeripheralList.FirstOrDefault(o => o.Equals(per)); if (resultItem != null) { value += (int)resultItem.SensorValue; count++; } } if (count > 0) { AutoReadResultData auto = _autoReadResultDatas.Find(a => a.SN == keyValue.Key); if (auto != null) { auto.AutoSensorInfo.IsSucess = true; auto.AutoSensorInfo.SensorValue = (int)(value / count); } else { _autoReadResultDatas.Add(new AutoReadResultData() { SN = keyValue.Key, AutoSensorInfo = new AutoGetSensorInfo() { IsSucess = true, SensorValue = (int)(value / count) } }); } } } } }
void MoniDatareader_FindPeripheralsEvent(PeripheralsLocateInfo periInfo) { SendData("FindPeripherals", CommandTextParser.GetJsonSerialization<PeripheralsLocateInfo>(periInfo)); }
private void ReadPeripheralsResultCallback(PeripheralsLocateInfo periInfo, object userToken) { TransFerDataHandlerCallback(TransferType.M3_PeripheralsInfo, CommandTextParser.GetJsonSerialization<PeripheralsLocateInfo>(periInfo), userToken); }