Ejemplo n.º 1
0
 public object doOperator()
 {
     try
     {
         tSetWsSnParam      wsSNParam = new tSetWsSnParam();
         SetSNCodeTaskModel model     = (snCodeModel as SetSNCodeTaskModel);
         foreach (SetSNCode snCode in model.snCodeList)
         {
             iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), "开始下发WS的SN串码 :" + snCode.MAC);
             wsSNParam.sn  = snCode.sn;
             wsSNParam.mac = new tMAC(snCode.MAC);
             //向底层发送信息
             if (!iCMS.WG.Agent.ComFunction.Send2WS(wsSNParam, Common.Enum.EnumRequestWSType.SetWsSn))
             {
                 CommunicationWithServer communication2Server = new CommunicationWithServer();
                 communication2Server.UploadConfigResponse(snCode.MAC, Enum_ConfigType.ConfigType_WS_SNCode, 1, "网络正忙下发SN串码失败,退出对该WS的SN串码设置");
                 iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), snCode.MAC + ":网络正忙下发SN串码失败,退出对该WS的SN串码设置");
             }
             else
             {
                 lock (iCMS.WG.Agent.ComFunction.setSNCodeList)
                 {
                     iCMS.WG.Agent.ComFunction.setSNCodeList.Add(snCode);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         iCMS.WG.Agent.Common.LogHelper.WriteLog(ex);
     }
     return("SNCodeOper");
 }
        //触发式上传配置的超时处理
        private void CheckSetTriggerDefTimeOut(object state)
        {
            try
            {
                int index = iCMS.WG.Agent.ComFunction.GetIndexOfSendTriggerDefineList((string)state);
                if (index < 0)
                {
                    return;
                }
                string mac = iCMS.WG.Agent.ComFunction.sendTriggerDefineList[index].MAC.ToUpper();
                iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), mac + "下发触发式配置超时WS返回结果: 4");
                CommunicationWithServer communication2Server = new CommunicationWithServer();
                communication2Server.UploadConfigResponse(mac, Enum_ConfigType.ConfigType_TriggerDefine, Convert.ToInt32(EnmuReceiveStatus.Faild), "下发触发式配置失败!");
                iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), mac + "上传触发式配置下发失败");


                lock (iCMS.WG.Agent.ComFunction.sendTriggerDefineList)
                {
                    index = iCMS.WG.Agent.ComFunction.GetIndexOfSendTriggerDefineList((string)state);
                    if (iCMS.WG.Agent.ComFunction.sendTriggerDefineList[index].time != null)
                    {
                        iCMS.WG.Agent.ComFunction.sendTriggerDefineList[index].time.Dispose();
                    }
                    iCMS.WG.Agent.ComFunction.sendTriggerDefineList.RemoveAt(index);
                }
            }
            catch
            {
            }
        }
Ejemplo n.º 3
0
        public object doOperator()
        {
            try
            {
                tSetNetworkIdParam    networkIDParam = new tSetNetworkIdParam();
                SetNetworkIDTaskModel model          = (newNetworkIDModel as SetNetworkIDTaskModel);
                foreach (SetNetworkID networkID in model.networkIDList)
                {
                    iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), "开始更新WS的NetworkID :" + networkID.MAC);
                    networkIDParam.u16ID = networkID.NewNetWorkID;
                    networkIDParam.mac   = new tMAC(networkID.MAC);

                    //向底层发送信息
                    if (!iCMS.WG.Agent.ComFunction.Send2WS(networkIDParam, Common.Enum.EnumRequestWSType.SetNetworkID))
                    {
                        CommunicationWithServer communication2Server = new CommunicationWithServer();
                        communication2Server.UploadConfigResponse(networkID.MAC, Enum_ConfigType.ConfigType_WS_NetID, 1, "网络正忙下发NetworkID失败,退出对该WS的NetworkID更新");
                        iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), networkID.MAC + ":网络正忙下发NetworkID失败,退出对该WS的NetworkID更新");
                    }
                    else
                    {
                        lock (iCMS.WG.Agent.ComFunction.setNetworkIDList)
                        {
                            iCMS.WG.Agent.ComFunction.setNetworkIDList.Add(networkID);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                iCMS.WG.Agent.Common.LogHelper.WriteLog(ex);
            }
            return("SetNetworkIDOper");
        }
