public void OpenSimulatorTest() { NuvoEssentiaProtocolDriver target = new NuvoEssentiaProtocolDriver(); Communication communicationConfiguration = new Communication("SIM", 9600, 8, 1, "None"); // Create Simulator target.Open(ENuvoSystem.NuVoEssentia, _deviceId, communicationConfiguration, null); }
/// <summary> /// Private method to create a protocol driver stack, using the mock class /// for the telegram stack. /// </summary> /// <param name="deviceId">Device Id to setup the stack.</param> /// <param name="commConfig">Communication Configuration to setup the stack.</param> private void createProtocolDriver(int deviceId, Communication commConfig) { _nuvoTelegramMock = new NuvoTelegramMock(); _essentiaProtocol = new NuvoEssentiaProtocol(deviceId, _nuvoTelegramMock); _protDriver = new NuvoEssentiaProtocolDriver(); _protDriver.Open(ENuvoSystem.NuVoEssentia, deviceId, commConfig, _essentiaProtocol); }
private void btnConnect_Click(object sender, EventArgs e) { if (cmbComSelect.Text.Contains("private")) { // Open a MSMQ queue _msgQueue = SerialPortQueue.GetQueue(".\\" + cmbComSelect.Text); if (chkReceive.Checked) { _msgQueue.ReceiveCompleted += new ReceiveCompletedEventHandler(_msgQueue_ReceiveCompleted); _msgQueue.BeginReceive(); } DisplayData(MessageType.Normal, string.Format("Open connection to Queue '{0}'", cmbComSelect.Text)); } else { // Open a protocol stack (using a class implementing IProtocol) DisplayData(MessageType.Normal, string.Format("Open connection to Port '{0}'", cmbComSelect.Text)); _nuvoServer = new NuvoEssentiaProtocolDriver(); if (chkReceive.Checked) { _nuvoServer.onCommandReceived += new ProtocolCommandReceivedEventHandler(nuvoServer_onCommandReceived); _nuvoServer.onZoneStatusUpdate += new ProtocolZoneUpdatedEventHandler(_nuvoServer_onZoneStatusUpdate); } _nuvoServer.Open(ENuvoSystem.NuVoEssentia, 1, new Communication(cmbComSelect.Text, 9600, 8, 1, "None")); if (chkSend.Checked) { DisplayData(MessageType.Normal, "Read version ..."); NuvoEssentiaSingleCommand command = new NuvoEssentiaSingleCommand(ENuvoEssentiaCommands.ReadVersion); DisplayData(MessageType.Outgoing, command.OutgoingCommand); _nuvoServer.SendCommand(_address, command); } } }
/// <summary> /// Private method to destroy the protocol stack. /// </summary> /// <param name="deviceId">Device Id used to setup the stack.</param> private void destroyProtocolDriver(int deviceId) { if (_protDriver != null) { _protDriver.Close(deviceId); } _protDriver = null; _essentiaProtocol = null; _nuvoTelegramMock = null; }
public void SimulatorCommandSetSourceTest() { NuvoEssentiaProtocolDriver target = new NuvoEssentiaProtocolDriver(); Communication communicationConfiguration = new Communication("SIM", 9600, 8, 1, "None"); // Create Simulator target.Open(ENuvoSystem.NuVoEssentia, _deviceId, communicationConfiguration, null); target.onCommandReceived += new ProtocolCommandReceivedEventHandler(target_onCommandReceived); Address zoneAddress = new Address(_deviceId, 2); // Zone 2 target.CommandSetSource(zoneAddress, new Address(_deviceId, 5)); // Source 5 }
public void checkZoneDeviceIdTest() { NuvoEssentiaProtocolDriver target = new NuvoEssentiaProtocolDriver(); target.Open(ENuvoSystem.NuVoEssentia, 1, _commConfig); // Open device with id=1 /* // not supported anymore; quick-fix, uncomment unit test -> * * // Test existing device id * target.checkZoneDeviceId(1); * * // Test non-existing device id * try * { * target.checkZoneDeviceId(4); * Assert.Fail("Failed! Excpetion was expected!"); * } * catch( ProtocolDriverException ex ) * { * _log.DebugFormat("ProtocolDriverException caught! Exception={0}", ex.ToString()); * } * */ }