private void OnRfidEvent(RfidEventArgs e) { if (RfidEvent != null) { RfidEvent(this, e); } }
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); } }
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(); }
public void Setup() { _uut = new RfidReaderSimulator(); _uut.RfidEvent += (o, args) => { _RfidEventArgs = args; }; }
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); }
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; }; }
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); }
// 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; } }
private void HandleRfIdEvent(object?sender, RfidEventArgs e) { _id = e.RfID; RfidDetected(_id); }
private void RfidReader_TagReadEvent(object sender, RfidEventArgs e) { numberOfEvents++; lastReceivedID = e.Id; }
private static void OnConnectionStatus(object sender, RfidEventArgs <RfidRdrConnectionStatus> e) { Console.WriteLine($"{nameof(OnConnectionStatus)} {e.Value.Rdr} {e.Value.Type}"); }
private static void OnAntennaStatus(object sender, RfidEventArgs <RfidRdrAntennaStatus> e) { }
protected virtual void OnScanTag(RfidEventArgs e) { TagReadEvent?.Invoke(this, e); }