SUPERCOMPUTER: what it sounded like before you bought it.

OpenFarm

# OpenFarm Notes
Locations can have Zones and HW Sensors
Zones have HW Sensors
Programs have day specific, time-related values for HW Sensors (on|off|value)
Clients (arduino/pi/risc-v) house HW Sensors that can be set with values and values can be retrieved from them
HW Sensors belong to Clients and have a unique subid per Client for retreieving/setting specific values
HW Sensors are switches or sensors like temperature, humidity, pH, and moisture
CNC and WEB-CNC are controllers for Locations, Zones, Programs, Clients, and HW Sensors
CNC and WEB-CNC use html image maps of drawing/picture of zone/location for visual interface


OpenFarm Socket Server v.1a
Licence: CC BY-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0/)
README.txt - OF Readme

Purpose:
1) handles all sensor, cnc and web director socket connections
2) provides client management functions (auth,exit,kick)
3) listens for all sensor data from clients and stores in a DB (redis|sqlite)
4) sends commands to specific clients or to all clients (wall)

Uses:
ReactPHP for socket management and periodic tasks
SQLite for client DB
JSON for data table communication and storage
Optional: Redis for stats storage (falls back to sqlite in memory db)
Optional: Use included fail2ban filter for auth failures/bans

Commands:
Server only:
   AUTH        (.auth id:pw)             authenticate to server
   CHECK       (.check)                  checks for dead clients
   CLIENTS     (.clients|.who)           prints list of active clients
   CRON        (.cron)                   run all periodic tasks
   DIAG        (.diag)                   prints diagnostic info
   DUMP        (.dump)                   prints all tables (clients, and stats)
   HELP        (.help)                   prints help text
   KICK        (.kick )             kicks a client off the server
   REPORT      (.report )          writes client stats in JSON to stats db
   RUN         (.run )              executes a command and prints result (dangerous as commands run as server user and can block)
   SEND        (.send )       sends a command to client identified by cid
   SET         (.set )  sets a client/server option
   SHUTDOWN    (.shutdown)               shutdowns the server
   STATS       (.stats |all)        retrieves stats from stats db (in TEXT or JSON depending on client mode)
   UPTIME      (.uptime)                 displays server uptime
   WALL        (.wall )             sends all clients a command
   WHOAMI      (.whoami)                 prints current cid for connection
   QUIT        (.exit | .quit)           closes connection to server
   
Clients only:
   INFO        (.info)                   asks client for current stats (sensor data, fan PWM speeds, switch states, etc.)
   REBOOT      (.reboot)                 asks client to reboot itself

Settings:
   SET         (.set )  sets a client/server option
               (.set mode text|json)     sets output to text or json for data tables (clients, stats)


# DB Schemas
# openfarm-client.db: {clients}
id
cid
type (cnc,webcnc,sensor)
loc
auth (md5sum)
mode (text|json)
acl [clients,programs,sensors,locations,zones]
notes
data
created
updated

# openfarm-programs.db {programs}
id
name
notes
data [day of program,time/timerange,sensorid,value]
notes
created
updated

# openfarm-sensor.db: {sensors}
id
type (sw,temp,rpm,ph,misc)
name
cid (client id of sensor)
hwid (sensor hw identifier)
desc
min
max
defvalue
notes
created
updated

# openfarm-loc.db {locations}
id
name
desc
sensors [sensorid]
zones [zoneid]
notes
created
updated

# openfarm-zones.db {zones}
id
name
desc
sensors [sensorid]
notes
created
updated

# openfarm-weblog.db: {notice,error}
id
type
sitemode (public/user/admin)
date
host
user
environment
read (boolean)
message