Ejemplo n.º 4
0
 public object doOperator()
 {
     try
     {
         tCaliSensorParam         caliSensorParam = new tCaliSensorParam();
         CalibrateSensorTaskModel model           = (calibrateSensorModel as CalibrateSensorTaskModel);
         foreach (CheckMonitor checkMonitor in model.checkMonitorList)
         {
             iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), "开始传感器校准 :" + checkMonitor.MAC);
             caliSensorParam.mac = new tMAC(checkMonitor.MAC);
             //向底层发送信息
             if (!iCMS.WG.Agent.ComFunction.Send2WS(caliSensorParam, Common.Enum.EnumRequestWSType.CalibrateWsSensor))
             {
                 CommunicationWithServer communication2Server = new CommunicationWithServer();
                 communication2Server.UploadConfigResponse(checkMonitor.MAC.ToUpper(), Enum_ConfigType.ConfigType_UpdateFirmware, 1, "网络正忙传感器校准失败,退出对该WS的传感器校准");
                 iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), checkMonitor.MAC + ":网络正忙传感器校准失败,退出对该WS的传感器校准");
             }
             else
             {
                 lock (iCMS.WG.Agent.ComFunction.checkMonitorList)
                 {
                     iCMS.WG.Agent.ComFunction.checkMonitorList.Add(checkMonitor);
                 }
             }
             System.Threading.Thread.Sleep(100);
         }
     }
     catch (Exception ex)
     {
         iCMS.WG.Agent.Common.LogHelper.WriteLog(ex);
     }
     return("CalibrateSensorOper");
 }
Ejemplo n.º 5
0
        public object doOperator()
        {
            RestoreWGModel.macList.ForEach(obj =>
            {
                object objdata = null;

                if (!iCMS.WG.Agent.ComFunction.Send2WS(objdata, Common.Enum.EnumRequestWSType.RestoreWG))
                {
                    CommunicationWithServer communication2Server = new CommunicationWithServer();
                    communication2Server.UploadConfigResponse(obj.ToString(), Enum_ConfigType.ConfigType_RestoreWG, 1, "网络正忙恢复WG出厂设置失败。");
                    iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), obj.ToString() + ":网络正忙恢复WG出厂设置失败");
                }
            });
            return("RestoreWG");
        }
Ejemplo n.º 6
0
        public object doOperator()
        {
            tGetWsSnParam getWsSNPara = new tGetWsSnParam()
            {
                mac = new tMAC(getSNCodeModel.Mac)
            };

            if (!iCMS.WG.Agent.ComFunction.Send2WS(getWsSNPara, Common.Enum.EnumRequestWSType.GetWsSn))
            {
                CommunicationWithServer communication2Server = new CommunicationWithServer();
                communication2Server.UploadConfigResponse(getSNCodeModel.Mac.ToString().ToUpper(), Enum_ConfigType.ConfigType_WS_Get_SNCode, 1, "网络正忙获取SN失败。");
                iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), getSNCodeModel.Mac.ToString() + ":网络正忙获取SN失败。");
            }

            return("GetSNCodeOper");
        }
 private void GetNetWorkIDFromManager()
 {
     System.Threading.Tasks.Task.Run(() =>
     {
         try
         {
             string netID = ((int)iCMS.WG.Agent.ComFunction.meshAdapter.GetNetworkId()).ToString();
             CommunicationWithServer communication2Server = new CommunicationWithServer();
             communication2Server.UploadWGNetWorkIDStatus(iCMS.WG.Agent.ComFunction.GetAppConfig("WGID").ToString(), netID);
             iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Log.ToString(), "WG NetWorkID " + netID);
         }
         catch (Exception ex)
         {
             iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Error.ToString(), ex.Message + "\r\n" + ex.StackTrace);
         }
     });
 }
