private void initAllDevComp() { fpc = new FunctionParameterCollection(); devCap = new DeviceCapabilities(); dev = new Device(); devcol = new DeviceCollection(); devEventColl = new DeviceEventCollection(); devfuncColl = new DeviceFunctionCollection(); devPropColl = new DevicePropertyCollection(); devevent = new DeviceEvent(); devFunc = new DeviceFunction(); devProp = new DeviceProperty(); }
private void LoadAllDevices() { if (File.Exists(@"\\192.168.0.37\MY101-Product X\07-Product Line\CSL\ComponentManager\Devices.xml")) { XElement root = XElement.Load(@"\\192.168.0.37\MY101-Product X\07-Product Line\CSL\ComponentManager\Devices.xml"); root.Elements("Device").All <XElement>(xeDevices => { DeviceCapabilities devCap = new DeviceCapabilities(); DeviceEventCollection devEventColl = new DeviceEventCollection(); DeviceFunctionCollection devfuncColl = new DeviceFunctionCollection(); DevicePropertyCollection devPropColl = new DevicePropertyCollection(); xeDevices.Elements("Capabilities").Elements("events").Elements("event").All <XElement>(xe => { devEventColl.AddDeviceEvent(xe.Attribute("id").Value, xe.Attribute("name").Value); return(true); }); xeDevices.Elements("Capabilities").Elements("functions").Elements("function").All <XElement>(xe => { devfuncColl.AddDeviceFunctions(xe.Attribute("id").Value, xe.Attribute("functionname").Value, fpc, /* this will taken care later*/ (ACTDataType)Enum.Parse(typeof(ACTDataType), "dt" + xe.Attribute("returntype").Value.ToLower())); return(true); }); xeDevices.Elements("Capabilities").Elements("properties").Elements("property").All <XElement>(xe => { devPropColl.AddDeviceProperties(xe.Attribute("id").Value, xe.Attribute("name").Value, (ACTDataType)Enum.Parse(typeof(ACTDataType), "dt" + xe.Attribute("type").Value.ToLower()), Convert.ToBoolean(xe.Attribute("Readonly").Value)); return(true); }); devCap.Events = devEventColl; devCap.Functions = devfuncColl; devCap.Properties = devPropColl; devcol.AddDevice(xeDevices.Attribute("id").Value, xeDevices.Attribute("name").Value, devCap); return(true); }); } if (File.Exists(@"\\192.168.0.37\MY101-Product X\07-Product Line\CSL\ComponentManager\SOA.xml")) { XElement root = XElement.Load(@"\\192.168.0.37\MY101-Product X\07-Product Line\CSL\ComponentManager\SOA.xml"); root.Elements("Device").All <XElement>(xeDevices => { DeviceCapabilities devCap = new DeviceCapabilities(); DeviceEventCollection devEventColl = new DeviceEventCollection(); DeviceFunctionCollection devfuncColl = new DeviceFunctionCollection(); DevicePropertyCollection devPropColl = new DevicePropertyCollection(); xeDevices.Elements("Capabilities").Elements("events").Elements("event").All <XElement>(xe => { devEventColl.AddDeviceEvent(xe.Attribute("id").Value, xe.Attribute("name").Value); return(true); }); xeDevices.Elements("Capabilities").Elements("functions").Elements("function").All <XElement>(xe => { devfuncColl.AddDeviceFunctions(xe.Attribute("id").Value, xe.Attribute("functionname").Value, fpc, /* this will taken care later*/ (ACTDataType)Enum.Parse(typeof(ACTDataType), "dt" + xe.Attribute("returntype").Value.ToLower())); return(true); }); xeDevices.Elements("Capabilities").Elements("properties").Elements("property").All <XElement>(xe => { devPropColl.AddDeviceProperties(xe.Attribute("id").Value, xe.Attribute("name").Value, (ACTDataType)Enum.Parse(typeof(ACTDataType), "dt" + xe.Attribute("type").Value.ToLower()), Convert.ToBoolean(xe.Attribute("Readonly").Value)); return(true); }); devCap.Events = devEventColl; devCap.Functions = devfuncColl; devCap.Properties = devPropColl; devcol.AddDevice(xeDevices.Attribute("id").Value, xeDevices.Attribute("name").Value, devCap); return(true); }); } AMAActionableObjects.FixedDeviceCollection = devcol; }