示例#1
0
        //加载端口
        private static WrapperBll PortSetting(Model_Data.DeviceModel obj)
        {
            WrapperBll PS = new WrapperBll();

            PS.Port = obj.Port;
            switch (obj.Port.PortType)
            {
            case Protocol.Modbus_SerialPort:
                PS.PortBll = AllPortBll.CreateInstance(Protocol.Modbus_SerialPort);
                PS.PortBll.SetParaMeter(CreatCommSerialEntity(obj));
                break;

            case Protocol.Modbus_TCPIPPort:
                PS.PortBll = AllPortBll.CreateInstance(Protocol.Modbus_TCPIPPort);
                PS.PortBll.SetParaMeter(CreatCommTCPEntity(obj));
                break;

            case Protocol.Modbus_USBPort:
                PS.PortBll = AllPortBll.CreateInstance(Protocol.Modbus_USBPort);
                break;

            default:
                return(null);
            }
            //Device
            DeviceBll deviceBLL = new DeviceBll();

            deviceBLL.Device.DeviceName                 = obj.DeviceName;
            deviceBLL.Device.UnitId                     = obj.UnitId;
            deviceBLL.Device.write2DBInterval           = obj.WriteDBTime;
            deviceBLL.Device.AnalogSignalValueTableName = obj.TableName;
            deviceBLL.Device.UIpath                     = obj.UIPath;
            //
            foreach (AnalogModel AnalogRow in obj.Analog)
            {
                AnalogBll analogSignalBLL = new AnalogBll();
                analogSignalBLL.AnalogInfo = AnalogRow;
                deviceBLL.AnalogList.Add(analogSignalBLL);
            }
            //
            foreach (DigitalModel DigitalRow in obj.Digital)
            {
                DigitalBll digitalSignalBLL = new DigitalBll();
                digitalSignalBLL.DigitalInfo = DigitalRow;
                deviceBLL.DigitalList.Add(digitalSignalBLL);
            }
            deviceBLL.SetSignalAlarmDelegate();
            if (deviceBLL != null)
            {
                PS.DeviceList.Add(deviceBLL);
            }
            PS.SetDeviceDelegate();
            return(PS);
        }
示例#2
0
        //根据 设备获取设备 信息,创建设备 实时LIST----数字
        public static List <UI_Digital> GetDeviceDigitalSignalValueList()
        {
            DeviceBll Device = wrapper.DeviceList[0];

            if (Device == null)
            {
                return(null);
            }
            if (Device.Device.ComState != DivCommStateEnum.Success)
            {
                return(null);
            }
            List <UI_Digital> DigitalSignalValueList = new List <UI_Digital>();

            foreach (DigitalBll Signal in Device.DigitalList)
            {
                UI_Digital DigitalSignal_Item = new UI_Digital();
                DigitalSignal_Item.SignalName  = Signal.DigitalInfo.SignalName;
                DigitalSignal_Item.SignalValue = Signal.DigitalInfo.Value;
                DigitalSignalValueList.Add(DigitalSignal_Item);
            }
            return(DigitalSignalValueList);
        }
示例#3
0
        //根据 设备获取设备 信息,创建设备 实时LIST-----模拟
        public static List <UI_Analog> GetDeviceAnalogSignalValueList()
        {
            DeviceBll Device = wrapper.DeviceList[0];

            if (Device == null)
            {
                return(null);
            }
            if (Device.Device.ComState != DivCommStateEnum.Success)
            {
                return(null);
            }
            List <UI_Analog> AnalogSignalValueList = new List <UI_Analog>();

            foreach (AnalogBll Signal in Device.AnalogList)
            {
                UI_Analog AnalogSignal_Item = new UI_Analog();
                AnalogSignal_Item.SignalName  = Signal.AnalogInfo.SignalName;
                AnalogSignal_Item.SignalValue = Signal.AnalogInfo.Value;
                AnalogSignal_Item.SignalUnit  = Signal.AnalogInfo.SignalUnit;
                AnalogSignalValueList.Add(AnalogSignal_Item);
            }
            return(AnalogSignalValueList);
        }