Ejemplo n.º 8
0
        public object doOperator()
        {
            reSetWSModel.macList.ForEach(obj =>
            {
                tResetWSParam reSetWSParam = new tResetWSParam()
                {
                    mac    = new tMAC(obj.ToString()),
                    u8Mote = 0x01,
                    u8MCU  = 0x01
                };
                if (!iCMS.WG.Agent.ComFunction.Send2WS(reSetWSParam, Common.Enum.EnumRequestWSType.ResetWS))
                {
                    CommunicationWithServer communication2Server = new CommunicationWithServer();
                    communication2Server.UploadConfigResponse(obj.ToString(), Enum_ConfigType.ConfigType_ReSetWS, 1, "网络正忙重启WS失败。");
                    iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), obj.ToString() + ":网络正忙重启WS失败");
                }
            });

            return("ResetWS");
        }
Ejemplo n.º 9
0
        public object doOperator()
        {
            ///初始化WS/WG状态列表
            try
            {
                iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Log.ToString(), "重新初始化Agent环境变量开始...");
                iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Log.ToString(), "开始与Server通讯");
                iCMS.WG.Agent.ComFunction.InitDeviceStatusFromServer();
                iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Log.ToString(), "与Server通讯完成");
                iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Log.ToString(), "开始与网关通讯");
                iCMS.WG.Agent.ComFunction.meshAdapter.QueryAllWs();
                string netID = ((int)iCMS.WG.Agent.ComFunction.meshAdapter.GetNetworkId()).ToString();
                iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Log.ToString(), "与网关通讯完成,获取NetID:" + netID);

                CommunicationWithServer communication2Server = new CommunicationWithServer();
                communication2Server.UploadWGNetWorkIDStatus(iCMS.WG.Agent.ComFunction.GetAppConfig("WGID").ToString(), netID);
                iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Log.ToString(), "重新初始化Agent环境变量完成!");
            }
            catch
            { }


            return("ReSetAgentOper");
        }
        public object doOperator()
        {
            try
            {
                ConfigTriggerDefineTaskModel model = (configModel as ConfigTriggerDefineTaskModel);
                foreach (SendTriggerDefine TriggerDefine in model.triggerDefineList)
                {
                    iMesh.tSetTrigParam setTriggerDefParam = new iMesh.tSetTrigParam();
                    iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), "开始下发WS的触发式配置 :" + TriggerDefine.MAC);
                    setTriggerDefParam.mac = new iMesh.tMAC(TriggerDefine.MAC);
                    switch (TriggerDefine.bEnable)
                    {
                    case 0:
                        setTriggerDefParam.Enable = iMesh.enEnableFun.eCloseFun;
                        iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), "关闭触发功能 " + TriggerDefine.MAC);
                        break;

                    case 1:
                        setTriggerDefParam.Enable = iMesh.enEnableFun.eOpenFun;
                        iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), "开启触发功能 " + TriggerDefine.MAC);
                        break;

                    default:
                        break;
                    }
                    setTriggerDefParam.Enable = (iMesh.enEnableFun)TriggerDefine.bEnable;
                    if (TriggerDefine.ACCEnable == 1)
                    {
                        setTriggerDefParam.AccMdf.MeasDefType    = iMesh.enMeasDefType.eAccWaveform;
                        setTriggerDefParam.AccMdf.bEnable        = true;
                        setTriggerDefParam.AccMdf.u8Flag         = TriggerDefine.ACCValue;
                        setTriggerDefParam.AccMdf.fCharRmsvalue  = TriggerDefine.ACCRmsThreshold;
                        setTriggerDefParam.AccMdf.fCharPKvalue   = TriggerDefine.ACCPKThreshold;
                        setTriggerDefParam.AccMdf.fCharPKPKvalue = TriggerDefine.ACCPKPKThreshold;
                    }
                    if (TriggerDefine.ACCEnvlEnable == 1)
                    {
                        setTriggerDefParam.AccEnvMdf.MeasDefType   = iMesh.enMeasDefType.eAccEnvelope;
                        setTriggerDefParam.AccEnvMdf.bEnable       = true;
                        setTriggerDefParam.AccEnvMdf.u8Flag        = TriggerDefine.ACCEnvlValue;
                        setTriggerDefParam.AccEnvMdf.fCharPKvalue  = TriggerDefine.ACCEnvlPKThreshold;
                        setTriggerDefParam.AccEnvMdf.fCharPKCvalue = TriggerDefine.ACCEnvlPKCThreshold;
                    }
                    if (TriggerDefine.VelEnable == 1)
                    {
                        setTriggerDefParam.VelMdf.MeasDefType    = iMesh.enMeasDefType.eVelWaveform;
                        setTriggerDefParam.VelMdf.bEnable        = true;
                        setTriggerDefParam.VelMdf.u8Flag         = TriggerDefine.VelValue;
                        setTriggerDefParam.VelMdf.fCharRmsvalue  = TriggerDefine.VelRmsThreshold;
                        setTriggerDefParam.VelMdf.fCharPKvalue   = TriggerDefine.VelPKThreshold;
                        setTriggerDefParam.VelMdf.fCharPKPKvalue = TriggerDefine.VelPKPKThreshold;
                    }
                    if (TriggerDefine.DispEnable == 1)
                    {
                        setTriggerDefParam.DspMdf.MeasDefType    = iMesh.enMeasDefType.eDspWaveform;
                        setTriggerDefParam.DspMdf.bEnable        = true;
                        setTriggerDefParam.DspMdf.u8Flag         = TriggerDefine.DispValue;
                        setTriggerDefParam.DspMdf.fCharRmsvalue  = TriggerDefine.DispRmsThreshold;
                        setTriggerDefParam.DspMdf.fCharPKvalue   = TriggerDefine.DispPKThreshold;
                        setTriggerDefParam.DspMdf.fCharPKPKvalue = TriggerDefine.DispPKPKThreshold;
                    }

                    //向底层发送信息
                    if (!iCMS.WG.Agent.ComFunction.Send2WS(setTriggerDefParam, Common.Enum.EnumRequestWSType.SetTrigger))
                    {
                        CommunicationWithServer communication2Server = new CommunicationWithServer();
                        communication2Server.UploadConfigResponse(TriggerDefine.MAC, Enum_ConfigType.ConfigType_MeasDefine, Convert.ToInt32(EnmuReceiveStatus.Unaccept), "网络正忙下发触发式配置失败,退出");
                        iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), TriggerDefine.MAC + ":网络正忙下发触发式配置失败,退出");
                    }
                    else
                    {
                        lock (iCMS.WG.Agent.ComFunction.sendTriggerDefineList)
                        {
                            System.Threading.Timer timer = new System.Threading.Timer(new System.Threading.TimerCallback(CheckSetTriggerDefTimeOut), TriggerDefine.MAC, 40000, -1);
                            TriggerDefine.time = timer;
                            iCMS.WG.Agent.ComFunction.sendTriggerDefineList.Add(TriggerDefine);
                        }
                    }

                    System.Threading.Thread.Sleep(100);
                }
            }
            catch (Exception ex)
            {
                iCMS.WG.Agent.Common.LogHelper.WriteLog(ex);
            }
            return("ConfigTriggerDefineOper");
        }
        public object doOperator()
        {
            try
            {
                iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), "准备升级");
                CommunicationWithServer communication2Server = new CommunicationWithServer();
                if (ComFunction.WSUpdatingInfo.UpdatingAllWSInfo.Count == 0)
                {
                    UpdateFirmwareTaskModel model = (updateModel as UpdateFirmwareTaskModel);
                    iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), "开始验证升级数据包...");
                    if (!ComFunction.JudgeLegitimacyOfUpgradeFile(model.updateFile))
                    {
                        foreach (string mac in model.macList)
                        {
                            communication2Server.UploadConfigResponse(mac, Enum_ConfigType.ConfigType_UpdateFirmware, Convert.ToInt32(EnmuReceiveStatus.Faild), "升级信息非法,退出对该WS的升级");
                            iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), mac + " 升级信息非法,退出对该WS的升级");
                        }
                        return(false);
                    }
                    iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), "升级数据包符合要求");
                    tFirmware firmware;
                    try
                    {
                        firmware = new tFirmware(model.updateFile);
                    }
                    catch
                    {
                        return(null);
                    }

                    iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), "开始:PreludeUpdate ");
                    if (ComFunction.meshAdapter.PreludeUpdate())
                    {
                        iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), "PreludeUpdate 完成 ");
                        lock (ComFunction.WSUpdatingInfo)
                        {
                            foreach (string mac in model.macList)
                            {
                                if (!string.IsNullOrWhiteSpace(mac))
                                {
                                    ComFunction.WSUpdatingInfo.UpdatingAllWSInfo.Add(mac, null);
                                }
                            }
                        }

                        List <tMAC> tempMACList = model.macList
                                                  .Where(macInfo => !string.IsNullOrWhiteSpace(macInfo))
                                                  .Select(macInfo => new tMAC(macInfo))
                                                  .ToList();
                        if (ComFunction.meshAdapter.Update(tempMACList, firmware))
                        {
                            if (model.CommandSuccessed != null)
                            {
                                model.CommandSuccessed();
                            }

                            iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), "Update成功,开始升级已选择的WS ");
                        }
                        else
                        {
                            iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), "Update失败,退出升级");

                            if (model.CommandFailed != null)
                            {
                                model.CommandFailed();
                            }

                            lock (ComFunction.WSUpdatingInfo)
                            {
                                foreach (string mac in model.macList)
                                {
                                    iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(),
                                                                            " Update失败,无法升级,退出对该WS的升级 :" + mac);
                                    communication2Server.UploadConfigResponse(mac, Enum_ConfigType.ConfigType_UpdateFirmware, Convert.ToInt32(EnmuReceiveStatus.Faild), "Update失败,退出对该WS的升级");
                                }
                                try
                                {
                                    ComFunction.WSUpdatingInfo.UpdatingAllWSInfo.Clear();
                                    if (ComFunction.WSUpdatingInfo.UpdateAllWSTimer != null)
                                    {
                                        ComFunction.WSUpdatingInfo.UpdateAllWSTimer.Stop();
                                        ComFunction.WSUpdatingInfo.UpdateAllWSTimer.Close();
                                        ComFunction.WSUpdatingInfo.UpdateAllWSTimer.Dispose();
                                        ComFunction.WSUpdatingInfo.UpdateAllWSTimer = null;
                                    }
                                }
                                catch
                                {
                                }
                            }

                            iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), "开始 PostludeUpdate");
                            ComFunction.meshAdapter.PostludeUpdate();
                            iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), "开始 PostludeUpdate 完成");
                            return(false);
                        }
                    }
                    else
                    {
                        iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), "PreludeUpdate 失败");

                        if (model.CommandFailed != null)
                        {
                            model.CommandFailed();
                        }

                        lock (ComFunction.WSUpdatingInfo)
                        {
                            foreach (string mac in model.macList)
                            {
                                iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(),
                                                                        " PreludeUpdate 失败,网络异常无法升级,退出对该WS的升级 :" + mac);
                                communication2Server.UploadConfigResponse(mac, Enum_ConfigType.ConfigType_UpdateFirmware, Convert.ToInt32(EnmuReceiveStatus.Faild), "PreludeUpdate 失败,退出对该WS的升级");
                            }
                            try
                            {
                                ComFunction.WSUpdatingInfo.UpdatingAllWSInfo.Clear();
                                if (ComFunction.WSUpdatingInfo.UpdateAllWSTimer != null)
                                {
                                    ComFunction.WSUpdatingInfo.UpdateAllWSTimer.Stop();
                                    ComFunction.WSUpdatingInfo.UpdateAllWSTimer.Close();
                                    ComFunction.WSUpdatingInfo.UpdateAllWSTimer.Dispose();
                                    ComFunction.WSUpdatingInfo.UpdateAllWSTimer = null;
                                }
                            }
                            catch
                            {
                            }
                        }

                        iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), "开始 PostludeUpdate!");
                        ComFunction.meshAdapter.PostludeUpdate();
                        iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), "PostludeUpdate 完成!");
                        return(false);
                    }
                }
                else
                {
                    iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), "当前有WS正在进行升级");
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex);
            }
            return(null);
        }
