common_config.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. /*
  2. * Copyright (c) 2019 Clementine Computing LLC.
  3. *
  4. * This file is part of PopuFare.
  5. *
  6. * PopuFare is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * PopuFare 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 Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with PopuFare. If not, see <https://www.gnu.org/licenses/>.
  18. *
  19. */
  20. #ifndef _COMMON_CFG
  21. #define _COMMON_CFG
  22. //-----------------------------------------------------------------
  23. //------------------------ OPERATIONAL THRESHOLDS AND MAGIC STRINGS
  24. //-----------------------------------------------------------------
  25. #define MOTION_THRESHOLD (0.5f) //we're moving if our velocity exceeds 0.5 m/sec
  26. #define ROLLOVER_TIME_WINDOW (10 * 60) //We count a stop as an option to roll over to if we're within +/- ROLLOVER_TIME_WINDOW seconds
  27. #define ROLLOVER_DISTANCE (60.0f) //We count a stop as an option to roll over to if we are also within ROLLOVER_DISTANCE meters of its GPS location
  28. #define MIN_SATS_FOR_TIME (3) //We are willing to set the system clock if we have at least this many GPS satellites in view
  29. #define MAX_GPS_CLOCK_DRIFT (10) // We insist in setting the system clock if it has drifted from GPS time by more than
  30. //MAX_GPS_CLOCK_DRIFT seconds (provided we have at least MIN_SATS_FOR_TIME satellites in view).
  31. #define GPS_DATE_CENTURY (2000) // For fuck's sake, NMEA GPS dates are not Y2K compliant and use only two digits. We
  32. //must assume a century, we'll assume it is the 21st century.
  33. #define GPS_STALE_THRESHOLD (5) //If we go five seconds without a GPS update we consider our GPS signal kaput.
  34. #define CLEAR_GPS_ON_STALE //Define this if we want to clear all GPS values when we make a valid --> stale transition.
  35. #define ROLLOVER_FORWARD_ONLY //Define this if you want to prevent rollover to a lesser or equal paddle stop
  36. #define ROLLOVER_TO_FURTHEST_STOP // Define this if you want the rollover keep hunting after the first match to
  37. //find the LAST stop in the paddle which meets the time and location criteria.
  38. //this is desirable if you have a route change where a bus arrives at a stop as
  39. //one route and turns into another at that stop and you want this corner case to
  40. //board all riders with the rules for the route the bus will LEAVE the stop as.
  41. #define ACCEPT_STR "ACCEPT"
  42. #define REJECT_STR "REJECT"
  43. #define PASSBACK_STR "PASSBACK"
  44. // This makes the passdb module reject a card offhand (but not put it in the billing log)
  45. //if there is no driver logged in. This will also cause the driver's console to beep a reject beep
  46. //which will serve as a reminder to log in...
  47. //#define REJECT_IF_NO_DRIVER
  48. // This define makes the passdb module's rule engine enter a debugging mode for the NEXT call of a rule which
  49. //asserted scheme_error during its last execution. This debugging mode generates quite verbose debug information (pages)
  50. //tracing every action taken by the scheme interpreter, and which order they occurred in, such that we on the server side
  51. //can see immediately where the bug is in a rule that is crashing in the field.
  52. #define TRACE_NEXT_CALL_OF_FAILED_RULE
  53. // This define makes the passdb module's rule engine take the debugging output from the rule call under trace and write it
  54. //in a file called "/tmp/RULE-NAME.trace" (replacing any previous contents) which will un-clog the diagnostic log with
  55. //unsolicited traces, but it will require us to log in remotely to the bus in question and snag its trace dropfiles over the
  56. //reverse-phone-home mechanism.
  57. #define TRACE_RULE_CALL_TO_FILE
  58. #define MAGIC_DRIVER_NAME "AdminMode" //A magic string that appears as the driver name for the driver login that goes to admin mode
  59. #define MACIC_DRIVER_MENU "admin" //The name of the menu to go to when this driver logs in
  60. #define PASSENGER_MESSAGE_DURATION (5) //How long to leave passenger messages up on the PIU display line 2
  61. #define PIU_DEVICE_ID "rider_ui" //Device ID returned in the "/?:" line from the PIU
  62. #define DIU_DEVICE_ID "driver_ui" //Device ID returned in the "/?:" line from the DIU
  63. #define ACCUM_SECONDS (1) //Number of seconds to wait for an EOL from a serial port
  64. //before declaring the line ended (see notes on open_rs232_device()
  65. //in common_defs.h for more details).
  66. #define DEVICE_TEST_TRIES (3) //How many times to try asking what a connected device is...
  67. #define DEVICE_TEST_TIMEOUT (5000) //How long to wait for a device ID line (in milliseconds) after sending a "\r" for each try
  68. #define MAX_EQUIPNUM (9999) //What is the largest allowable equipment number...
  69. //#define BEEP_WITH_MAGSTRIPE_READER
  70. #ifdef BEEP_WITH_MAGSTRIPE_READER
  71. //These are used for the beeping that the driver user interface performs:
  72. #define PIU_ACK_BEEP(fd) if((fd)>=0){write(fd, "/m:7A\r", 6);}
  73. #define PIU_ERROR_BEEP(fd) if((fd)>=0){write(fd, "/m:5A\r", 6); usleep(500000); write(fd, "/m:5A\r", 6);}
  74. #define PIU_CRITICAL_BEEP(fd) if((fd)>=0){write(fd, "/m:5A\r", 6); usleep(500000); write(fd, "/m:5A\r", 6);write(fd, "/m:5A\r", 6); usleep(500000); write(fd, "/m:5A\r", 6);write(fd, "/m:5A\r", 6); usleep(500000); write(fd, "/m:5A\r", 6);write(fd, "/m:5A\r", 6); usleep(500000); write(fd, "/m:5A\r", 6);write(fd, "/m:5A\r", 6); usleep(500000); write(fd, "/m:5A\r", 6);}
  75. //These are used for the beeping that the driver user interface performs:
  76. #define DIU_BUTTON_BEEP(fd) if((fd)>=0){beep((fd), 440, 25);}
  77. #define DIU_ACK_BEEP(fd) if((fd)>=0){}
  78. #define DIU_ERROR_BEEP(fd) if((fd)>=0){}
  79. #define DIU_CRITICAL_BEEP(fd) if((fd)>=0){}
  80. #else
  81. //These are used for the beeping that the driver user interface performs:
  82. #define DIU_BUTTON_BEEP(fd) if((fd)>=0){beep((fd), 0xA50, 25);}
  83. #define DIU_ACK_BEEP(fd) if((fd)>=0){beep((fd), 0xA50, 75);}
  84. #define DIU_ERROR_BEEP(fd) if((fd)>=0){beep((fd), 0xDC0, 250); beep((fd), 0, 50); beep((fd), 0xDC0, 250);}
  85. #define DIU_CRITICAL_BEEP(fd) if((fd)>=0){beep((fd), 0xDC0, 1000); beep((fd), 0, 50); beep((fd), 0xDC0, 1000);}
  86. #endif
  87. //This is the threshold of time between duplicate driver notifies before which the beep will be supressed
  88. //(so that bulk-accepting 15 interline fares won't result in an enormous string of accept beeps for instance)
  89. #define DUP_USEC_BEEP_THRESHOLD (500000) // 5/10th of a second
  90. //This is the maximum number of times we'll be willing to
  91. //catch a SIGINT, SIGTERM, or IPC message exit request before forcing an exit
  92. #define MAX_POLITE_EXIT_REQUESTS (2)
  93. #define APB_ROW_EXPIRE (30 * 60) //Expire a passback entry in 30 minutes if it is still in the cache
  94. #define APB_DIST_EXPIRE (100.0f) //Expire the whole passback cache if the bus has moved at least APB_DIST_EXPIRE meters since the last accept
  95. #define POLL_TIMEOUT (1000) //How many milliseconds to wait each time through the poll loop of each module
  96. #define DEFAULT_CONNECT_RETRY (60) //How many seconds to wait before attempting to reconnect to a forwarded port
  97. #define DEFAULT_BILL_SYNC_RETRY (1 * 60) //How many seconds before reinitiating data transfer to billing server for any given log entry
  98. #define DEFAULT_PASS_SYNC_RETRY (2 * 60) //How many seconds before re-querying the buspass server for updates
  99. #define AVLS_MOTION_INTERVAL (2 * 60) //How often to send AVLS chirps when in motion (in seconds) (default, see config)
  100. #define AVLS_STILL_INTERVAL (60 * 60) //How often to send AVLS chirps when still (in seconds) (default, see config)
  101. #define HUB_RETRY_TIME (3) //Number of seconds between connection retries if the IPC hub cannot be found.
  102. #define PADDLE_REQ_TIMEOUT (15) //How long to wait for a paddle request to time out.
  103. #define ALPHA_MAX ((unsigned) 255) //Alpha value representing 100% opaque
  104. #define ALPHA_DRK ((unsigned) 192) //Alpha value for dark blendovers
  105. #define ALPHA_LGT ((unsigned) 128) //Alpha value for light blendovers
  106. #define SHADOW_OFFSET_UP (5) //How many pixels to offset the shadow under a unpressed button.
  107. #define SHADOW_OFFSET_DOWN (2) //How many pixels to offset the shadow under a pressed button.
  108. #define TS_CALIB_HOLD_TIME (15) //How long the user has to hold down the touchscreen to initiate a calibration
  109. #define SHELLCALL_VAR_ESC ('~') //What character brackets variable expansion in shellcall actions
  110. //-----------------------------------------------------------------
  111. //------------------------ CONFIGURATION FLAGS
  112. //-----------------------------------------------------------------
  113. //if USE_WATCHDOG_ALARM is defined, the individual modules will
  114. //use a SIGALRM handler as a watchdog timer.
  115. #define USE_WATCHDOG_ALARM
  116. //Define ALLOW_CREDENTIAL_COLLISIONS if you want to allow duplicate credential entries to exist.
  117. //This essentially states that you belive file corruption to be less of a risk than administrator error
  118. //when dealing with the active pass table.
  119. #define ALLOW_CREDENTIAL_COLLISIONS
  120. //Define ALLOW_WILDCARD_MAGSTRIPE_TRACK if you'd like to allow the pass database to contain magstripe credentials
  121. //with a special track number of zero which will match data on ANY track (only after trying each track against a
  122. //track-specific match, to reduce the likelyhood of unintended collisions). See comments in the magstripe lookup
  123. //function smart_find_mag() that lives in passdb/rules.c for a more detailed description.
  124. #define ALLOW_WILDCARD_MAGSTRIPE_TRACK
  125. //Define SCRUB_MAGSTRIPE_TRACK[123] if you want to ignore (not look up and not log)
  126. //the specified tracks if they appear to contain the type of field delimiter specified by the banking
  127. //standards for credit or debit cards. The T[123]_SCRUB_LIST macros contain the list of characters that
  128. //will trigger the system to ignore the data on that track when the corresponding SCRUB_ macro is defined.
  129. #define SCRUB_MAGSTRIPE_TRACK1
  130. #define T1_SCRUB_LIST ("^")
  131. #define SCRUB_MAGSTRIPE_TRACK2
  132. #define T2_SCRUB_LIST ("=")
  133. //In practice, there is little (that I know of) reason to scrub track 3, so we don't waste the CPU cycles.
  134. //#define SCRUB_MAGSTRIPE_TRACK3
  135. //#define T3_SCRUB_LIST ("")
  136. #ifdef USE_WATCHDOG_ALARM
  137. //How many seconds can a module go without running through its main
  138. //loop (and resetting its watchdog) before it kills itself
  139. #define MODULE_WATCHDOG_VALUE (60)
  140. #endif
  141. // Uncomment this definition if you want to directly write to the frame buffer rather than
  142. //having the UI engine batch changes and present them synchronously when present_framebuffer() is called.
  143. // This method saves the RAM taken by a shadow frame buffer at the expense of some perceived display
  144. //flicker as the framebuffer will often contain (and display) partially drawn widgets for a frame while the
  145. //UI engine is busy drawing the rest of them. This method is also slower for read-modify-write type framebuffer
  146. //operations since the framebuffer is marked non-cacheable so that the DMA controller that scans the framebuffer
  147. //will always see changes that occur.
  148. //#define FRAMEBUFFER_NO_SOFTWARE_BACKBUFFER
  149. #ifndef FRAMEBUFFER_NO_SOFTWARE_BACKBUFFER
  150. #define FRAMEBUFFER_SOFTWARE_BACKBUFFER
  151. #endif
  152. //#define USE_REMOTE_UI
  153. #ifdef USE_REMOTE_UI
  154. #define FB_SHADOW_TMP "/tmp/fb_shadow.tmp"
  155. #define FB_SHADOW_FILE "/tmp/fb_shadow"
  156. #endif
  157. // Uncomment this if you want the application to return the video framebuffer's colormap
  158. //to the state it was in then the application launched (If we need to be compatible with other
  159. //3rd party framebuffer applications that expect a standard VGA palette for instance) after it exits.
  160. // Mostly, we are going to run another instance of ourselves, or one of the showmessage programs
  161. //so there is no harm in keeping the palette the way we like it and it prevents flicker and user
  162. //confusion. So, yeah, really, don't uncomment FRAMEBUFFER_RESTORE_PALETTE unless you really mean it.
  163. //#define FRAMEBUFFER_RESTORE_PALETTE
  164. //--------------------------------
  165. // When ZFLUSH_SLOW_BUT_SAFE is set, after retrieving a compressed bulk update
  166. //the flush process goes and calls msync() (or emulates it on jffs2) for each
  167. //individual record, in order. This makes sure that a powerdown mid-write will
  168. //preserve everything that has been extracted up to that time. On the other hand,
  169. //that may not be optimal behavior (if we get half way through a compressed flush,
  170. //and then reboot and have to finish uncompressed, it'll take for ever...)
  171. //
  172. // The alternative is ZFLUSH_ONE_SHOT which applies all of the changes without
  173. //forcing a sync, and then writes the file in one big chunk once its done.
  174. //#define ZFLUSH_SLOW_BUT_SAFE
  175. //By default, if we don't pick the "slow but safe" option, we go for the one shot option because:
  176. // A) The file system journal SHOULD pick up the slack.
  177. // B) The one-shot write provides the filesystem with a good defragment and erase-block coalesce opportunity (for jffs-ish filesystem)
  178. // C) The super-caps should hold the viper up longer than it actually takes to do the file system write except under dire conditions, then see condition A.
  179. #ifndef ZFLUSH_SLOW_BUT_SAFE
  180. #define ZFLUSH_ONE_SHOT
  181. #endif
  182. //Do a little idiot-proofing on this config value since it could result in strange/data-losing behavior
  183. //if both values are defined at once.
  184. #ifdef ZFLUSH_SLOW_BUT_SAFE
  185. #ifdef ZFLUSH_ONE_SHOT
  186. #error "Cannot have both ZFLUSH_ONE_SHOT and ZFLUSH_SLOW_BUT_SAFE defined at once!"
  187. #endif
  188. #endif
  189. //If COMMHUB_O_NONBLOCK is defined, the IPC hub will maintain all of its clients in
  190. //nonblocking mode and cut anybody loose who doesn't respond.
  191. #define COMMHUB_O_NONBLOCK
  192. //If TOUCHSCREEN_QUIET is defined we request the touchscreen not send data between making a UI change and flushing it to
  193. //the display... This can reduce latency on a heavily loaded system at the expense of stability (it becomes easy to miss
  194. //a pen up event). Don't define this unless you really mean it...
  195. //#define TOUCHSCREEN_QUIET
  196. //These constraints are useful because on buses that have extremely funky or barely-sufficent power, they can fill
  197. //their billing logs (and thus the modem pipe, bandwidth limit, and database tables) with rapid-fire updates on how
  198. //crappy their input power is. I have seen busses that complain about this for hours on end, so this limits the damage
  199. //done by those buses until somebody can go fix their wiring...
  200. //how many DIU error messages to accept before rate-limiting
  201. #define DIU_ERROR_BURST_LIMIT (5)
  202. //number of seconds before allowing another DIU error message to be logged
  203. //after exhausting the number allotted by DIU_ERROR_BURST_LIMIT
  204. #define DIU_ERROR_RATE_LIMIT (120)
  205. //----------------------------------------------------------------
  206. //------------------------ PATH NAMES OF SPECIAL FILES AND DEVICES
  207. //----------------------------------------------------------------
  208. //IPC hub related stuff
  209. #define COMMHUB_ADDRESS "/tmp/commhub"
  210. //Configuration File Paths
  211. #ifdef TARGET_DEVEL_DESKTOP
  212. //#define CONFIG_FILE_PATH "./"
  213. #define CONFIG_FILE_PATH "/home/bus/config/"
  214. #else
  215. #define CONFIG_FILE_PATH "/mnt/data2/config/"
  216. #endif
  217. //Database File Paths
  218. #ifdef TARGET_DEVEL_DESKTOP
  219. //#define DATABASE_FILE_PATH "./"
  220. #define DATABASE_FILE_PATH "/home/bus/database/"
  221. #else
  222. #define DATABASE_FILE_PATH "/mnt/data2/database/"
  223. #endif
  224. //Executable File Paths
  225. #ifdef TARGET_DEVEL_DESKTOP
  226. //#define EXECUTABLE_FILE_PATH "./"
  227. #define EXECUTABLE_FILE_PATH "/home/bus/bin/"
  228. #else
  229. #define EXECUTABLE_FILE_PATH "/mnt/data2/bin/"
  230. #endif
  231. //Local database files
  232. #define BILLING_FILE (DATABASE_FILE_PATH "billing.mem")
  233. #define PASSES_FILE (DATABASE_FILE_PATH "passes.mem")
  234. #define QRSEED_FILE (DATABASE_FILE_PATH "qr.seed")
  235. //Local configuration files
  236. #define DRIVER_MENU_FILE (CONFIG_FILE_PATH "menu.xml")
  237. #define DRIVERS_FILE (CONFIG_FILE_PATH "drivers.txt")
  238. #define SCHEME_INIT_FILE (CONFIG_FILE_PATH "init.scm")
  239. #define RULES_FILE (CONFIG_FILE_PATH "rules.scm")
  240. #define EQUIPNUM_FILE (CONFIG_FILE_PATH "equipnum.txt")
  241. #define EQUIPNUM_TEMPFILE (CONFIG_FILE_PATH "equipnum.tmp")
  242. #define RFID_PATTERN_FILE (CONFIG_FILE_PATH "rfid_patterns.txt")
  243. #define TOUCHSCREEN_CALIB_FILE (CONFIG_FILE_PATH "touchscreen_calib.txt")
  244. #define AVLS_CONFIG_FILE (CONFIG_FILE_PATH "avls_freq.txt")
  245. #define STATE_INFO_FILE (CONFIG_FILE_PATH "state.info")
  246. #define STATE_INFO_TEMPFILE (CONFIG_FILE_PATH "state.tmp")
  247. #define SERVER_LIST_FILE (CONFIG_FILE_PATH "server/server_list")
  248. #define SERVER_DESC_FILE (CONFIG_FILE_PATH "server/server_desc")
  249. //Network status notification files
  250. #define TUNNEL_DROPFILE "/tmp/tunnel-is-up"
  251. #define GPRS_DROPFILE "/tmp/network-is-up"
  252. // Serial port mapping
  253. //
  254. #ifdef TARGET_DEVEL_DESKTOP
  255. #define CONSOLE_PORT "/dev/ttyCONSOLE"
  256. #define DRIVER_UI_PORT "/tmp/ttyDIU"
  257. #define PASSENGER_UI_PORT "/dev/ttyPIU"
  258. #define MODEM_PORT "/dev/ttyGPRS"
  259. #define GPS_PORT "/dev/ttyGPS"
  260. #else
  261. // Legacy
  262. //
  263. #define CONSOLE_PORT "/dev/ttyS0"
  264. #define DRIVER_UI_PORT "/dev/ttyS1"
  265. #define PASSENGER_UI_PORT "/dev/ttyS2"
  266. #define MODEM_PORT "/dev/ttyS3"
  267. #endif
  268. // Network protocol ports
  269. //
  270. #define PASS_SERVER_IP "127.0.0.1"
  271. #define PASS_SERVER_PORT (7277)
  272. #define BILL_SERVER_IP "127.0.0.1"
  273. #define BILL_SERVER_PORT (2455)
  274. #define AVLS_SERVER_IP "127.0.0.1"
  275. #define AVLS_SERVER_PORT (2857)
  276. #define HELLO_SERVER_IP "127.0.0.1"
  277. #define HELLO_SERVER_PORT (3556)
  278. // Framebuffer location: (legacy)
  279. //
  280. #define CONFIG_FRAMEBUFFER_PATH "/dev/fb0"
  281. //----------------------------------------------------------------
  282. //------------------------ DATA SIZE CONFIGURATION VALUES
  283. //----------------------------------------------------------------
  284. // This is the size of the buffer used to read lines from sockets and serial ports.
  285. // reads longer than this will either be truncated, or trigger an exit-with-error
  286. // Any sadistic bastard who writes config file lines longer than 1KB (that would be
  287. // half a screen-full to the character on a standard 80x25 text screen!) deserves some
  288. // rude truncation.
  289. //
  290. #define LINE_BUFFER_SIZE (1024)
  291. // This is the hardware page size for the mmap()'d data files:
  292. //
  293. #define MEMORY_PAGE_SIZE (4096)
  294. // This is the maximum size of a command line that can be assembled by the driver UI menu system using the <shellcall/> action.
  295. //
  296. #define SHELLCALL_BUFFER_SIZE (2048)
  297. //This defines the expected size of the pass database and its RAM based index tables:
  298. //
  299. //#define NUM_STORED_PASSES (131072) //A nice round number that multiplies by sizeof(rider_record) to a page boundary
  300. //#define STORED_PASS_HASH (131101) //A prime number larger than NUM_STORED_PASSES
  301. //#define NUM_STORED_PASSES (262144) //A nice round number that multiplies by sizeof(rider_record) to a page boundary
  302. //#define STORED_PASS_HASH (262147) //A prime number larger than NUM_STORED_PASSES
  303. #define NUM_STORED_PASSES (1048576) //A nice round number that multiplies by sizeof(rider_record) to a page boundary
  304. #define STORED_PASS_HASH (1048583) //A prime number larger than NUM_STORED_PASSES
  305. //This defines the expected size of the billing cache:
  306. #define NUM_BILLING_ENTRIES (2048) //A nice round number that multiplies by sizeof(billing_record)
  307. //to be an integer number of MMU pages (for the benefit of efficient and
  308. //transaction safe msync() calls.
  309. // Thresholds for high-water-mark warnings on the billing log. These cause the system to warn the driver
  310. //when there are fewer than X free entries in the billing log file. A prolonged time without connectiviry to
  311. //the billing log server where rows can be offloaded from the local cache to the main database is usually the
  312. //underlying cause of this condition. The goal here is to issue frequent and annoying warnings to the driver
  313. //when the situation has gotten dangeriously bad such that they will call dispatch and the bus will be serviced.
  314. //
  315. #define BILLING_HIGH_THRESHOLD (NUM_BILLING_ENTRIES / 2) //Warn the driver at the half-way mark
  316. #define BILLING_CRITICAL_THRESHOLD (NUM_BILLING_ENTRIES / 4) //at 3/4 full, start really bitching about it
  317. #define BILLING_HIGH_FREQUENCY (60 * 15) //Warn every fifteen minutes after the half-way mark
  318. #define BILLING_CRITICAL_FREQUENCY (60 * 5) //Warn every 5 minutes at the 3/4 mark
  319. #define REJECT_DIAG_DEBUG_THRESHOLD (BILLING_HIGH_THRESHOLD) //Reject diagnostic debug messages when log space is more than half full
  320. #define REJECT_DIAG_WARN_THRESHOLD (BILLING_CRITICAL_THRESHOLD) //Reject diagnostic warning messages when log space is more than 3/4 full
  321. #define REJECT_DIAG_ERROR_THRESHOLD (BILLING_CRITICAL_THRESHOLD) //Reject diagnostic critical messages when log space is more than 3/4 full
  322. //This defines the size of the anti-passback-cache
  323. #define APB_CACHE_SIZE (128)
  324. //This defines the maximum number of stops in a paddle
  325. #define MAX_PADDLE_SIZE (1024)
  326. // This constant defines how deep down the rabbit hole of nested XML tags we will allow our parser to traverse when reading
  327. //a menu.xml file defining the behavior of the driver facing user interface. This is NOT how deep the user-facing menu tree
  328. //can become. That is not clearly defined yet, and since it may not be predictable until after the XML tree is parsed, it
  329. //very well may need to be a runtime value that is dynamically allocated after the UI engine analizes the contents of the XML
  330. //tree. Alternately, if memory is not too tight, a double-the-reasonable-max type engineering tolerance estimate could produce
  331. //a statically allocated menu execution tree and thus reduce memory fragmentation and heap thrash.
  332. #define MENU_STACK_DEPTH (32)
  333. // This is the size of the buffer used to load the menu.xml file. It doesn't have to fit the whole file,
  334. //it just determines how many times we have to go back to the "disk" to fetch and parse the whole file.
  335. //4K seems like a reasonable block size.
  336. #define XML_CHUNK_SIZE (4096)
  337. // This is the maximum length of actuall DIU display messages
  338. #define DIU_MESSAGE_CHARS (80)
  339. // This is how many lines to maintain
  340. #define DIU_MESSAGE_LINES (25)
  341. // This is the number of Raw->site:id mapping schemes supported for RFID decoding
  342. #define NUM_RFID_PATTERNS (64)
  343. //----------------------------------------------------------------
  344. //------------------------ SYSTEM SUPERVISOR CONFIGURATION VALUES
  345. //----------------------------------------------------------------
  346. //The superviser checks for this module to be alive and preferentially
  347. //routes error messages there if it is present and alive, otherwise
  348. //they get routed to syslog.
  349. #define SUPERVISOR_SPECIAL_BILLDB "billdb"
  350. //The maximum number of modules that may be monitored by the supervisor
  351. #define SUPERVISOR_MAX_MODULES (32)
  352. // If a spawned process lasts less than SUPERVISOR_RESPAWN_DELAY_THRESHOLD
  353. //seconds, we want to delay SUPERVISOR_RESPAWN_RATE_LIMIT seconds to avoid driving
  354. //load too high by thrashing a process that is doomed to fail.
  355. #define SUPERVISOR_RESPAWN_DELAY_THRESHOLD (15)
  356. #define SUPERVISOR_RESPAWN_RATE_LIMIT (30)
  357. // The supervisor process will refrain from spawning ANYTHING within
  358. //SUPERVISOR_GLOBAL_SPAWN_RATE_LIMIT seconds of the last spawn to prevent
  359. //thrashing the system and driving load too high by trying to start everything
  360. //all at once.
  361. #define SUPERVISOR_GLOBAL_SPAWN_RATE_LIMIT (1)
  362. // These are some useful general math widgets so we don't keep repeating
  363. //ourselves, and if we (god forbid) need to adjust the number of microseconds in
  364. //a second due to the evil decree of some mad scientist...
  365. #define SEC_TO_USEC(x) ((x) * 1000000)
  366. #define USEC_TO_SEC(x) ((x) / 1000000)
  367. // The supervisor process will sent a message to MAILBOX_PING every
  368. //SUPERVISOR_PING_INTERVAL microseconds. If any module fails to respond
  369. //by SUPERVISOR_PING_WARN_TIME microseconds a warning message will be generated
  370. //and if a module failes to respond within SUPERVISOR_PING_TERM_TIME the process
  371. //will be issued a SIGTERM, and if it again fails to respond within
  372. //SUPERVISOR_PING_KILL_TIME it will be issued a SIGKILL. If a PONG comes in
  373. //at any point, further abuse of the child module will stop.
  374. #define SUPERVISOR_PING_INTERVAL SEC_TO_USEC(30)
  375. #define SUPERVISOR_PING_WARN_TIME SEC_TO_USEC(60)
  376. #define SUPERVISOR_PING_TERM_TIME SEC_TO_USEC(120)
  377. #define SUPERVISOR_PING_KILL_TIME SEC_TO_USEC(180)
  378. //How often to check system health parameters
  379. #define SUPERVISOR_SYSTEM_STAT_INTERVAL (60)
  380. #ifdef TARGET_DEVEL_DESKTOP
  381. #define SUPERVISOR_WARN_LOW_MEM (4096) //Warn if free memory goes below this threshold
  382. #define SUPERVISOR_WARN_LOAD_AVG (2.0f) //Warn if our 5 minute load average goes above this threshold
  383. #define SUPERVISOR_WARN_NUM_PROC (2048) //Warn if there are more than this many processes
  384. #else
  385. #define SUPERVISOR_WARN_LOW_MEM (4096) //Warn if free memory goes below this threshold
  386. #define SUPERVISOR_WARN_LOAD_AVG (2.0f) //Warn if our 5 minute load average goes above this threshold
  387. #define SUPERVISOR_WARN_NUM_PROC (1024) //Warn if there are more than this many processes
  388. #endif
  389. //Which types of log entries should be sent to the server via the billing log?
  390. #define SUPERVISOR_LOG_DEBUG_TO_BILLDB
  391. #define SUPERVISOR_LOG_WARNING_TO_BILLDB
  392. #define SUPERVISOR_LOG_ERROR_TO_BILLDB
  393. #endif