public DeviceManagerSettings(ApplicationSettings root, XmlElement element)
            : base(root, element)
        {
            ApplicationSettings = (ApplicationSettings)root;
            SerialPort = null;

            _DeviceGroupName = new GenericSetting<String>("", this, "DeviceGroupName");
            _Enabled = new GenericSetting<bool>(true, this, "Enabled");
            _Name = new GenericSetting<String>("", this, "Name");

            String deviceGroupName = DeviceGroupName;
            DeviceGroup = ApplicationSettings.DeviceManagementSettings.GetDeviceGroup(deviceGroupName);
            ProtocolSettings = ApplicationSettings.DeviceManagementSettings.GetProtocol(DeviceGroup.Protocol);

            LoadDetails();
        }
示例#2
0
        public Protocol(ProtocolSettings protocolSettings, IConverseCheckSum16 converseCheckSum = null)
            : base(GlobalSettings.SystemServices, null)
        {
            ProtocolSettings = protocolSettings;
            Type = ProtocolSettings.Type;
            if (converseCheckSum == null)
            {
                if (ProtocolSettings.CheckSum == "ModbusCheckSum16" || ProtocolSettings.CheckSum == "ModbusCRC16")
                    Calculations = new Conversations.ModbusConverseCalculations();
                else if (ProtocolSettings.CheckSum == "GrowattCheckSum16")
                    Calculations = new Conversations.GrowattConverseCalculations();
                else if (ProtocolSettings.CheckSum == "CRC16")
                    Calculations = new Conversations.CRC16ConverseCalculations();
                else if (ProtocolSettings.CheckSum == "CheckSum8")
                    Calculations = new Conversations.FroniusConverseCalculations();
                else
                    Calculations = new Conversations.ConverseCalculations();

                LogMessage("Protocol", "Using Calculations: " + Calculations.GetType().ToString(), LogEntryType.DetailTrace);
            }
            else
                Calculations = converseCheckSum;
            LoadConverse();
        }
        private void LoadProtocolsAndDevices(PVSettings.SettingsBase fileSettings)
        {
            foreach (XmlNode e in fileSettings.settings.ChildNodes)
            {
                if (e.NodeType == XmlNodeType.Element && e.Name == "protocol")
                {
                    ProtocolSettings protocol = new ProtocolSettings(this, (XmlElement)e);
                    _ProtocolList.Add(protocol);
                }
                else if (e.NodeType == XmlNodeType.Element && e.Name == "device")
                {
                    DeviceSettings device = new DeviceSettings(this, (XmlElement)e);
                    foreach (DeviceSettings.DeviceName name in device.Names)
                    {
                        DeviceListItem item = new DeviceListItem();
                        item.Id = name.Id;
                        item.Description = name.Name;
                        item.DeviceSettings = device;
                        _DeviceList.Add(item);

                        foreach (DeviceSettings.GroupName groupName in item.DeviceSettings.DeviceGroups)
                        {
                            string protocol = item.DeviceSettings.Protocol;
                            DeviceGroup deviceGroup = FindOrCreateDeviceGroup(groupName.Id, groupName.Name, protocol);
                            if (!deviceGroup.DeviceList.Contains(item))
                                deviceGroup.DeviceList.Add(item);
                            deviceGroup = FindOrCreateDeviceGroup(protocol, "Protocol: " + protocol, protocol, true);
                            if (!deviceGroup.DeviceList.Contains(item))
                                deviceGroup.DeviceList.Add(item);
                        }
                    }
                }
            }
        }