Exemplo n.º 1
0
 private void OnRfidEvent(RfidEventArgs e)
 {
     if (RfidEvent != null)
     {
         RfidEvent(this, e);
     }
 }
Exemplo n.º 2
0
        private void _rfidCardDataReceived(object _cardPort, SerialDataReceivedEventArgs unused)
        {
            // Capture the port that the data was received on.
            SerialPort cardPort = (SerialPort)_cardPort;

            //String cardID = String.Empty;
            int iRFIDReadLen = cardPort.BytesToRead;

            //RFID always read in 16 bytes of data
            if (iRFIDReadLen == 16)
            {
                byte[] rawData      = new byte[16]; // Incoming raw bytes from the serial connection.
                char[] idStringData = new char[10]; // ID String data.

                //Read in 16 bytes data
                cardPort.Read(rawData, 0, rawData.Length);

                // Card ID is a 10 byte ASCII data
                // It is located at byte 1 - 11 of the 16 bytes
                for (int i = 0; i < 10; i++)
                {
                    idStringData[i] = (char)rawData[i + 1];   // skip first byte
                }

                RfidEventArgs _args = new RfidEventArgs();
                _args.RFID = new string(idStringData);
                OnRfidEvent(_args);
            }
        }
Exemplo n.º 3
0
        public void Rfid_OpenNoConnection(int OldId, int id)
        {
            RfidEventArgs RfidArgs = new RfidEventArgs(OldId);

            _chargeControl.connection_establishment().Returns(false);
            _rfidreader.RfidHandler += Raise.EventWith(RfidArgs);
            _door.DidNotReceive().Lock();
        }
Exemplo n.º 4
0
 public void Setup()
 {
     _uut            = new RfidReaderSimulator();
     _uut.RfidEvent +=
         (o, args) =>
     {
         _RfidEventArgs = args;
     };
 }
Exemplo n.º 5
0
        public void Rfid_AvailableState_NoConnection(int id)
        {
            RfidEventArgs RfidArgs = new RfidEventArgs(id);

            _chargeControl.connection_establishment().Returns(false);
            _rfidreader.RfidHandler += Raise.EventWith(RfidArgs);

            _door.DidNotReceive().Lock();
            _chargeControl.DidNotReceive().charge_control_start();
            _disp.Received().PrintStationMsg(_NoConnectionMsg);
        }
Exemplo n.º 6
0
 public void Setup()
 {
     _recievedEventArgs = null;
     _uut                    = new RfidReaderSimulator();
     _numberOfEvents         = 0;
     _uut.IdRegisteredEvent += (o, a) =>
     {
         _recievedEventArgs = a;
         _numberOfEvents++;
     };
 }
        public void Setup()
        {
            _uut = new RfidReader();
            _receivedEventArgs = null;

            _uut.RfidDetectedEvent +=
                (o, args) =>
            {
                _receivedEventArgs = args;
            };
        }
Exemplo n.º 8
0
        public void Rfid_AvailableState(int id)
        {
            RfidEventArgs RfidArgs = new RfidEventArgs(id);

            _chargeControl.connection_establishment().Returns(true);
            _rfidreader.RfidHandler += Raise.EventWith(this, RfidArgs);
            //_rfidreader.RfidHandler += (sender, args) => receivedId = args.id_;

            _door.Received().Lock();
            _chargeControl.Received().charge_control_start();
            _disp.Received().PrintStationMsg(_NowChargingMsg);
        }
Exemplo n.º 9
0
        // Eksempel på event handler for eventet "RFID Detected" fra tilstandsdiagrammet for klassen
        private void RfidDetected(object sender, RfidEventArgs e)
        {
            switch (_state)
            {
            case LadeskabState.Available:
                // Check for ladeforbindelse
                if (_charger.IsConnected())
                {
                    _door.LockDoor();
                    _charger.StartCharge();
                    _oldId = e.Id;
                    _logfile.LogDoorLocked(e.Id);

                    _display.StateChangedToLocked();
                    _state = LadeskabState.Locked;
                }
                else
                {
                    _display.ErrorInPhoneConnection();
                }

                break;

            case LadeskabState.DoorOpen:
                throw new System.Exception("ERROR! RFID cannot be received when state is DoorOpen");

            case LadeskabState.Locked:
                // Check for correct ID
                if (e.Id == _oldId)
                {
                    _charger.StopCharge();
                    _door.UnlockDoor();
                    _logfile.LogDoorUnlocked(e.Id);

                    _display.StateChangedToUnlocked();
                    _state = LadeskabState.Available;
                }
                else
                {
                    _display.RfidNoMatch();
                }
                break;
            }
        }
Exemplo n.º 10
0
 private void HandleRfIdEvent(object?sender, RfidEventArgs e)
 {
     _id = e.RfID;
     RfidDetected(_id);
 }
Exemplo n.º 11
0
 private void RfidReader_TagReadEvent(object sender, RfidEventArgs e)
 {
     numberOfEvents++;
     lastReceivedID = e.Id;
 }
Exemplo n.º 12
0
 private static void OnConnectionStatus(object sender, RfidEventArgs <RfidRdrConnectionStatus> e)
 {
     Console.WriteLine($"{nameof(OnConnectionStatus)} {e.Value.Rdr} {e.Value.Type}");
 }
Exemplo n.º 13
0
 private static void OnAntennaStatus(object sender, RfidEventArgs <RfidRdrAntennaStatus> e)
 {
 }
Exemplo n.º 14
0
 protected virtual void OnScanTag(RfidEventArgs e)
 {
     TagReadEvent?.Invoke(this, e);
 }