public void SendCompositeData(DataPoint dp) { //if (dp.TimeStamp == 0) // dp.TimeStamp = DateTime.Now.Ticks; DataEngine.SendData(dp); }
public void SendData(DataPoint data) { if (DataPointReceived != null) DataPointReceived(data); }
internal static void SendData(DataPoint data) { try { if (recordData) { lock (_sync) { if (!_datamap.ContainsKey(data.Key)) { _datamap.Add(data.Key, data); } else { _datamap[data.Key] = data; } } } foreach (DataService service in innerServiceCollection) { if (service.IsInterrupted) continue; if (!service.Need(data.Key)) continue; try { service.Client.ReceiveCompositeData(data); } catch (Exception ex) { service.IsInterrupted = true; service.Exception = ex; } } } catch (Exception ex) { _logService.Error(string.Format("ExistCatch:error:<-{0}->:{1} \r\n Error detail:{2}", "SendData", ex.Message, ex.ToString())); } }
internal static void SendData(string key, object data) { try { if (_recordEnable) { DataPoint dp = new DataPoint(); dp.Key = key; //dp.TimeStamp = DateTime.Now.Ticks; dp.Value = data; string mapKey = key; lock (_sync) { if (_datamap != null) { if (key == "MonitoringData") { var tempVar = data as DataPoint; if (tempVar != null) { mapKey = "(" + key + ")" + tempVar.Key; } } if (!_datamap.ContainsKey(mapKey)) { _datamap.Add(mapKey, dp); } else { _datamap[mapKey] = dp; } } } } foreach (DataService service in innerServiceCollection) { if (service.IsInterrupted) continue; if (!service.Need(key)) continue; try { service.Client.ReceiveData(key, data); } catch (Exception ex) { service.IsInterrupted = true; service.Exception = ex; } } //策略引擎获取实时数据 Task task = Task.Factory.StartNew(() => { RuleEngine.ReceiveData(key, data); }); } catch (Exception ex) { _logService.Error(string.Format("ExistCatch:error:<-{0}->:{1} \r\n Error detail:{2}", "SendData", ex.Message, ex.ToString())); } }
//private SerializableDictionary<string, List<byte>> _senderRetryInfoDic; //private SerializableDictionary<string, List<ScanBoardRegionInfo>> _scanRetryInfoDic; private void ReadDataCallback(CompletedMonitorCallbackParams cmpParams, object userToken) { //if (userToken != null) //{ // SenderMonitorDataNeedRetry(cmpParams, _ledAlarmConfigDic, out _senderRetryInfoDic); // if (_senderRetryInfoDic.Count != 0) // { // _isNeedRetry = true; // _dataType = DataType.senderData; // return; // } // else // { // ScannerMonitorDataNeedRetry(cmpParams, _ledAlarmConfigDic, out _scanRetryInfoDic); // if (_scanRetryInfoDic.Count != 0) // { // _isNeedRetry = true; // _dataType = DataType.scannerData; // return; // } // } //} //_isNeedRetry = false; try { if (cmpParams != null && cmpParams.MonitorData != null && cmpParams.MonitorData.AllScreenMonitorCollection != null && cmpParams.MonitorData.AllScreenMonitorCollection.Count > 0) { SendData("M3_MonitoringData", CommandTextParser.GetJsonSerialization<AllMonitorData>(cmpParams.MonitorData)); SendData("M3_StateData", "ReadMonitoringSuccess"); } else { SendData("M3_MonitoringData", CommandTextParser.GetJsonSerialization<AllMonitorData>(cmpParams.MonitorData)); SendData("M3_StateData", "ReadMonitoringFailed"); } WriteLog("ReadDataCallback回调开始,首先获取计算机的相关参数..."); #region pc hardware information string pcInfo = string.Empty; pcInfo += _sysInfo.CpuLoad; pcInfo += "+" + _sysInfo.PhysicalMemory; pcInfo += "+" + _sysInfo.MemoryAvailable; List<HDDInfo> hInfoList = _sysInfo.GetLogicalDrives(); foreach (var hddInfo in hInfoList) { pcInfo += "+" + hddInfo.DiskName + "-" + hddInfo.TotalSize + "-" + hddInfo.FreeSpace; } DataPoint pcDP = new DataPoint(); pcDP.Key = ByteToHexStrX1(new byte[] { (byte)HWDeviceType.ComputerHWInfo }) + "|" + ByteToHexStrX1(new byte[] { (byte)(int)PhysicalType.ComputerStatus }) + "|" + ByteToHexStrX1(new byte[] { (byte)0 }) + "|" + ByteToHexStrX2(new byte[] { (byte)1 }); pcDP.Value = pcInfo; #endregion List<AutoReadResultData> brightList = _moniDatareader.AutoReadResultDatas(); WriteLog("ReadDataCallback将数据对外发出..."); Dictionary<string, object> allScreenMonitorData; List<DataPoint> dpList; if (MonitorDataConverter(cmpParams, out allScreenMonitorData)) { if (allScreenMonitorData.Count != 0) { dpList = new List<DataPoint>(); foreach (var item in allScreenMonitorData.Keys) { dpList = new List<DataPoint>(); foreach (var dataPoint in ((Dictionary<string, object>)allScreenMonitorData[item]).Keys) { DataPoint dp = new DataPoint(); dp.Key = dataPoint; dp.Value = ((Dictionary<string, object>)allScreenMonitorData[item])[dataPoint].ToString(); dpList.Add(dp); } #region brightness DataPoint pcDPBright = new DataPoint(); DataPoint pcDPSensorBright = new DataPoint(); if (brightList != null && brightList.Count != 0) { AutoReadResultData brightnessData = brightList.Find(a => a.SN == item); if (brightnessData != null && brightnessData.AutoBrightInfo != null) { if (brightnessData.AutoBrightInfo.IsSucess) { pcDPBright.Value = brightnessData.AutoBrightInfo.BrightValue.ToString(); } else { pcDPBright.Value = "-1"; } } if (brightnessData != null && brightnessData.AutoSensorInfo != null) { if (brightnessData.AutoSensorInfo.IsSucess) { pcDPSensorBright.Value = brightnessData.AutoSensorInfo.SensorValue.ToString(); } else { pcDPSensorBright.Value = "-1"; } } } else { pcDPBright.Value = "-1"; pcDPSensorBright.Value = "-1"; } pcDPBright.Key = ByteToHexStrX1(new byte[] { (byte)HWDeviceType.Screen }) + "|" + ByteToHexStrX1(new byte[] { (byte)(int)PhysicalType.brightness }) + "|" + ByteToHexStrX1(new byte[] { (byte)0 }) + "|" + ByteToHexStrX2(new byte[] { (byte)1 }); pcDPSensorBright.Key = ByteToHexStrX1(new byte[] { (byte)HWDeviceType.Screen }) + "|" + ByteToHexStrX1(new byte[] { (byte)(int)PhysicalType.EnvironmentBrightness }) + "|" + ByteToHexStrX1(new byte[] { (byte)0 }) + "|" + ByteToHexStrX2(new byte[] { (byte)1 }); #endregion dpList.Add(pcDP); dpList.Add(pcDPBright); dpList.Add(pcDPSensorBright); SendData("MonitoringData", new DataPoint() { Key = item, Value = dpList }); } } } WriteLog("ReadDataCallback将数据对外发出完成..."); } catch (Exception ex) { WriteLog("ReadDataCallback将数据返回时出现异常:" + ex.ToString()); _fLogService.Error("ExistCatch:ReadDataCallback将数据返回时出现异常:" + ex.ToString()); } finally { _fLogService.Debug("ReadDataCallback BusyWorking释放"); Interlocked.Exchange(ref _isReadingMonitorData, 0); } }
public void SendCompositeData(DataPoint dp) { _dataService.SendCompositeData(dp); }
public virtual void ReceiveCompositeData(DataPoint data) { }