/// <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 } }
public void Open(ENuvoSystem system, int deviceId, Communication communicationConfiguration, IConcreteProtocol essentiaProtocol) { throw new System.NotImplementedException(); }
public void Open(ENuvoSystem system, int deviceId, Communication communicationConfiguration) { throw new System.NotImplementedException(); }
/// <summary> /// Public method to open a connection to a device. /// </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> public void Open(ENuvoSystem system, int deviceId, Communication communicationConfiguration) { Open(system, deviceId, communicationConfiguration, null); }