Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/axiom logic #353

Merged
merged 4 commits into from
Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions drivers/rhb_access/axiomroomlogic.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require "placeos-driver"

class RHBAccess::AxiomRoomLogic < PlaceOS::Driver
descriptive_name "Room Access Logic for Axiom rooms"
generic_name :RoomAccess
description "Abstracts room access for Axiom"

default_settings({
axiom_door_ids: [] of String,
})

accessor axiom : AxiomXa

@door_ids = [] of String

def on_load
on_update
end

def on_update
@door_ids = setting(Array(String), :axiom_door_ids)
end

def lock
@door_ids.map { |d| axiom.lock(d) }
self["locked_at"] = Time.local
self["doors_locked"] = true
end

def unlock
@door_ids.map { |d| axiom.unlock(d) }
self["unlocked_at"] = Time.local
self["doors_locked"] = false
end
end
2 changes: 1 addition & 1 deletion drivers/rhb_access/axiomxa.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require "axio"

class RHBAccess::Axiomxa < PlaceOS::Driver
descriptive_name "RHB Access Axiomxa"
generic_name :Campus
generic_name :AxiomXa
uri_base "http://127.0.0.1:60001"

alias Client = Axio::Client
Expand Down