godoor/wiegand_mock.go

38 lines
597 B
Go
Raw Normal View History

2023-07-28 22:22:26 +00:00
package main
import (
2023-07-29 22:03:52 +00:00
"log"
2023-07-28 22:22:26 +00:00
"time"
)
type WiegandMock struct {
mockUid uint64
2023-07-29 17:04:19 +00:00
openState bool
}
func (w *WiegandMock) OpenDoor() error {
2023-07-29 22:03:52 +00:00
log.Println("DOOR: Opened")
2023-07-29 17:04:19 +00:00
w.openState = true
return nil
}
func (w *WiegandMock) CloseDoor() error {
2023-07-29 22:03:52 +00:00
log.Println("DOOR: Closing")
2023-07-29 17:04:19 +00:00
w.openState = false
return nil
2023-07-28 22:22:26 +00:00
}
2023-07-29 17:04:19 +00:00
func (w *WiegandMock) IsDoorOpen() (bool, error) {
return w.openState, nil
2023-07-28 22:22:26 +00:00
}
func (w *WiegandMock) GetCardUid() (uint64, error) {
time.Sleep(1 * time.Second)
2023-07-29 17:04:19 +00:00
return w.mockUid, nil //fmt.Errorf("err")
2023-07-28 22:22:26 +00:00
}
func (w *WiegandMock) SetMockUid(mockUid uint64) {
w.mockUid = mockUid
}