예제 #1
0
        private bool MonitorDataConverter(CompletedMonitorCallbackParams monitorData, out Dictionary<string, object> allScreenMonitorData)
        {
            allScreenMonitorData = new Dictionary<string, object>();
            if (monitorData == null) return false;
            StringBuilder pathSB = new StringBuilder();
            byte keyByte = 0;
            List<byte> pathByteArr = new List<byte>();
            List<byte> tmpArr;
            if (monitorData.MonitorData.AllScreenMonitorCollection.Count == 0) return false;
            string key;
            foreach (var sData in monitorData.MonitorData.AllScreenMonitorCollection)
            {
                Dictionary<string, object> terMonitorData = new Dictionary<string, object>();
                #region sender card
                foreach (var senderData in sData.SenderMonitorCollection)//sender monitor data list
                {
                    keyByte = (byte)HWDeviceType.Sender;//equip type
                    pathByteArr.Clear();
                    for (int i = 0; i < senderData.MappingList.Count; i++)
                    {
                        pathByteArr.Add((byte)(int)senderData.MappingList[i].Device);
                        pathByteArr.Add((byte)senderData.MappingList[i].DeviceIndex);
                    }
                    tmpArr = new List<byte>(pathByteArr);
                    tmpArr.Add((byte)(int)PhysicalType.workstatus);
                    tmpArr.Add((byte)0);
                    key = ByteToHexStrX1(new byte[] { keyByte })
                                       + "|" + ByteToHexStrX1(new byte[] { (byte)(int)PhysicalType.workstatus })
                                       + "|" + ByteToHexStrX1(new byte[] { (byte)(tmpArr.Count / 2) })
                                       + "|" + ByteToHexStrX2(tmpArr.ToArray());
                    if (terMonitorData.ContainsKey(key)) continue;
                    terMonitorData.Add(key, (int)senderData.DeviceStatus);
                    if (senderData.DeviceStatus == DeviceWorkStatus.OK)
                    {
                        tmpArr = new List<byte>(pathByteArr);
                        tmpArr.Add((byte)(int)PhysicalType.connectedstatus);
                        tmpArr.Add((byte)0);
                        key = ByteToHexStrX1(new byte[] { keyByte })
                                           + "|" + ByteToHexStrX1(new byte[] { (byte)(int)PhysicalType.connectedstatus })
                                           + "|" + ByteToHexStrX1(new byte[] { (byte)(tmpArr.Count / 2) })
                                           + "|" + ByteToHexStrX2(tmpArr.ToArray());
                        if (terMonitorData.ContainsKey(key)) continue;
                        terMonitorData.Add(key, Convert.ToInt32(!senderData.IsDviConnected));

                        tmpArr = new List<byte>(pathByteArr);
                        tmpArr.Add((byte)(int)PhysicalType.dviRate);
                        tmpArr.Add((byte)0);
                        key = ByteToHexStrX1(new byte[] { keyByte })
                                               + "|" + ByteToHexStrX1(new byte[] { (byte)(int)PhysicalType.dviRate })
                                               + "|" + ByteToHexStrX1(new byte[] { (byte)(tmpArr.Count / 2) })
                                               + "|" + ByteToHexStrX2(tmpArr.ToArray());
                        if (terMonitorData.ContainsKey(key)) continue;
                        terMonitorData.Add(key, (int)senderData.DviRate);
                        #region Sender Card Port
                        foreach (var portInfo in senderData.ReduPortIndexCollection)
                        {
                            pathByteArr.Clear();
                            for (int i = 0; i < portInfo.MappingList.Count; i++)
                            {
                                pathByteArr.Add((byte)(int)portInfo.MappingList[i].Device);
                                pathByteArr.Add((byte)portInfo.MappingList[i].DeviceIndex);
                            }
                            tmpArr = new List<byte>(pathByteArr);
                            tmpArr.Add((byte)(int)PhysicalType.PortOfSenderStatus);
                            tmpArr.Add((byte)0);
                            key = ByteToHexStrX1(new byte[] { keyByte })
                                                   + "|" + ByteToHexStrX1(new byte[] { (byte)(int)PhysicalType.PortOfSenderStatus })
                                                   + "|" + ByteToHexStrX1(new byte[] { (byte)(tmpArr.Count / 2) })
                                                   + "|" + ByteToHexStrX2(tmpArr.ToArray());
                            if (terMonitorData.ContainsKey(key)) continue;
                            terMonitorData.Add(key, Convert.ToInt32(portInfo.IsReduState));
                        }
                        #endregion
                    }
                }
                #endregion
                #region Deconcentrator
                foreach (var deconcentratorData in sData.DeconcentratorCollection)
                {
                    pathByteArr.Clear();
                    for (int i = 0; i < deconcentratorData.MappingList.Count; i++)
                    {
                        pathByteArr.Add((byte)(int)deconcentratorData.MappingList[i].Device);
                        pathByteArr.Add((byte)deconcentratorData.MappingList[i].DeviceIndex);
                    }
                    tmpArr = new List<byte>(pathByteArr);
                    tmpArr.Add((byte)(int)PhysicalType.workstatus);
                    tmpArr.Add((byte)0);
                    key = ByteToHexStrX1(new byte[] { keyByte })
                       + "|" + ByteToHexStrX1(new byte[] { (byte)(int)PhysicalType.workstatus })
                       + "|" + ByteToHexStrX1(new byte[] { (byte)(tmpArr.Count / 2) })
                       + "|" + ByteToHexStrX2(tmpArr.ToArray());
                    if (terMonitorData.ContainsKey(key))
                        terMonitorData.Add(key, (int)deconcentratorData.DeviceStatus);
                }
                #endregion
                #region scanner card
                keyByte = (byte)HWDeviceType.Scanner;//equip type
                foreach (var scannerData in sData.ScannerMonitorCollection)
                {
                    pathByteArr.Clear();
                    for (int i = 0; i < scannerData.MappingList.Count; i++)
                    {
                        pathByteArr.Add((byte)(int)scannerData.MappingList[i].Device);
                        pathByteArr.Add((byte)scannerData.MappingList[i].DeviceIndex);
                    }
                    tmpArr = new List<byte>(pathByteArr);
                    tmpArr.Add((byte)(int)PhysicalType.workstatus);
                    tmpArr.Add((byte)0);

                    key = ByteToHexStrX1(new byte[] { keyByte })
                                       + "|" + ByteToHexStrX1(new byte[] { (byte)(int)PhysicalType.workstatus })
                                       + "|" + ByteToHexStrX1(new byte[] { (byte)(tmpArr.Count / 2) })
                                       + "|" + ByteToHexStrX2(tmpArr.ToArray());

                    if (terMonitorData.ContainsKey(key)) continue;
                    terMonitorData.Add(key, (int)scannerData.DeviceStatus);
                    if (scannerData.DeviceStatus == DeviceWorkStatus.OK)
                    {
                        tmpArr = new List<byte>(pathByteArr);
                        tmpArr.Add((byte)(int)PhysicalType.temperature);
                        tmpArr.Add((byte)0);
                        key = ByteToHexStrX1(new byte[] { keyByte })
                                           + "|" + ByteToHexStrX1(new byte[] { (byte)(int)PhysicalType.temperature })
                                           + "|" + ByteToHexStrX1(new byte[] { (byte)(tmpArr.Count / 2) })
                                           + "|" + ByteToHexStrX2(tmpArr.ToArray());
                        if (terMonitorData.ContainsKey(key)) continue;
                        terMonitorData.Add(key, scannerData.Temperature);
                        tmpArr = new List<byte>(pathByteArr);
                        tmpArr.Add((byte)(int)PhysicalType.voltage);
                        tmpArr.Add((byte)0);
                        key = ByteToHexStrX1(new byte[] { keyByte })
                                           + "|" + ByteToHexStrX1(new byte[] { (byte)(int)PhysicalType.voltage })
                                           + "|" + ByteToHexStrX1(new byte[] { (byte)(tmpArr.Count / 2) })
                                           + "|" + ByteToHexStrX2(tmpArr.ToArray());
                        if (terMonitorData.ContainsKey(key)) continue;
                        terMonitorData.Add(key, scannerData.Voltage);
                    }
                }
                #endregion
                #region function card
                keyByte = (byte)HWDeviceType.FunctionCard;//equip type
                foreach (var funCardData in sData.FunctionCardInfoCollection)
                {
                    pathByteArr.Clear();
                    for (int i = 0; i < funCardData.MappingList.Count; i++)
                    {
                        pathByteArr.Add((byte)(int)funCardData.MappingList[i].Device);
                        pathByteArr.Add((byte)funCardData.MappingList[i].DeviceIndex);
                    }
                    tmpArr = new List<byte>(pathByteArr);
                    tmpArr.Add((byte)(int)PhysicalType.workstatus);
                    tmpArr.Add((byte)0);
                    key = ByteToHexStrX1(new byte[] { keyByte })
                                       + "|" + ByteToHexStrX1(new byte[] { (byte)(int)PhysicalType.workstatus })
                                       + "|" + ByteToHexStrX1(new byte[] { (byte)(tmpArr.Count / 2) })
                                       + "|" + ByteToHexStrX2(tmpArr.ToArray());
                    if (terMonitorData.ContainsKey(key)) continue;
                    terMonitorData.Add(key, (int)funCardData.DeviceStatus);
                    if (funCardData.DeviceStatus == DeviceWorkStatus.OK)
                    {
                        List<byte> funCardPathByteArr = new List<byte>();
                        //functionCard PeripheralInfo
                        foreach (var index in funCardData.PeripheralInfoDict.Keys)
                        {
                            PeripheralMonitorBaseInfo perInfo = funCardData.PeripheralInfoDict[index];
                            if (perInfo is LightSensorMonitorInfo)
                            {
                                if (perInfo.DeviceStatus == DeviceWorkStatus.OK)
                                {
                                    tmpArr = new List<byte>(pathByteArr);
                                    tmpArr.Add((byte)(int)PhysicalType.brightness);
                                    tmpArr.Add((byte)(byte)index);
                                    LightSensorMonitorInfo lightSensorInfo = perInfo as LightSensorMonitorInfo;
                                    key = ByteToHexStrX1(new byte[] { keyByte })
                                          + "|" + ByteToHexStrX1(new byte[] { (byte)(int)PhysicalType.brightness })
                                          + "|" + ByteToHexStrX1(new byte[] { (byte)(tmpArr.Count / 2) })
                                          + "|" + ByteToHexStrX2(tmpArr.ToArray());
                                    if (terMonitorData.ContainsKey(key)) continue;
                                    terMonitorData.Add(key, lightSensorInfo.Lux);
                                }
                            }
                            else if (perInfo is TemperatureSensorMonitorInfo)
                            {
                                if (perInfo.DeviceStatus == DeviceWorkStatus.OK)
                                {
                                    tmpArr = new List<byte>(pathByteArr);
                                    tmpArr.Add((byte)(int)PhysicalType.temperature);
                                    tmpArr.Add((byte)(byte)index);
                                    TemperatureSensorMonitorInfo temSensorInfo = perInfo as TemperatureSensorMonitorInfo;
                                    key = ByteToHexStrX1(new byte[] { keyByte })
                                          + "|" + ByteToHexStrX1(new byte[] { (byte)(int)PhysicalType.temperature })
                                          + "|" + ByteToHexStrX1(new byte[] { (byte)(tmpArr.Count / 2) })
                                          + "|" + ByteToHexStrX2(tmpArr.ToArray());
                                    if (terMonitorData.ContainsKey(key)) continue;
                                    terMonitorData.Add(key, temSensorInfo.Tempearture);
                                }
                            }
                            else if (perInfo is HumiditySensorMonitorInfo)
                            {
                                if (perInfo.DeviceStatus == DeviceWorkStatus.OK)
                                {
                                    tmpArr = new List<byte>(pathByteArr);
                                    tmpArr.Add((byte)(int)PhysicalType.humidity);
                                    tmpArr.Add((byte)(byte)index);
                                    HumiditySensorMonitorInfo humiditySensorInfo = perInfo as HumiditySensorMonitorInfo;
                                    key = ByteToHexStrX1(new byte[] { keyByte })
                                          + "|" + ByteToHexStrX1(new byte[] { (byte)(int)PhysicalType.humidity })
                                          + "|" + ByteToHexStrX1(new byte[] { (byte)(tmpArr.Count / 2) })
                                          + "|" + ByteToHexStrX2(tmpArr.ToArray());
                                    if (terMonitorData.ContainsKey(key)) continue;
                                    terMonitorData.Add(key, humiditySensorInfo.Humidity);
                                }
                            }
                        }
                    }
                }
                #endregion
                #region monitor card
                keyByte = (byte)(HWDeviceType.MonitorCard);//equip type
                foreach (var monitorCardData in sData.MonitorCardInfoCollection)
                {
                    if (monitorCardData == null) continue;
                    pathByteArr.Clear();
                    for (int i = 0; i < monitorCardData.MappingList.Count; i++)
                    {
                        pathByteArr.Add((byte)(int)monitorCardData.MappingList[i].Device);
                        pathByteArr.Add((byte)monitorCardData.MappingList[i].DeviceIndex);
                    }
                    #region common data
                    tmpArr = new List<byte>(pathByteArr);
                    tmpArr.Add((byte)(int)PhysicalType.workstatus);
                    tmpArr.Add((byte)0);
                    key = ByteToHexStrX1(new byte[] { keyByte })
                                       + "|" + ByteToHexStrX1(new byte[] { (byte)(int)PhysicalType.workstatus })
                                       + "|" + ByteToHexStrX1(new byte[] { (byte)(tmpArr.Count / 2) })
                                       + "|" + ByteToHexStrX2(tmpArr.ToArray());
                    if (terMonitorData.ContainsKey(key)) continue;
                    terMonitorData.Add(key, (int)monitorCardData.DeviceStatus);

                    if (monitorCardData.DeviceStatus == DeviceWorkStatus.OK)
                    {
                        tmpArr = new List<byte>(pathByteArr);
                        tmpArr.Add((byte)(int)PhysicalType.humidity);
                        tmpArr.Add((byte)0);
                        if (monitorCardData.HumidityUInfo != null && monitorCardData.HumidityUInfo.IsUpdate)
                        {
                            key = ByteToHexStrX1(new byte[] { keyByte })
                                               + "|" + ByteToHexStrX1(new byte[] { (byte)(int)PhysicalType.humidity })
                                               + "|" + ByteToHexStrX1(new byte[] { (byte)(tmpArr.Count / 2) })
                                               + "|" + ByteToHexStrX2(tmpArr.ToArray());
                            if (terMonitorData.ContainsKey(key)) continue;
                            terMonitorData.Add(key, monitorCardData.HumidityUInfo.Humidity);
                        }
                        tmpArr = new List<byte>(pathByteArr);
                        tmpArr.Add((byte)(int)PhysicalType.doorOpenStatus);
                        tmpArr.Add((byte)0);
                        if (monitorCardData.CabinetDoorUInfo != null && monitorCardData.CabinetDoorUInfo.IsUpdate)
                        {
                            key = ByteToHexStrX1(new byte[] { keyByte })
                                               + "|" + ByteToHexStrX1(new byte[] { (byte)(int)PhysicalType.doorOpenStatus })
                                               + "|" + ByteToHexStrX1(new byte[] { (byte)(tmpArr.Count / 2) })
                                               + "|" + ByteToHexStrX2(tmpArr.ToArray());
                            if (terMonitorData.ContainsKey(key)) continue;
                            terMonitorData.Add(key, Convert.ToInt32(monitorCardData.CabinetDoorUInfo.IsDoorOpen));
                        }
                        tmpArr = new List<byte>(pathByteArr);
                        tmpArr.Add((byte)(int)PhysicalType.smoke);
                        tmpArr.Add((byte)0);
                        if (monitorCardData.SmokeUInfo != null && monitorCardData.SmokeUInfo.IsUpdate)
                        {
                            key = ByteToHexStrX1(new byte[] { keyByte })
                                               + "|" + ByteToHexStrX1(new byte[] { (byte)(int)PhysicalType.smoke })
                                               + "|" + ByteToHexStrX1(new byte[] { (byte)(tmpArr.Count / 2) })
                                               + "|" + ByteToHexStrX2(tmpArr.ToArray());
                            if (terMonitorData.ContainsKey(key)) continue;
                            terMonitorData.Add(key, Convert.ToInt32(monitorCardData.SmokeUInfo.IsSmokeAlarm));
                        }
                        tmpArr = new List<byte>(pathByteArr);
                        tmpArr.Add((byte)(int)PhysicalType.temperature);
                        tmpArr.Add((byte)0);
                        if (monitorCardData.TemperatureUInfo != null && monitorCardData.TemperatureUInfo.IsUpdate)
                        {
                            key = ByteToHexStrX1(new byte[] { keyByte })
                                               + "|" + ByteToHexStrX1(new byte[] { (byte)(int)PhysicalType.temperature })
                                               + "|" + ByteToHexStrX1(new byte[] { (byte)(tmpArr.Count / 2) })
                                               + "|" + ByteToHexStrX2(tmpArr.ToArray());
                            if (terMonitorData.ContainsKey(key)) continue;
                            terMonitorData.Add(key, monitorCardData.TemperatureUInfo.Temperature);
                        }
                        tmpArr = new List<byte>(pathByteArr);
                        tmpArr.Add((byte)(int)PhysicalType.SocketCableStatus);
                        tmpArr.Add((byte)0);
                        if (monitorCardData.SocketCableUInfo != null)
                        {
                            WorkStatusType socketCableStatus = IsSocketCableStatusOK(monitorCardData);
                            if (socketCableStatus != WorkStatusType.Unknown)
                            {
                                key = ByteToHexStrX1(new byte[] { keyByte })
                                                   + "|" + ByteToHexStrX1(new byte[] { (byte)(int)PhysicalType.SocketCableStatus })
                                                   + "|" + ByteToHexStrX1(new byte[] { (byte)(tmpArr.Count / 2) })
                                                   + "|" + ByteToHexStrX2(tmpArr.ToArray());
                                if (terMonitorData.ContainsKey(key)) continue;
                                terMonitorData.Add(key, (int)socketCableStatus);
                            }
                        }
                    #endregion
                        #region list data
                        //monitorCard voltage
                        if (monitorCardData.PowerUInfo != null && monitorCardData.PowerUInfo.IsUpdate)
                        {
                            foreach (var monitorPower in monitorCardData.PowerUInfo.PowerMonitorInfoCollection)
                            {
                                tmpArr = new List<byte>(pathByteArr);
                                tmpArr.Add((byte)(int)PhysicalType.voltage);
                                tmpArr.Add((byte)monitorPower.Key);
                                key = ByteToHexStrX1(new byte[] { keyByte })
                                                   + "|" + ByteToHexStrX1(new byte[] { (byte)(int)PhysicalType.voltage })
                                                   + "|" + ByteToHexStrX1(new byte[] { (byte)(tmpArr.Count / 2) })
                                                   + "|" + ByteToHexStrX2(tmpArr.ToArray());
                                if (terMonitorData.ContainsKey(key)) continue;
                                terMonitorData.Add(key, monitorPower.Value);
                            }
                        }
                        //monitorCard Fan
                        if (monitorCardData.FansUInfo != null && monitorCardData.FansUInfo.IsUpdate)
                        {
                            foreach (var monitorFan in monitorCardData.FansUInfo.FansMonitorInfoCollection)
                            {
                                tmpArr = new List<byte>(pathByteArr);
                                tmpArr.Add((byte)(int)PhysicalType.fanspeed);
                                tmpArr.Add((byte)monitorFan.Key);
                                key = ByteToHexStrX1(new byte[] { keyByte })
                                                   + "|" + ByteToHexStrX1(new byte[] { (byte)(int)PhysicalType.fanspeed })
                                                   + "|" + ByteToHexStrX1(new byte[] { (byte)(tmpArr.Count / 2) })
                                                   + "|" + ByteToHexStrX2(tmpArr.ToArray());
                                if (terMonitorData.ContainsKey(key)) continue;
                                terMonitorData.Add(key, monitorFan.Value);
                            }
                        }
                        //monitorCard SocketCable
                        //if (monitorCardData.SocketCableUInfo.IsUpdate)
                        //{
                        //    foreach (var socketcableInfo in monitorCardData.SocketCableUInfo.SocketCableInfoCollection)
                        //    {
                        //        if (socketcableInfo.DeviceStatus == DeviceWorkStatus.OK) continue;
                        //        socketcableInfo.SocketCableInfoDict
                        //    }
                        //}
                        #endregion
                    }
                }
                #endregion
                if (!allScreenMonitorData.ContainsKey(sData.ScreenUDID))
                    allScreenMonitorData.Add(sData.ScreenUDID, terMonitorData);
            }
            return true;
        }
