Пример #1
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public DeviceConfiguration()
 {
     var thisDevice = this;
     HeaderFields = new DeviceHeader(ref thisDevice);
     LastConfigurationTime = new DeviceConfigurationTime();
     //minimum 1 UART presentin device
     UartPorts = new List<DeviceUARTPortConfiguration>(3) { new DeviceUARTPortConfiguration(ref thisDevice) };
     DIModuleConfiguration = null;
     DOModuleConfiguration = null;
     RoutingHeader = null;
     RoutingTable = null;
     AIModuleConfiguration = null;
     ModbusMasterQueriesOnUartPorts = new ObservableCollection<ObservableCollection<DeviceModbusMasterQuery>>(){new ObservableCollection<DeviceModbusMasterQuery>()};
 }
Пример #2
0
        public bool FromList(List<object> listOfConfigurationItems)
        {
            if (listOfConfigurationItems.Count < 3)
                return false;
            int listIndex = 0;
            //Header
            object tempObj = HeaderFields;
            Utility.CloneObjectProperties(listOfConfigurationItems[listIndex++], ref tempObj);
            HeaderFields = tempObj as DeviceHeader;
            //Configuration Time
            LastConfigurationTime = listOfConfigurationItems[listIndex++] as DeviceConfigurationTime;//Utility.CloneObject(listOfConfigurationItems[listIndex++]) as DeviceConfigurationTime;
            //UART ports
            for (int port = 0; port < HeaderFields.DeviceUartChannelsCount && listIndex < listOfConfigurationItems.Count; port++)
            {
                UartPorts[port] = listOfConfigurationItems[listIndex++] as DeviceUARTPortConfiguration;
            }

            if (DIModuleConfiguration != null && HeaderFields.ModuleDI && listIndex < listOfConfigurationItems.Count)
                DIModuleConfiguration = listOfConfigurationItems[listIndex++] as DeviceModuleDIConfiguration;

            if (DOModuleConfiguration != null && HeaderFields.ModuleDO && listIndex < listOfConfigurationItems.Count)
                DOModuleConfiguration = listOfConfigurationItems[listIndex++] as DeviceModuleDOConfiguration;

            if (RoutingHeader != null && HeaderFields.ModuleRouter && listIndex < listOfConfigurationItems.Count)
            {
                tempObj = RoutingHeader;
                Utility.CloneObjectProperties(listOfConfigurationItems[listIndex++], ref tempObj);
                RoutingHeader = tempObj as DeviceRoutingHeader;
            }

            if (HeaderFields.ModuleRouter && RoutingTable != null)
            {
                for (int route = 0; route < HeaderFields.DeviceUserRegistersCount && listIndex < listOfConfigurationItems.Count; route++)
                {
                    RoutingTable[route] = listOfConfigurationItems[listIndex++] as DeviceRoutingTableElement;
                }
            }

            if (AIModuleConfiguration != null && HeaderFields.ModuleAI && listIndex < listOfConfigurationItems.Count)
                AIModuleConfiguration = listOfConfigurationItems[listIndex++] as DeviceModuleAIConfiguration;

            if (HeaderFields.ModuleModbusMaster)
            {
                foreach (ObservableCollection<DeviceModbusMasterQuery> portQueriesList in ModbusMasterQueriesOnUartPorts)
                {
                    for (int query = 0; query < portQueriesList.Count && listIndex < listOfConfigurationItems.Count; query++)
                    {
                        portQueriesList[query] = listOfConfigurationItems[listIndex++] as DeviceModbusMasterQuery;
                    }
                }
            }

            return true;
        }