Example #1
0
 public Device()
 {
     Configuration = new DeviceConfiguration();
     UserRegisters = new List<DeviceUserRegister>();
     Statuses = new DeviceStatuses();
     DIModule = null;
     DOModule = null;
     AIModule = null;
     RouterModule = null;
 }
 public DeviceUARTPortConfiguration(ref DeviceConfiguration deviceConfiguration)
 {
     _deviceConfiguration = deviceConfiguration;
     PortOperation = 1;
     PortSpeed = 9600;
     PortStopBits = 2;
     PortParity = 0;
     PortByteSize = 8;
     PortFlowControl = 0;
     PortProtocolType = 1;
     PortMasterTimeout = 200;
     PortMasterRequestCount = 0;
     PortRetriesCount = 5;
     PortModbusAddress = 1;
 }
Example #3
0
 public DeviceUserRegister(DeviceConfiguration deviceConfiguration)
 {
     _deviceConfiguration = deviceConfiguration;
     Source = new List<object>();
 }
 public DeviceModuleDOConfiguration(DeviceConfiguration deviceConfiguration)
 {
     _deviceConfiguration = deviceConfiguration;
 }
 public DeviceModuleDOConfiguration()
 {
     ModuleOperation = 1;
     PulseDurationTime = 10;
     _deviceConfiguration = null;
 }
Example #6
0
 public DeviceRoutingHeader(ref DeviceConfiguration deviceConfiguration)
 {
     _deviceConfiguration = deviceConfiguration;
     RoutingEnabled = 1;
 }
Example #7
0
 public DeviceRoutingHeader()
 {
     RoutingEnabled = 1;
     _deviceConfiguration = null;
 }
Example #8
0
 public RegistersMapBuilder(DeviceConfiguration configuration)
 {
     _configuration = configuration;
 }
Example #9
0
        internal ReaderSaverErrors ReadDeviceHeader(DeviceConfiguration configuration)
        {
            List<object> listOfConfigurationItems = new List<object>();
            DeviceHeader tempHeader = new DeviceHeader();
            DeviceConfigurationTime tempConfigurationTime = new DeviceConfigurationTime();
            listOfConfigurationItems.Add(tempHeader);
            listOfConfigurationItems.Add(tempConfigurationTime);

            ReaderSaverErrors retCode = PerformReading(ref listOfConfigurationItems);
            if (retCode != ReaderSaverErrors.CodeOk)
                return retCode;

            if (listOfConfigurationItems.Count < 1)
                return ReaderSaverErrors.CodeUnknownError;

            if (!tempHeader.IsValidHeader())
                    return ReaderSaverErrors.CodeInvalidDeviceHeader;

            configuration.HeaderFields.DeviceConsistenceRegister = tempHeader.DeviceConsistenceRegister;
            configuration.HeaderFields.DeviceHeaderCrc16 = tempHeader.DeviceHeaderCrc16;
            configuration.HeaderFields.DeviceUartChannelsCount = tempHeader.DeviceUartChannelsCount;
            configuration.HeaderFields.DeviceMaximumModbusMasterRequestsToSubDeviceCount = tempHeader.DeviceMaximumModbusMasterRequestsToSubDeviceCount;
            configuration.HeaderFields.DeviceUserRegistersCount = tempHeader.DeviceUserRegistersCount;
            configuration.HeaderFields.DeviceVersion = tempHeader.DeviceVersion;
            configuration.LastConfigurationTime = tempConfigurationTime;

            return ReaderSaverErrors.CodeOk;
        }
Example #10
0
        internal ReaderSaverErrors CheckDeviceHeaderValidityAndInitConfiguration(DeviceConfiguration configuration, bool checkOnly = false)
        {
            List<object> listOfConfigurationItems = new List<object>();
            DeviceHeader tempHeader = new DeviceHeader();
            listOfConfigurationItems.Add(checkOnly ? tempHeader : configuration.HeaderFields);

            ReaderSaverErrors retCode = PerformReading(ref listOfConfigurationItems);
            if (retCode != ReaderSaverErrors.CodeOk)
                return retCode;

            if (listOfConfigurationItems.Count < 1)
                return ReaderSaverErrors.CodeUnknownError;

            if (!checkOnly)
            {
                object tempObj = configuration.HeaderFields;
                Utility.CloneObjectProperties(listOfConfigurationItems[0], ref tempObj);
                if (!configuration.HeaderFields.IsValidHeader())
                    return ReaderSaverErrors.CodeInvalidDeviceHeader;

                if (configuration.HeaderFields.ModuleRouter && configuration.RoutingHeader != null)
                {
                    //save previous reading  offset
                    UInt16 currentDeviceOffset = RegisterReadAddressOffset;
                    //calculate offset for reading router header
                    listOfConfigurationItems.Add(configuration.LastConfigurationTime);
                    listOfConfigurationItems.AddRange(configuration.UartPorts);
                    if (configuration.DIModuleConfiguration != null)
                        listOfConfigurationItems.Add(configuration.DIModuleConfiguration);
                    if (configuration.DOModuleConfiguration != null)
                        listOfConfigurationItems.Add(configuration.DOModuleConfiguration);

                    RegisterReadAddressOffset = (UInt16)(currentDeviceOffset + ((SizeofHelper.SizeOfPublicPropertiesWithModbusAttribute(listOfConfigurationItems) + 1) / 2));
                    listOfConfigurationItems.Clear();

                    //read header
                    listOfConfigurationItems.Add(configuration.RoutingHeader);
                    retCode = PerformReading(ref listOfConfigurationItems);
                    if (retCode != ReaderSaverErrors.CodeOk)
                        return retCode;
                    //restore previous reading  offset
                    RegisterReadAddressOffset = currentDeviceOffset;
                }
            }
            else
            {
                if (!tempHeader.IsValidHeader())
                    return ReaderSaverErrors.CodeInvalidDeviceHeader;

                if (configuration.HeaderFields.DeviceUartChannelsCount !=
                    tempHeader.DeviceUartChannelsCount)
                    return ReaderSaverErrors.CodeNotCompliantDevice;
            }
            return ReaderSaverErrors.CodeOk;
        }
Example #11
0
 public DeviceHeader(ref DeviceConfiguration deviceConfiguration)
 {
     _deviceConfiguration = deviceConfiguration;
 }
Example #12
0
 public DeviceHeader()
 {
     _deviceConfiguration = null;
 }