private async Task ReceiveConnectionsLoopAsync() { tcpServer.Start(); while (true) { TcpClient socket; try { socket = await tcpServer.AcceptTcpClientAsync(); } catch (ObjectDisposedException) { //Console.WriteLine ("break listenConnections()"); break; } RexDevice rex = new RexDevice(socket.GetStream()); rex.Connected += () => { if (Connected != null) { Connected(rex); } }; rex.Disconnected += () => { if (Disconnected != null) { Disconnected(rex); } }; rex.InitializeAsync(); } }
internal Features(RexDevice rex, byte[] payload) { this.Rex = rex; Stream stream = new MemoryStream(payload); this.NumRelays = stream.ReadInt(); this.NumSerialPorts = stream.ReadInt(); this.NumDigitalInputs = stream.ReadInt(); this.NumLeds = stream.ReadInt(); this.NumFingerprintScanners = stream.ReadInt(); this.HasKeyboard = stream.ReadInt() > 0; this.HasDisplay = stream.ReadInt() > 0; this.HasBuzzer = stream.ReadInt() > 0; this.HasMP3 = stream.ReadInt() > 0; byte[] versionInts = stream.ReadFully(4); this.Version = new Version(versionInts[3], versionInts[2], versionInts[1], versionInts[0]); }
internal DigitalInput(RexDevice rex, int index) { this.Rex = rex; this.Index = index; this.Value = false; }
internal SerialPort(RexDevice rex, int index) { this.Rex = rex; this.Index = index; this._stream = null; }
internal Display(RexDevice rex) { this.Rex = rex; this.Backlight = new DigitalOutput(rex, DigitalOutput.DigitalOutputType.DisplayBacklight, 0); }
internal DigitalOutput(RexDevice rex, DigitalOutputType type, int index) { this.Rex = rex; this.Type = type; this.Index = index; }