commented pppc-sample.ini a bit, filled out the event handlers in pppc.cc more
git-svn-id: http://apu.dw.local/svnusers/JoshHoltrop/pppc/trunk@57 8131a0b2-b21c-1c47-bd6a-f003126495bd
This commit is contained in:
parent
2dd4be5a62
commit
16e33fafa7
@ -1,8 +1,30 @@
|
||||
|
||||
; Global options
|
||||
;###########################################################################
|
||||
;# Global options section #
|
||||
;###########################################################################
|
||||
|
||||
; port = <which Windows parallel port device to control>
|
||||
port = LPT1
|
||||
|
||||
[Light]
|
||||
;###########################################################################
|
||||
;# Entry section #
|
||||
;###########################################################################
|
||||
; Entry format:
|
||||
; [Entry_Name]
|
||||
; pin = <parallel port data line number to control> (required)
|
||||
; on_start = <action upon program start>
|
||||
; on_exit = <action upon program exit>
|
||||
; on_lock = <action upon workstation lock event>
|
||||
; on_unlock = <action upon workstation unlock event>
|
||||
|
||||
; Actions:
|
||||
; on - turn the controller on
|
||||
; off - turn the controller off
|
||||
; none - do not change the controller (default if an event is unspecified)
|
||||
; previous - only used for unlock events - restores state to what it was
|
||||
; when the lock event ocurred
|
||||
|
||||
[Overhead Light]
|
||||
pin = 7
|
||||
on_start = on
|
||||
on_exit = off
|
||||
@ -11,7 +33,6 @@ on_unlock = on
|
||||
|
||||
[Fan]
|
||||
pin = 6
|
||||
on_start = off
|
||||
on_exit = off
|
||||
on_lock = off
|
||||
on_unlock = previous
|
||||
|
46
pppc.cc
46
pppc.cc
@ -241,17 +241,63 @@ void PPPC::event_start()
|
||||
|
||||
void PPPC::event_exit()
|
||||
{
|
||||
for (int sz = m_config.entries.size(), i = 0; i < sz; i++)
|
||||
{
|
||||
switch (m_config.entries[i].on_exit)
|
||||
{
|
||||
case Config::ON:
|
||||
SET_BIT(m_pins, m_config.entries[i].pin, 1);
|
||||
break;
|
||||
case Config::OFF:
|
||||
SET_BIT(m_pins, m_config.entries[i].pin, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
update_pins();
|
||||
}
|
||||
|
||||
void PPPC::event_lock()
|
||||
{
|
||||
for (int sz = m_config.entries.size(), i = 0; i < sz; i++)
|
||||
{
|
||||
switch (m_config.entries[i].on_lock)
|
||||
{
|
||||
case Config::ON:
|
||||
SET_BIT(m_pins, m_config.entries[i].pin, 1);
|
||||
break;
|
||||
case Config::OFF:
|
||||
SET_BIT(m_pins, m_config.entries[i].pin, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
update_pins();
|
||||
m_previous_pins = m_pins;
|
||||
}
|
||||
|
||||
void PPPC::event_unlock()
|
||||
{
|
||||
for (int sz = m_config.entries.size(), i = 0; i < sz; i++)
|
||||
{
|
||||
switch (m_config.entries[i].on_unlock)
|
||||
{
|
||||
case Config::ON:
|
||||
SET_BIT(m_pins, m_config.entries[i].pin, 1);
|
||||
break;
|
||||
case Config::OFF:
|
||||
SET_BIT(m_pins, m_config.entries[i].pin, 0);
|
||||
break;
|
||||
case Config::PREVIOUS:
|
||||
SET_BIT(m_pins, m_config.entries[i].pin,
|
||||
GET_BIT(m_previous_pins, m_config.entries[i].pin));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
update_pins();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user