/// <summary> /// Copy constructor, to create a copy of the existing DictEntry object. /// </summary> /// <param name="copyEntry">DictEntry object, which shall be copied.</param> public DictEntry(DictEntry copyEntry) { _deviceId = copyEntry._deviceId; _protocolStack = copyEntry._protocolStack; DeviceMarkedAsOffline = copyEntry.DeviceMarkedAsOffline; LastTimeCommandReceived = copyEntry.LastTimeCommandReceived; }
public void Open(ENuvoSystem system, int deviceId, Communication communicationConfiguration, IConcreteProtocol essentiaProtocol) { throw new System.NotImplementedException(); }
/// <summary> /// Public method - specific for Nuvo - to connect to. /// </summary> /// <param name="system">System Type, to connect to.</param> /// <param name="deviceId">Device Id, to connect to</param> /// <param name="communicationConfiguration">Communication Configuration, used to connect to the device.</param> /// <param name="essentiaProtocol">Optional protocol layer object, used in case of test environment. Pass <c>null</c> in case of productive system.</param> public void Open(ENuvoSystem system, int deviceId, Communication communicationConfiguration, IConcreteProtocol essentiaProtocol) { if (system != ENuvoSystem.NuVoEssentia) { throw new ProtocolDriverException(string.Format("This system type is not supported! Cannot connect! '{0}'", system)); } lock (_deviceList) { if (_deviceList.ContainsKey(deviceId)) { throw new ProtocolDriverException(string.Format("A device with the id {0} is already registered. Cannot add a device with the same id!", deviceId)); } // if not null, use the protocol object passed by the caller (e.g. as mock object for unit test) _deviceList.Add(deviceId, new DictEntry(deviceId, ((essentiaProtocol == null) ? new NuvoEssentiaProtocol(deviceId, null) : essentiaProtocol))); // register for events from protocol layer _deviceList[deviceId].ProtocolStack.onCommandReceived += new ConcreteProtocolEventHandler(_essentiaProtocol_onCommandReceived); // open connection to the protocol layer _deviceList[deviceId].ProtocolStack.Open(new SerialPortConnectInformation( communicationConfiguration.Port, // e.g. "COM1" communicationConfiguration.BaudRate, // e.g. 9600 (Parity)Enum.Parse(typeof(Parity), communicationConfiguration.ParityMode), // e.g. None communicationConfiguration.DataBits, // e.g. 8 (StopBits)communicationConfiguration.ParityBit)); // e.g. 1 = StopBits } }
/// <summary> /// Public constructor to create a dictionary entry. /// It is required to set the protocol stack at creation time. /// </summary> /// <param name="deviceId">Device Id.</param> /// <param name="protocolStack">Protocol Stack</param> public DictEntry(int deviceId, IConcreteProtocol protocolStack) { _deviceId = deviceId; _protocolStack = protocolStack; }