Ejemplo n.º 12
0
        public object doOperator()
        {
            try
            {
                ConfigMeasureDefineTaskModel model = (configModel as ConfigMeasureDefineTaskModel);
                foreach (SendMeasureDefine measureDefine in model.measureDefineList)
                {
                    //System.Threading.Tasks.Task result = System.Threading.Tasks.Task.Run(() =>
                    //{
                    iMesh.tSetMeasDefParam setMeasDefParam = new iMesh.tSetMeasDefParam();
                    iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), "开始下发WS的测量定义 :" + measureDefine.MAC);
                    setMeasDefParam.mac = new iMesh.tMAC(measureDefine.MAC);
                    switch (measureDefine.DAQStyle)
                    {
                    case 1:
                        setMeasDefParam.DaqMode = iMesh.enWsDaqMode.eTiming;
                        //设备总数
                        setMeasDefParam.u8DevTotal = Convert.ToByte(measureDefine.DevTotal);
                        //设备编号
                        setMeasDefParam.u8DevNum = Convert.ToByte(measureDefine.DevNum);

                        iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), "定时采集 " + measureDefine.MAC);
                        break;

                    case 2:
                        setMeasDefParam.DaqMode = iMesh.enWsDaqMode.eImmediate;
                        iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), "临时采集 " + measureDefine.MAC);
                        break;

                    default:
                        break;
                    }



                    setMeasDefParam.TmpDaqPeriod.u8Hour = measureDefine.DAQPeriodTemperature[0];
                    setMeasDefParam.TmpDaqPeriod.u8Min  = measureDefine.DAQPeriodTemperature[1];
                    setMeasDefParam.u16EigenDaqMult     = measureDefine.DAQPeriodCharacterValue;
                    setMeasDefParam.u16WaveDaqMult      = measureDefine.DAQPeriodWave;

                    if (measureDefine.ACCSubscribe == 1)
                    {
                        setMeasDefParam.AccMdf.MeasDefType      = iMesh.enMeasDefType.eAccWaveform;
                        setMeasDefParam.AccMdf.bSubscribed      = true;
                        setMeasDefParam.AccMdf.u8EigenValueType = measureDefine.ACCValue;
                        setMeasDefParam.AccMdf.u16WaveLen       = measureDefine.ACCWaveLength;
                        setMeasDefParam.AccMdf.u16UpperFreq     = measureDefine.ACCUpLimitFreq;
                        setMeasDefParam.AccMdf.u16LowFreq       = measureDefine.ACCLowLimitFreq;
                    }
                    if (measureDefine.ACCEnvlSubscribe == 1)
                    {
                        setMeasDefParam.AccEnvMdf.MeasDefType      = iMesh.enMeasDefType.eAccEnvelope;
                        setMeasDefParam.AccEnvMdf.bSubscribed      = true;
                        setMeasDefParam.AccEnvMdf.u8EigenValueType = measureDefine.ACCEnvlValue;
                        setMeasDefParam.AccEnvMdf.u16WaveLen       = measureDefine.ACCEnvlWaveLength;
                        setMeasDefParam.AccEnvMdf.u16UpperFreq     = measureDefine.ACCEnvlpBandWidth;
                        setMeasDefParam.AccEnvMdf.u16LowFreq       = measureDefine.ACCEnvlpFilter;
                    }
                    if (measureDefine.DispSubscribe == 1)
                    {
                        setMeasDefParam.DspMdf.MeasDefType      = iMesh.enMeasDefType.eDspWaveform;
                        setMeasDefParam.DspMdf.bSubscribed      = true;
                        setMeasDefParam.DspMdf.u8EigenValueType = measureDefine.DispValue;
                        setMeasDefParam.DspMdf.u16WaveLen       = measureDefine.DispWaveLength;
                        setMeasDefParam.DspMdf.u16UpperFreq     = measureDefine.DispUpLimitFreq;
                        setMeasDefParam.DspMdf.u16LowFreq       = measureDefine.DispLowLimitFreq;
                    }
                    if (measureDefine.VelSubscribe == 1)
                    {
                        setMeasDefParam.VelMdf.MeasDefType      = iMesh.enMeasDefType.eVelWaveform;
                        setMeasDefParam.VelMdf.bSubscribed      = true;
                        setMeasDefParam.VelMdf.u8EigenValueType = measureDefine.VelValue;
                        setMeasDefParam.VelMdf.u16WaveLen       = measureDefine.VelWaveLength;
                        setMeasDefParam.VelMdf.u16UpperFreq     = measureDefine.VelUpLimitFreq;
                        setMeasDefParam.VelMdf.u16LowFreq       = measureDefine.VelLowLimitFreq;
                    }
                    //启停机
                    if (measureDefine.CriticalSubscribe == 1)
                    {
                        if (setMeasDefParam.RevStop != null)
                        {
                            setMeasDefParam.RevStop.MeasDefType      = iMesh.enMeasDefType.eRevStopform;
                            setMeasDefParam.RevStop.bSubscribed      = true;
                            setMeasDefParam.RevStop.u8EigenValueType = measureDefine.CriticalValue;
                            setMeasDefParam.RevStop.u16WaveLen       = measureDefine.CriticalWaveLength;
                            setMeasDefParam.RevStop.u16UpperFreq     = measureDefine.CriticalBandWidth;
                            setMeasDefParam.RevStop.u16LowFreq       = measureDefine.CriticalFilter;
                        }
                    }
                    //LQ
                    if (measureDefine.LQSubscribe == 1)
                    {
                        setMeasDefParam.LQMdf.MeasDefType = iMesh.enMeasDefType.eLQform;
                        setMeasDefParam.LQMdf.bSubscribed = true;

                        setMeasDefParam.LQMdf.u8EigenValueType = measureDefine.LQValue;
                        setMeasDefParam.LQMdf.u16WaveLen       = measureDefine.LQWaveLength;
                        setMeasDefParam.LQMdf.u16UpperFreq     = measureDefine.LQUpLimitFreq;
                        setMeasDefParam.LQMdf.u16LowFreq       = measureDefine.LQLowLimitFreq;
                    }

                    //向底层发送信息
                    if (!iCMS.WG.Agent.ComFunction.Send2WS(setMeasDefParam, Common.Enum.EnumRequestWSType.SetMeasDef))
                    {
                        CommunicationWithServer communication2Server = new CommunicationWithServer();
                        communication2Server.UploadConfigResponse(measureDefine.MAC, Enum_ConfigType.ConfigType_MeasDefine, Convert.ToInt32(EnmuReceiveStatus.Unaccept), "网络正忙下发测量定义失败,退出对该WS的下发测量定义");
                        iCMS.WG.Agent.Common.LogHelper.WriteLog(iCMS.WG.Agent.Common.Enum.EnumLogType.Agent2WS.ToString(), measureDefine.MAC + ":网络正忙下发测量定义失败,退出对该WS的下发测量定义");
                    }
                    else
                    {
                        lock (iCMS.WG.Agent.ComFunction.sendMeasureDefineList)
                        {
                            System.Threading.Timer timer = new System.Threading.Timer(new System.Threading.TimerCallback(CheckSetMeasDefTimeOut), measureDefine.MAC, 40000, -1);
                            measureDefine.time = timer;
                            iCMS.WG.Agent.ComFunction.sendMeasureDefineList.Add(measureDefine);
                        }
                    }

                    System.Threading.Thread.Sleep(100);
                }
            }
            catch (Exception ex)
            {
                iCMS.WG.Agent.Common.LogHelper.WriteLog(ex);
            }
            return("ConfigMeasureDefineOper");
        }