public string Generate_EDC()
        {
            string _strresult = string.Empty;


            foreach (cls_EDC_Body_Item key in _lst_EDC_Body_Item)
            {
                if (key.orig_item_type == "ASC" || key.orig_item_type == "BIT")
                {
                    cls_EDC_Body_Item EDC_Interval_Func = new cls_EDC_Body_Item();
                    EDC_Interval_Func.item_name  = key.item_name;
                    EDC_Interval_Func.item_type  = key.item_type;
                    EDC_Interval_Func.item_value = key.item_value;
                    _BaseEDCInfo.edcitem_info.Add(EDC_Interval_Func);
                }
                else if (key.orig_item_type == "DATETIME")
                {
                    DateTime          parsedDate;
                    cls_EDC_Body_Item EDC_Interval_Func = new cls_EDC_Body_Item();
                    EDC_Interval_Func.item_name = key.item_name;
                    EDC_Interval_Func.item_type = key.item_type;
                    if (DateTime.TryParse(key.item_value, out parsedDate))
                    {
                        EDC_Interval_Func.item_value = parsedDate.ToString("yyyyMMddHHmmss");
                    }
                    else
                    {
                        EDC_Interval_Func.item_value = "999999";
                    }
                    _BaseEDCInfo.edcitem_info.Add(EDC_Interval_Func);
                }
                else
                {
                    IEnumerable <cls_EDC_Body_Item> selectManyQuery = _EDCHisInfo.SelectMany(o => o.ToList());
                    List <cls_EDC_Body_Item>        EDC_BodyItems   = selectManyQuery.Where(o => o.item_name.Equals(key.item_name)).ToList();
                    List <double> Item1Value = EDC_BodyItems.Select(o => Convert.ToDouble(o.item_value)).ToList();
                    foreach (string founction in _BaseEDCInfo.interval_function)
                    {
                        cls_EDC_Body_Item EDC_Interval_Func = new cls_EDC_Body_Item();
                        EDC_Interval_Func.item_name = string.Concat(key.item_name, "_", founction);
                        EDC_Interval_Func.item_type = "X";
                        switch (founction)
                        {
                        case "MAX":
                            EDC_Interval_Func.item_value = Item1Value.Max().ToString();
                            _BaseEDCInfo.edcitem_info.Add(EDC_Interval_Func);
                            break;

                        case "MIN":
                            EDC_Interval_Func.item_value = Item1Value.Min().ToString();
                            _BaseEDCInfo.edcitem_info.Add(EDC_Interval_Func);
                            break;

                        case "AVG":
                            EDC_Interval_Func.item_value = Item1Value.Average().ToString();
                            _BaseEDCInfo.edcitem_info.Add(EDC_Interval_Func);
                            break;

                        default:

                            break;
                        }
                    }
                }
            }
            _strresult = _BaseEDCInfo.xml_string();
            _EDCHisInfo.Clear();
            return(_strresult);
        }
        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);
            }
        }