#182 WIP work on PLC PSIL

This commit is contained in:
Mikayla Fischler
2023-04-08 00:38:46 -04:00
parent 6ea530635f
commit 9bc4f0f7a6
5 changed files with 128 additions and 37 deletions

View File

@@ -51,6 +51,19 @@ function psil.create()
self.ic[key].value = value
end
-- publish a toggled boolean value to a given key, passing it to all subscribers if it has changed<br>
-- this is intended to be used to toggle boolean indicators such as heartbeats without extra state variables
---@param key string data key
function public.toggle(key)
if self.ic[key] == nil then alloc(key) end
self.ic[key].value = self.ic[key].value == false
for i = 1, #self.ic[key].subscribers do
self.ic[key].subscribers[i].notify(self.ic[key].value)
end
end
return public
end