godoor/wiegand_mock.go
2023-07-30 01:03:52 +03:00

38 lines
597 B
Go

package main
import (
"log"
"time"
)
type WiegandMock struct {
mockUid uint64
openState bool
}
func (w *WiegandMock) OpenDoor() error {
log.Println("DOOR: Opened")
w.openState = true
return nil
}
func (w *WiegandMock) CloseDoor() error {
log.Println("DOOR: Closing")
w.openState = false
return nil
}
func (w *WiegandMock) IsDoorOpen() (bool, error) {
return w.openState, nil
}
func (w *WiegandMock) GetCardUid() (uint64, error) {
time.Sleep(1 * time.Second)
return w.mockUid, nil //fmt.Errorf("err")
}
func (w *WiegandMock) SetMockUid(mockUid uint64) {
w.mockUid = mockUid
}