Date: Sat, 20 Jan 1996 14:26:43 +0300 (MSK) From: "Alexis Yushin" <alexis@dawn.ww.net> To: upsd-list@ww.net, hackers@freebsd.org Subject: Generic UPS daemon design. Message-ID: <199601201126.OAA04697@dawn.ww.net>
next in thread | raw e-mail | index | archive | help
Greetings, I have attached DESIGN of the upsd I am developping to the end of this letter. I hope this is a good start for working out an idea of what the generic daemon will look like. I have created a majordomo driven list called ``upsd-list@ww.net'' for ups specific discussions to ease the burden of freebsd-hackers list. I also took courage to subscribe interested people who have written me to that list. Mail me if I did wrong. alexis -------- DESIGN BLURB ----- This is the second release of UPS Daemon. The first release is the simplest UPS daemon with no ability to interact with an UPS on an advanced level. The first release is available from: ftp://ftp.ww.net/pub/wildwind/upsd-1.1.tgz This second release is logically divided into following blocks: - run-time configuration block (config.y) - generic events and actions implementation (event.c) - generic hardware communication (port.c) - ups-specific interaction blocks (apc.c) TERMINOLOGY ----------- REGISTER (struct ups_reg) is a generic mean of interaction with UPS. A register can be one or more of the following types: R_COMMAND -- the register specifies a command like, self-test, shutdown, value toggle etc and has no value associated with it. R_INFO -- the register has a value of informational kind: ups manufacture date, last batteries replacement etc R_STATUS -- this register value reflects current status of an UPS and should be read from time to time. R_OPTION -- this register contains ups-specific setting, like nominal output voltage, delay before shutting down etc Every register has a char * name for reference from configuration file inside events or actions. The same thing is true for triggers. TRIGGER (struct ups_trig) is a generic way of handling immediate events like utility power line failure or restore. A trigger is like a UNIX signal, and handled by UPS daemon asycronously. EVENT (struct ups_event) is actually a condition. The form of specifying an event in an upsd configuration is: [on trigger-name] [after n] [for n] [every n] actions or [on register-name condition] [after n] [for n] [every n] actions The parts after, for, every specify the time when the actions will be executed. If after n is omitted or n is zero the actions will be executing immediately when the event occured. If for n is omitted or zero the actions will be executing while the event is active. Finally, if every is omitted or zero the actions will be executed only once. When on trigger-name or on register-name part are omitted the actions will be executing anyway dependinig on the time specified with the rest of the configuration command. on trigger-name is active when trigger-name is caught. on register name condition is active when condition is true. ACTION (struct ups_act) can be of the following types: A_EVENT -- embedded event, and the event is checked when the action is executed. A_POLL -- causes a poll of the specified register. There should be an independed event which polls register for other events to work. A_TUNE -- tunes the specified register. Usually the register should be of R_OPTION type. A_RAISE -- raises an event as if it was triggered by an UPS A_EXCEED -- disactivates an event. A_EXECUTE -- executes an internal command. Sigh. A_SLEEP -- usually events are executed asyncronously this action just sleeps depriving anything exept triggers to be handled. CONFIGURATION FILE ------------------ Here follows an example of what is intended to be implemented. ups "SmartUPS" (240) "APCSmart" { device "/dev/cuaa0" speed 2400 timeout 10 } every 60 { # poll the UPS poll "line-voltage" poll "line-frequency" poll "line-max-vdc" poll "line-min-vdc" poll "measured-temperature" tune "shutdown-delay" 20 tune "wakeup-delay" 300 } every 3600 { poll "self-test" } on "last-test-result" != "OK" { exec "echo UPS SELF TEST FAILED! | wall" } on "line-failure" after 10 every 30 { exec "echo Line failure occured. | wall" exec "rsh sunset 'sh -c echo Line failure occured. | wall'" } on "line-restore" after 10 { exceed "line-failure" exec "echo Line has restored. | wall" exec "rsh sunset 'sh -c echo Line has restored. | wall'" } on "line-failure" after 180 { # shutdown on "line voltage" < 30 { # lets make sure there's no line v exec "rsh sunset 'sh -c echo Shutting down. | wall'" exec "echo Shutting down. | wall" exec "rsh sunset /sbin/halt" exec "/sbin/halt" every 2 { poll "shutdown" } } } -- The more experienced you are the less people you can get advice from.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199601201126.OAA04697>