Exemplo n.º 1
0
 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();
     }
 }
Exemplo n.º 2
0
        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]);
        }
Exemplo n.º 3
0
 internal DigitalInput(RexDevice rex, int index)
 {
     this.Rex   = rex;
     this.Index = index;
     this.Value = false;
 }
Exemplo n.º 4
0
 internal SerialPort(RexDevice rex, int index)
 {
     this.Rex     = rex;
     this.Index   = index;
     this._stream = null;
 }
Exemplo n.º 5
0
 internal Display(RexDevice rex)
 {
     this.Rex       = rex;
     this.Backlight = new DigitalOutput(rex, DigitalOutput.DigitalOutputType.DisplayBacklight, 0);
 }
Exemplo n.º 6
0
 internal DigitalOutput(RexDevice rex, DigitalOutputType type, int index)
 {
     this.Rex   = rex;
     this.Type  = type;
     this.Index = index;
 }