1 /* dummy-ups.h - NUT testing driver and repeater 2 3 Copyright (C) 4 2005 - 2012 Arnaud Quette <http://arnaud.quette.free.fr/contact.html> 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 */ 20 21 /* This file lists all valid data with their type and info. 22 * 23 * These are then enabled through a definition file, specified 24 * as the "port" parameter (only the file name, not the path). 25 * 26 * The format of this file is the same as an upsc dump: 27 * 28 * <varname>: <value> 29 * 30 * FIXME: use cmdvartab for conformance checking 31 * ... 32 * Once the driver is loaded: 33 * - change the value by using upsrw 34 * - ?you can add new variables and change variable values by 35 * editing the definition file? 36 */ 37 38 /* from usbhid-ups.h */ 39 /* --------------------------------------------------------------- */ 40 /* Struct & data for ups.status processing */ 41 /* --------------------------------------------------------------- */ 42 43 #if 0 /* XXX status lookup table not currently used???? */ 44 /* 45 * Status lookup table type definition 46 */ 47 typedef struct { 48 const char *status_str; /* ups.status string */ 49 int status_value; /* ups.status flag bit */ 50 } status_lkp_t; 51 52 #define STATUS_CAL (1 << 0) /* calibration */ 53 #define STATUS_TRIM (1 << 1) /* SmartTrim */ 54 #define STATUS_BOOST (1 << 2) /* SmartBoost */ 55 #define STATUS_OL (1 << 3) /* on line */ 56 #define STATUS_OB (1 << 4) /* on battery */ 57 #define STATUS_OVER (1 << 5) /* overload */ 58 #define STATUS_LB (1 << 6) /* low battery */ 59 #define STATUS_RB (1 << 7) /* replace battery */ 60 #define STATUS_BYPASS (1 << 8) /* on bypass */ 61 #define STATUS_OFF (1 << 9) /* ups is off */ 62 #define STATUS_CHRG (1 << 10) /* charging */ 63 #define STATUS_DISCHRG (1 << 11) /* discharging */ 64 65 /* 66 * Status lookup table 67 */ 68 status_lkp_t status_info[] = { 69 { "CAL", STATUS_CAL }, 70 { "TRIM", STATUS_TRIM }, 71 { "BOOST", STATUS_BOOST }, 72 { "OL", STATUS_OL }, 73 { "OB", STATUS_OB }, 74 { "OVER", STATUS_OVER }, 75 { "LB", STATUS_LB }, 76 { "RB", STATUS_RB }, 77 { "BYPASS", STATUS_BYPASS }, 78 { "OFF", STATUS_OFF }, 79 { "CHRG", STATUS_CHRG }, 80 { "DISCHRG", STATUS_DISCHRG }, 81 { "NULL", 0 }, 82 }; 83 #endif /* 0 -- not currently used??? */ 84 85 typedef struct { 86 char hid_value; /* HID value */ 87 char *nut_value; /* NUT value */ 88 } info_enum_t; 89 90 /* --------------------------------------------------------------- */ 91 /* Structure containing information about how to get/set data */ 92 /* from/to the UPS and convert these to/from NUT standard */ 93 /* --------------------------------------------------------------- */ 94 95 typedef struct { 96 const char *info_type; /* NUT variable name */ 97 int info_flags; /* NUT flags (to set in addinfo) */ 98 float info_len; /* if ST_FLAG_STRING: length of the string */ 99 /* if HU_TYPE_CMD: command value ; multiplier (or max len) otherwise */ 100 const char *default_value; /* if HU_FLAG_ABSENT: default value ; format otherwise */ 101 int drv_flags; /* */ 102 char **var_values; /* all possible values for this variable (allows to check data...) */ 103 /* FIXME: "void *" so we can have bound or enum */ 104 /* interpreter interpret; */ /* FFE: interpreter fct, NULL if not needed */ 105 } dummy_info_t; 106 107 /* data flags */ 108 #define DU_FLAG_NONE 0 109 #define DU_FLAG_INIT 1 /* intialy show element to upsd */ 110 111 /* --------------------------------------------------------------- */ 112 /* Data table (all possible info from NUT, then enable upon cong */ 113 /* --------------------------------------------------------------- */ 114 115 /* FIXME: need to enforce value check with enum or bounds */ 116 dummy_info_t nut_data[] = 117 { 118 /* Essential variables, loaded before parsing the definition file */ 119 { "ups.mfr", ST_FLAG_STRING | ST_FLAG_RW, 32, "Dummy Manufacturer", DU_FLAG_INIT, NULL }, 120 { "ups.model", ST_FLAG_STRING | ST_FLAG_RW, 32, "Dummy UPS", DU_FLAG_INIT, NULL }, 121 { "ups.status", ST_FLAG_STRING | ST_FLAG_RW, 32, "OL", DU_FLAG_INIT, NULL }, 122 /* Other known variables */ 123 { "ups.serial", ST_FLAG_STRING | ST_FLAG_RW, 32, NULL, DU_FLAG_NONE, NULL }, 124 { "ups.load", ST_FLAG_RW, 32, NULL, DU_FLAG_NONE, NULL }, 125 { "ups.alarm", ST_FLAG_STRING | ST_FLAG_RW, 32, NULL, DU_FLAG_NONE, NULL }, 126 { "ups.time", ST_FLAG_STRING | ST_FLAG_RW, 16, NULL, DU_FLAG_NONE, NULL }, 127 { "ups.date", ST_FLAG_STRING | ST_FLAG_RW, 16, NULL, DU_FLAG_NONE, NULL }, 128 { "ups.mfr.date", ST_FLAG_STRING | ST_FLAG_RW, 16, NULL, DU_FLAG_NONE, NULL }, 129 { "ups.serial", ST_FLAG_STRING | ST_FLAG_RW, 16, NULL, DU_FLAG_NONE, NULL }, 130 { "ups.firmware", ST_FLAG_STRING | ST_FLAG_RW, 16, NULL, DU_FLAG_NONE, NULL }, 131 { "ups.firmware.aux", ST_FLAG_STRING | ST_FLAG_RW, 16, NULL, DU_FLAG_NONE, NULL }, 132 { "ups.temperature", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 133 { "ups.id", ST_FLAG_STRING | ST_FLAG_RW, 16, NULL, DU_FLAG_NONE, NULL }, 134 { "ups.delay.start", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 135 { "ups.delay.reboot", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 136 { "ups.delay.shutdown", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 137 { "ups.test.interval", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 138 { "ups.test.result", ST_FLAG_STRING | ST_FLAG_RW, 16, NULL, DU_FLAG_NONE, NULL }, 139 /* 140 ups.display.language 141 ups.contacts 142 ups.power 143 ups.power.nominal 144 */ 145 { "input.voltage", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 146 { "input.voltage.maximum", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 147 { "input.voltage.minimum", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 148 { "input.voltage.nominal", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 149 { "input.transfer.reason", ST_FLAG_STRING | ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 150 { "input.transfer.low", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 151 { "input.transfer.high", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 152 { "input.sensitivity", ST_FLAG_STRING | ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 153 { "input.quality", ST_FLAG_STRING | ST_FLAG_RW, 6, NULL, DU_FLAG_NONE, NULL }, 154 { "input.frequency", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 155 { "input.transfer.boost.low", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 156 { "input.transfer.boost.high", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 157 { "input.transfer.trim.low", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 158 { "input.transfer.trim.high", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 159 { "output.voltage", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 160 { "output.frequency", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 161 { "output.current", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 162 /* 163 output.voltage.nominal 164 */ 165 { "battery.charge", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 166 { "battery.charge.low", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 167 { "battery.voltage", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 168 { "battery.current", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 169 { "battery.runtime", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 170 { "battery.runtime.low", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 171 { "battery.charge.restart", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 172 { "battery.temperature", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 173 { "battery.voltage.nominal", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 174 /* 175 battery.alarm.threshold 176 battery.date 177 battery.packs 178 battery.packs.bad 179 */ 180 { "ambient.temperature", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 181 { "ambient.temperature.alarm", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 182 { "ambient.temperature.high", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 183 { "ambient.temperature.low", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 184 { "ambient.humidity", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 185 { "ambient.humidity.alarm", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 186 { "ambient.humidity.high", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 187 { "ambient.humidity.low", ST_FLAG_RW, 1, NULL, DU_FLAG_NONE, NULL }, 188 /* 189 FIXME: how to manage these? (i.e. index <n>) 190 outlet.n.id 191 outlet.n.desc 192 outlet.n.switch 193 outlet.n.status 194 outlet.n.switchable 195 outlet.n.autoswitch.charge.low 196 outlet.n.delay.shutdown 197 outlet.n.delay.start 198 ... 199 200 driver.name 201 driver.version 202 driver.version.internal | Internal driver version | 1.23.45 | 203 driver.parameter.xxx 204 driver.flag.xxx 205 206 No need for these! 207 server.info 208 server.version 209 210 Cmds 211 load.off 212 load.on 213 shutdown.return 214 shutdown.stayoff 215 shutdown.stop 216 shutdown.reboot 217 shutdown.reboot.graceful 218 test.panel.start 219 test.panel.stop 220 test.failure.start 221 test.failure.stop 222 test.battery.start 223 test.battery.stop 224 calibrate.start 225 calibrate.stop 226 bypass.start 227 bypass.stop 228 reset.input.minmax 229 reset.watchdog 230 beeper.enable 231 beeper.disable 232 */ 233 234 /* end of structure. */ 235 { NULL, 0, 0, NULL, DU_FLAG_NONE, NULL } 236 }; 237