예제 #2
0
        private void ReadMonitorData(IAsyncResult result)
        {
            lock (_objLock)
            {
                ReadMonitorDataErrType res = _moniDatareader.BeginReadData(new CompletedMonitorCallback(
                        (cmpParams, userToken) =>
                        {
                            if (cmpParams != null)
                            {
                                string cmpStr = CommandTextParser.GetJsonSerialization<CompletedMonitorCallbackParams>(cmpParams);
                                _cmpParams = CommandTextParser.GetDeJsonSerialization<CompletedMonitorCallbackParams>(cmpStr);
                            }
                            ReadDataCallback(_cmpParams, userToken);
                        }), DataType.all);

                if (res == ReadMonitorDataErrType.NoServerObj)
                {
                    //取消重新读取,直接提示用户
                    //_fLogService.Error("服务没有注册,需重新注册...");
                    //AsyncRestartDataReader(false);
                    //UpdateConfigMessage(TransferType.M3_UpdateLedScreenConfigInfo, string.Empty);
                    Interlocked.Exchange(ref _isReadingMonitorData, 0);
                    return;
                }
                else if (res != ReadMonitorDataErrType.OK)
                {
                    State = DataSourceState.Error;
                    SendData("M3_StateData", res.ToString());
                    MonitorException = new Exception(res.ToString()) { Source = "M3_MonitorData" };
                    if (res != ReadMonitorDataErrType.BusyWorking)
                    {
                        _fLogService.Debug("ReadMonitorData BusyWorking释放");
                        Interlocked.Exchange(ref _isReadingMonitorData, 0);
                    }
                }
            }
        }
        private CompletedMonitorCallbackParams GetCompletedMonitorCallbackParams()
        {
            CompletedMonitorCallbackParams param = new CompletedMonitorCallbackParams();

            AllMonitorData monitorData = new AllMonitorData();
            param.MonitorData = monitorData;

            int createScreenCount = 3;
            int senderCount = 2;
            int scannerCount = 2;
            int fansCount = 2;
            int powerCount = 2;
            int cableCount = 1;
            int functionCount = 2;
            int peripheralCount = 2;
            int comFunctionCount = 2;
            const int deconcentratorCount = 1;
            for (int scrIndex = 0; scrIndex < createScreenCount; scrIndex++)
            {
                string scrUDID = "1306280000015920-" + scrIndex.ToString("X2");
                ScreenModnitorData scrMonitorData = new ScreenModnitorData(scrUDID);

                for (int senderIndex = 0; senderIndex < senderCount; senderIndex++)
                {
            #region 添加发送卡数据
                    SendStatusMsg("StartReadDVIData" + senderIndex);
                    SenderMonitorInfo sendInfo = new SenderMonitorInfo();
                    sendInfo.DeviceStatus = DeviceWorkStatus.OK;
                    sendInfo.MappingList.Add(new DeviceSearchMapping(HWDeviceType.Sender, senderIndex));

                    sendInfo.IsDviConnected = true;
                    sendInfo.DviRate = 60;
                    sendInfo.ReduPortIndexCollection.Add(new PortOfSenderMonitorInfo());
                    sendInfo.ReduPortIndexCollection.Add(new PortOfSenderMonitorInfo());
                    scrMonitorData.SenderMonitorCollection.Add(sendInfo);
                    SendStatusMsg("FinishReadDVIData" + senderIndex);
            #endregion

            #region 分线器数据
                    scrMonitorData.DeconcentratorCollection = new List<DeconcentratorMonitorInfo>();
                    for (int deconcentratoIndex = 0; deconcentratoIndex < deconcentratorCount; deconcentratoIndex++)
                    {
                        SendStatusMsg("Start分线器数据Data" + deconcentratoIndex);
                        DeconcentratorMonitorInfo deconcentratorInfo = new DeconcentratorMonitorInfo();
                        deconcentratorInfo.DeviceStatus = DeviceWorkStatus.OK;
                        deconcentratorInfo.MappingList.Add(new DeviceSearchMapping(HWDeviceType.Sender, senderIndex));
                        if (deconcentratoIndex < 1)
                            deconcentratorInfo.MappingList.Add(new DeviceSearchMapping(HWDeviceType.PortOfSender, 0));
                        else
                            deconcentratorInfo.MappingList.Add(new DeviceSearchMapping(HWDeviceType.PortOfSender, 1));
                        scrMonitorData.DeconcentratorCollection.Add(deconcentratorInfo);
                        SendStatusMsg("End分线器数据Data" + deconcentratoIndex);
                    }
            #endregion
                    for (int scannerIndex = 0; scannerIndex < scannerCount; scannerIndex++)
                    {
            #region 添加接收卡数据
                        SendStatusMsg("Start接收卡数据Data" + scannerIndex);
                        ScannerMonitorInfo scannerInfo = new ScannerMonitorInfo();
                        scannerInfo.DeviceStatus = DeviceWorkStatus.OK;

                        scannerInfo.MappingList.Add(new DeviceSearchMapping(HWDeviceType.Sender, senderIndex));
                        if (scannerIndex < 50)
                        {
                            scannerInfo.MappingList.Add(new DeviceSearchMapping(HWDeviceType.PortOfSender, 0));
                        }
                        else
                        {
                            scannerInfo.MappingList.Add(new DeviceSearchMapping(HWDeviceType.PortOfSender, 1));
                        }
                        scannerInfo.MappingList.Add(new DeviceSearchMapping(HWDeviceType.Scanner, scannerIndex));

                        scannerInfo.Temperature = 25.5f;
                        scannerInfo.Voltage = 5.5f;
                        scrMonitorData.ScannerMonitorCollection.Add(scannerInfo);
                        SendStatusMsg("End接收卡数据Data" + scannerIndex);
            #endregion

            #region 添加监控卡数据
                        //MonitorCardMonitorInfo
                        SendStatusMsg("Start监控卡数据Data" + scannerIndex);
                        MonitorCardMonitorInfo monitorCardInfo = new MonitorCardMonitorInfo();
                        monitorCardInfo.DeviceStatus = DeviceWorkStatus.OK;

                        monitorCardInfo.MappingList.Add(new DeviceSearchMapping(HWDeviceType.Sender, senderIndex));
                        if (scannerIndex < 50)
                        {
                            monitorCardInfo.MappingList.Add(new DeviceSearchMapping(HWDeviceType.PortOfSender, 0));
                        }
                        else
                        {
                            monitorCardInfo.MappingList.Add(new DeviceSearchMapping(HWDeviceType.PortOfSender, 1));
                        }
                        monitorCardInfo.MappingList.Add(new DeviceSearchMapping(HWDeviceType.Scanner, scannerIndex));
                        monitorCardInfo.MappingList.Add(new DeviceSearchMapping(HWDeviceType.MonitorCard, 0));

                        monitorCardInfo.TemperatureUInfo = new MCTemperatureUpdateInfo() { IsUpdate = true, Temperature = 20.5f };
                        monitorCardInfo.HumidityUInfo = new MCHumidityUpdateInfo() { IsUpdate = true, Humidity = 80.5f };
                        monitorCardInfo.SmokeUInfo = new MCSmokeUpdateInfo() { IsUpdate = true, IsSmokeAlarm = false };
                        monitorCardInfo.CabinetDoorUInfo = new MCDoorUpdateInfo() { IsUpdate = true, IsDoorOpen = true };

                        SendStatusMsg("End监控卡数据Data" + scannerIndex);
            #region 风扇数据
                        SendStatusMsg("Start风扇数据Data" + scannerIndex);
                        MCFansUpdateInfo mcFansUpdateInfo = new MCFansUpdateInfo();
                        mcFansUpdateInfo.IsUpdate = true;
                        mcFansUpdateInfo.FansMonitorInfoCollection = new SerializableDictionary<int, int>();
                        for (int fansIndex = 0; fansIndex < fansCount; fansIndex++)
                        {
                            int speed = 3000;
                            if (scannerIndex < 50)
                            {
                                speed = 3500;
                            }
                            mcFansUpdateInfo.FansMonitorInfoCollection.Add(fansIndex, speed);
                        }
                        monitorCardInfo.FansUInfo = mcFansUpdateInfo;
                        SendStatusMsg("End风扇数据Data" + scannerIndex);
            #endregion

            #region 电源数据
                        SendStatusMsg("Start电源数据Data" + scannerIndex);
                        MCPowerUpdateInfo mcPowerUInfo = new MCPowerUpdateInfo();
                        mcPowerUInfo.IsUpdate = true;
                        mcPowerUInfo.PowerMonitorInfoCollection = new SerializableDictionary<int,float>();
                        for (int pwoerIndex = 0; pwoerIndex < powerCount; pwoerIndex++)
                        {
                            float power = 5.0f;
                            if (scannerIndex < 50)
                            {
                                power = 4.5f;
                            }

                            mcPowerUInfo.PowerMonitorInfoCollection.Add(pwoerIndex, power);
                        }
                        monitorCardInfo.PowerUInfo = mcPowerUInfo;
                        SendStatusMsg("End电源数据Data" + scannerIndex);
            #endregion

            #region 排线数据
                        SendStatusMsg("Start排线数据Data" + scannerIndex);
                        List<SocketCableMonitorInfo> socketCableInfoCollection = new List<SocketCableMonitorInfo>();
                        for (int cableIndex = 0; cableIndex < cableCount; cableIndex++)
                        {
                            SocketCableMonitorInfo cableInfo = new SocketCableMonitorInfo();
                            cableInfo.DeviceStatus = DeviceWorkStatus.OK;

                            cableInfo.MappingList.Add(new DeviceSearchMapping(HWDeviceType.Sender, senderIndex));
                            if (scannerIndex < 50)
                            {
                                cableInfo.MappingList.Add(new DeviceSearchMapping(HWDeviceType.PortOfSender, 0));
                            }
                            else
                            {
                                cableInfo.MappingList.Add(new DeviceSearchMapping(HWDeviceType.PortOfSender, 1));
                            }
                            cableInfo.MappingList.Add(new DeviceSearchMapping(HWDeviceType.Scanner, scannerIndex));
                            cableInfo.MappingList.Add(new DeviceSearchMapping(HWDeviceType.MonitorCard, 0));
                            cableInfo.MappingList.Add(new DeviceSearchMapping(HWDeviceType.SocketOfMonitorCard, cableIndex));
                            for (int groupIndex = 0; groupIndex < 8; groupIndex++)
                            {
                                List<SocketCableStatus> oneGroupStatusList = new List<SocketCableStatus>();
                                SocketCableStatus cableStatus = new SocketCableStatus();
                                cableStatus.CableType = SocketCableType.ABCD_Signal;
                                cableStatus.IsCableOK = true;
                                oneGroupStatusList.Add(cableStatus);

                                cableStatus = new SocketCableStatus();
                                cableStatus.CableType = SocketCableType.CTRL_Signal;
                                cableStatus.IsCableOK = true;
                                oneGroupStatusList.Add(cableStatus);

                                cableStatus = new SocketCableStatus();
                                cableStatus.CableType = SocketCableType.DCLK_Signal;
                                cableStatus.IsCableOK = true;
                                oneGroupStatusList.Add(cableStatus);

                                cableStatus = new SocketCableStatus();
                                cableStatus.CableType = SocketCableType.LAT_Signal;
                                cableStatus.IsCableOK = true;
                                oneGroupStatusList.Add(cableStatus);

                                cableStatus = new SocketCableStatus();
                                cableStatus.CableType = SocketCableType.OE_Signal;
                                cableStatus.IsCableOK = false;
                                oneGroupStatusList.Add(cableStatus);

                                cableStatus = new SocketCableStatus();
                                cableStatus.CableType = SocketCableType.Red_Signal;
                                cableStatus.IsCableOK = false;
                                oneGroupStatusList.Add(cableStatus);

                                cableStatus = new SocketCableStatus();
                                cableStatus.CableType = SocketCableType.Green_Signal;
                                cableStatus.IsCableOK = false;
                                oneGroupStatusList.Add(cableStatus);

                                cableStatus = new SocketCableStatus();
                                cableStatus.CableType = SocketCableType.Blue_Signal;
                                cableStatus.IsCableOK = false;
                                oneGroupStatusList.Add(cableStatus);

                                cableStatus = new SocketCableStatus();
                                cableStatus.CableType = SocketCableType.VRed_Signal;
                                cableStatus.IsCableOK = false;
                                oneGroupStatusList.Add(cableStatus);

                                cableInfo.SocketCableInfoDict.Add(groupIndex, oneGroupStatusList);

                            }
                            socketCableInfoCollection.Add(cableInfo);
                            monitorCardInfo.SocketCableUInfo = new MCSocketCableUpdateInfo() { IsUpdate = true, SocketCableInfoCollection = socketCableInfoCollection };
                        }
                        SendStatusMsg("End排线数据Data" + scannerIndex);
            #endregion

                        scrMonitorData.MonitorCardInfoCollection.Add(monitorCardInfo);
            #endregion
                    }

                    for (int functionIndex = 0; functionIndex < functionCount; functionIndex++)
                    {
                        SendStatusMsg("Start多功能卡数据Data" + functionIndex);
            #region 添加网口上的多功能卡
                        FunctionCardMonitorInfo functionInfo = new FunctionCardMonitorInfo();
                        functionInfo.PeripheralInfoDict = new SerializableDictionary<int, PeripheralMonitorBaseInfo>();
                        functionInfo.DeviceStatus = DeviceWorkStatus.OK;

                        functionInfo.MappingList.Add(new DeviceSearchMapping(HWDeviceType.Sender, senderIndex));
                        functionInfo.MappingList.Add(new DeviceSearchMapping(HWDeviceType.PortOfSender, 1));
                        functionInfo.MappingList.Add(new DeviceSearchMapping(HWDeviceType.FunctionCard, functionIndex));

                        for (int sensorIndex = 0; sensorIndex < peripheralCount; sensorIndex++)
                        {
                            PeripheralMonitorBaseInfo sensorInfo;
                            if (sensorIndex <= 2)
                            {
                                sensorInfo = new LightSensorMonitorInfo() { DeviceStatus = DeviceWorkStatus.OK, Lux = 280 };
                            }
                            else
                            {
                                sensorInfo = new TemperatureSensorMonitorInfo() { DeviceStatus = DeviceWorkStatus.OK, Tempearture = 18.5f };
                            }
                            functionInfo.PeripheralInfoDict.Add(sensorIndex, sensorInfo);
                        }
                        SendStatusMsg("End多功能卡数据Data" + functionIndex);
                        scrMonitorData.FunctionCardInfoCollection.Add(functionInfo);
            #endregion
                    }

                }
                monitorData.AllScreenMonitorCollection.Add(scrMonitorData);
            }

            //for (int comFuncIndex = 0; comFuncIndex < comFunctionCount; comFuncIndex++ )
            //{
            //    #region 添加串口上的多功能卡
            //    FunctionCardMonitorInfo functionInfo = new FunctionCardMonitorInfo();
            //    functionInfo.DeviceStatus = DeviceWorkStatus.OK;

            //    functionInfo.MappingList.Add(new DeviceSearchMapping(HWDeviceType.FunctionCard, comFuncIndex));

            //    for (int sensorIndex = 0; sensorIndex < sensorCount; sensorIndex++)
            //    {
            //        LightSensorMonitorInfo sensorInfo = new LightSensorMonitorInfo();
            //        sensorInfo.MappingList.Add(new DeviceSearchMapping(HWDeviceType.FunctionCard, comFuncIndex));
            //        sensorInfo.MappingList.Add(new DeviceSearchMapping(HWDeviceType.LightSensor, 0));

            //        sensorInfo.Birghtness = 2600;
            //        functionInfo.LightSensorInfoDict.Add(sensorIndex, sensorInfo);
            //    }
            //    #endregion
            //}

            return param;
        }
예제 #4
0
        //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);
            }
        }
 private void NotifyCompleteAllMonitor()
 {
     _fLogService.Info("开始通知数据采集完成");
     if (_readHWParams != null && _readHWParams.CallBack != null)
     {
         _stopwatch.Stop();
         CompletedMonitorCallbackParams param = new CompletedMonitorCallbackParams()
         {
             MonitorData = _allMonitorData
         };
         Interlocked.Exchange(ref _isRunningMetux, 0);
         _readHWParams.CallBack.Invoke(param, _readHWParams.UserToken);
     }
     _fLogService.Info("完成通知数据采集完成,开始检查配置文件是否更新..." + _stopwatch.ElapsedMilliseconds);
     lock (_notifyLocker)
     {
         if (_isNeedNotifyScreenCfgChanged)
         {
             _fLogService.Info("通知外部显示屏配置更新");
             _isNeedNotifyScreenCfgChanged = false;
             OnNotifyScreenCfgChangedEvent(this, EventArgs.Empty);
             _fLogService.Info("完成通知外部显示屏配置更新");
         }
     }
     OnNotifyExecResEvent(TransferType.M3_RefreshDataFinish, string.Empty, UpdateCfgFileResType.OK);
 }