Ejemplo n.º 1
0
        public void Handle_Interval_EDC(EDCPartaker input)
        {
            string serial_id = input.serial_id;
            List <cls_EDC_Body_Item> temp_EDC_Body = new List <cls_EDC_Body_Item>(input.edcitem_info.ToArray());
            EDC_Interval_Partaker    EDCInterval   = _dic_Interval_EDC.GetOrAdd(serial_id, new EDC_Interval_Partaker(input));

            EDCInterval.Add_EDC2Queue(temp_EDC_Body);
            _dic_Interval_EDC.AddOrUpdate(serial_id, EDCInterval, (key, oldvalue) => EDCInterval);
        }
        public EDC_Interval_Partaker(EDCPartaker BaseEDCInfo)
        {
            _InitialDatatime   = DateTime.Now;
            report_interval    = BaseEDCInfo.report_interval;
            _BaseEDCInfo       = (EDCPartaker)BaseEDCInfo.Clone();
            _EDCHisInfo        = new List <List <cls_EDC_Body_Item> >();
            _lst_EDC_Body_Item = new List <cls_EDC_Body_Item>(_BaseEDCInfo.edcitem_info.ToArray());

            // Export Clear 原始的  如果不清除就是保留最新的一份;
            _BaseEDCInfo.edcitem_info.Clear();
        }
Ejemplo n.º 3
0
 public ProcEDCData(string inputdata, IOTEDCService.Put_Write_Event _delegate_Method, IOTEDCService.Handle_Interval_Event _delegate_Interval_Event)
 {
     try
     {
         this.objEDC     = JsonConvert.DeserializeObject <EDCPartaker>(inputdata.ToString());
         _Put_Write      = _delegate_Method;
         _Interval_Event = _delegate_Interval_Event;
     }
     catch
     {
         this.objEDC = null;
     }
 }
Ejemplo n.º 4
0
        public void Organize_EDCPartaker(string GateWayID, string Device_ID)
        {
            //--- 等待EDC List information

            if (_objectmanager.EDCManager == null)
            {
                return;
            }

            List <ObjectManager.cls_EDC_Info> lst_EDCInfo = _objectmanager.EDCManager.gateway_edc.Where(p => p.gateway_id == GateWayID && p.device_id == Device_ID && p.enable == true).ToList();

            foreach (cls_EDC_Info _EDC in lst_EDCInfo)
            {
                EDCPartaker EDCReporter = new EDCPartaker(_EDC);
                EDCReporter.timestapm = DateTime.Now;

                cls_Gateway_Info gateway = _objectmanager.GatewayManager.gateway_list.Where(p => p.gateway_id == GateWayID).FirstOrDefault();
                if (gateway != null)
                {
                    cls_Device_Info device = gateway.device_info.Where(p => p.device_name == Device_ID).FirstOrDefault();
                    if (device != null)
                    {
                        // Assembly Normal Tag info
                        foreach (Tuple <string, string> _Items in _EDC.tag_info)
                        {
                            cls_EDC_Body_Item edcitem = new cls_EDC_Body_Item();
                            edcitem.item_name = _Items.Item1;
                            edcitem.item_type = "X";

                            if (device.tag_info.ContainsKey(_Items.Item2))
                            {
                                edcitem.item_value     = device.tag_info[_Items.Item2].Value;
                                edcitem.orig_item_type = device.tag_info[_Items.Item2].Expression;
                            }
                            else
                            {
                                edcitem.item_value = string.Empty;
                            }

                            EDCReporter.edcitem_info.Add(edcitem);
                        }

                        // Assembly Calc Tag info
                        foreach (Tuple <string, string> _Items in _EDC.calc_tag_info)
                        {
                            cls_EDC_Body_Item edcitem = new cls_EDC_Body_Item();
                            edcitem.item_name = _Items.Item1;
                            edcitem.item_type = "X";

                            if (device.calc_tag_info.ContainsKey(_Items.Item2))
                            {
                                edcitem.item_value     = device.calc_tag_info[_Items.Item2].Value;
                                edcitem.orig_item_type = "DOUBLE";
                            }
                            else
                            {
                                edcitem.item_value = string.Empty;
                            }

                            EDCReporter.edcitem_info.Add(edcitem);
                        }
                    }
                }

                //----- Send MQTT-----
                xmlMessage SendOutMsg = new xmlMessage();
                SendOutMsg.GatewayID   = GateWayID; // GateID
                SendOutMsg.DeviceID    = Device_ID; // DeviceID
                SendOutMsg.MQTTTopic   = "EDCService";
                SendOutMsg.MQTTPayload = JsonConvert.SerializeObject(EDCReporter, Newtonsoft.Json.Formatting.Indented);
                _QueueManager.PutMessage(SendOutMsg);
            }
        }