Skip to content

Commit

Permalink
Minor fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
interkosmos committed Aug 3, 2024
1 parent 428edf0 commit af2637f
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 77 deletions.
6 changes: 3 additions & 3 deletions adoc/dmdbctl.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ through command-line arguments.
*--version*, *-v*::
Output version information and quit.

*--X*, *-x* _x_::
*--x*, *-X* _x_::
Node, sensor, or target x, usually in metres. May be in local or global
coordinate system.

*--Y*, *-y* _z_::
*--y*, *-Y* _z_::
Node, sensor, or target z, usually in metres. May be in local or global
coordinate system.

*--Z*, *-z* _z_::
*--z*, *-Z* _z_::
Node, sensor, or target z, usually in metres. May be in local or global
coordinate system.

Expand Down
20 changes: 12 additions & 8 deletions app/dmdbctl.f90
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ program dmdbctl
integer, parameter :: ATTR_X = 7
integer, parameter :: ATTR_Y = 8
integer, parameter :: ATTR_Z = 9
integer, parameter :: ATTR_LNG = 10
integer, parameter :: ATTR_LON = 10
integer, parameter :: ATTR_LAT = 11
integer, parameter :: ATTR_ALT = 12
integer, parameter :: ATTR_LAST = 12
Expand Down Expand Up @@ -85,6 +85,8 @@ integer function crud(app) result(rc)
rc = db_update(db, app)
case (OP_DELETE)
rc = db_delete(db, app)
case default
rc = E_INVALID
end select

! Close database.
Expand Down Expand Up @@ -112,6 +114,7 @@ integer function db_create(db, app) result(rc)
end if

rc = dm_db_insert(db, app%node)
call dm_error_out(rc)

case (TYPE_SENSOR)
! Create sensor.
Expand Down Expand Up @@ -305,7 +308,7 @@ integer function db_update(db, app) result(rc)
if (.not. app%mask(ATTR_X)) app%node%x = old_node%x
if (.not. app%mask(ATTR_Y)) app%node%y = old_node%y
if (.not. app%mask(ATTR_Z)) app%node%z = old_node%z
if (.not. app%mask(ATTR_LNG)) app%node%longitude = old_node%longitude
if (.not. app%mask(ATTR_LON)) app%node%longitude = old_node%longitude
if (.not. app%mask(ATTR_LAT)) app%node%latitude = old_node%latitude
if (.not. app%mask(ATTR_ALT)) app%node%altitude = old_node%altitude

Expand Down Expand Up @@ -407,9 +410,9 @@ integer function read_args(app) result(rc)
arg_type('sn', short='Q', type=ARG_TYPE_STRING, max_len=SENSOR_SN_LEN), & ! -Q, --sn <string>
arg_type('type', short='t', type=ARG_TYPE_STRING, max_len=SENSOR_TYPE_NAME_LEN), & ! -t, --type <type>
arg_type('state', short='S', type=ARG_TYPE_INTEGER), & ! -S, --state <state>
arg_type('X', short='x', type=ARG_TYPE_REAL), & ! -X, --x <x>
arg_type('Y', short='y', type=ARG_TYPE_REAL), & ! -Y, --y <y>
arg_type('Z', short='z', type=ARG_TYPE_REAL), & ! -Z, --z <z>
arg_type('x', short='X', type=ARG_TYPE_REAL), & ! -X, --x <x>
arg_type('y', short='Y', type=ARG_TYPE_REAL), & ! -Y, --y <y>
arg_type('z', short='Z', type=ARG_TYPE_REAL), & ! -Z, --z <z>
arg_type('longitude', short='G', type=ARG_TYPE_REAL), & ! -G, --longitude <lng>
arg_type('latitude', short='L', type=ARG_TYPE_REAL), & ! -L, --latitude <lat>
arg_type('altitude', short='A', type=ARG_TYPE_REAL), & ! -A, --altitude <alt>
Expand Down Expand Up @@ -450,7 +453,7 @@ integer function read_args(app) result(rc)
rc = dm_arg_get(args(13), app%node%x, passed=app%mask(ATTR_X))
rc = dm_arg_get(args(14), app%node%y, passed=app%mask(ATTR_Y))
rc = dm_arg_get(args(15), app%node%z, passed=app%mask(ATTR_Z))
rc = dm_arg_get(args(16), app%node%longitude, passed=app%mask(ATTR_LNG))
rc = dm_arg_get(args(16), app%node%longitude, passed=app%mask(ATTR_LON))
rc = dm_arg_get(args(17), app%node%latitude, passed=app%mask(ATTR_LAT))
rc = dm_arg_get(args(18), app%node%altitude, passed=app%mask(ATTR_ALT))

Expand Down Expand Up @@ -484,7 +487,7 @@ integer function read_args(app) result(rc)
return
end select

rc = dm_arg_get(args(16), app%verbose)
rc = dm_arg_get(args(19), app%verbose)

! Validate options.
rc = E_INVALID
Expand All @@ -510,7 +513,7 @@ integer function read_args(app) result(rc)
case (TYPE_NODE)
if (.not. app%mask(ATTR_NAME) .and. .not. app%mask(ATTR_META) .and. &
.not. app%mask(ATTR_X) .and. .not. app%mask(ATTR_Y) .and. &
.not. app%mask(ATTR_Z) .and. .not. app%mask(ATTR_LNG) .and. &
.not. app%mask(ATTR_Z) .and. .not. app%mask(ATTR_LON) .and. &
.not. app%mask(ATTR_LAT) .and. .not. app%mask(ATTR_ALT)) then
call dm_error_out(rc, 'command-line option --name, --meta, -x, -y, -z, ' // &
'--longitude, --latitude, or --altitude required')
Expand Down Expand Up @@ -540,5 +543,6 @@ integer function read_args(app) result(rc)
end select
end select

rc = E_NONE
end function read_args
end program dmdbctl
2 changes: 1 addition & 1 deletion config/dmlua.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
dmlua = {
logger = "dmlogger",
node = "dummy-node",
script = "/usr/local/share/dmpack/dmlua.lua",
script = "/usr/local/share/dmpack/dmlua/dmlua.lua",
procedure = "process",
debug = false,
verbose = true
Expand Down
2 changes: 1 addition & 1 deletion config/dmreport.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dmreport = {
from = "1970-01-01T00:00:00.000000+00:00",
to = "2070-01-01T00:00:00.000000+00:00",
output = "%Y-%M-%D_dummy-report.html",
style = "/usr/local/share/dmpack/dmreport.min.css",
style = "/usr/local/share/dmpack/dmreport/dmreport.min.css",
title = "Monitoring Report",
subtitle = "Project",
meta = "Report example.",
Expand Down
113 changes: 59 additions & 54 deletions guide/guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,8 @@ The data structures of DMPACK are based on the following entities. The
date and time format used internally is a 32-characters long ISO 8601 time stamp
in microsecond resolution, with time separator `T` and mandatory GMT offset, for
example, `1970-01-01T00:00:00.000000+00:00`. The human-readable output format
`1970-01-01 00:00:00 +00:00` is used where reasonable.
`1970-01-01 00:00:00 +00:00` is used where reasonable. Global coordinates are in
longitude/latitude order (east-west/north-south order).

=== Observation Entities

Expand Down Expand Up @@ -849,24 +850,27 @@ through command-line arguments.
|===
| Option | Short | Default | Description

| `--altitude _z_` | `-Z` | – | Node, sensor, or target altitude (optional).
| `--altitude _alt_` | `-A` | – | Node, sensor, or target altitude (optional).
| `--create _type_` | `-C` | – | Create record of given type (`node`, `sensor`, or `target`).
| `--database _file_` | `-d` | – | Path to SQLite observation database (required).
| `--delete _type_` | `-D` | – | Delete record of given type (`node`, `sensor`, or `target`).
| `--easting _x_` | `-X` | – | Node, sensor, or target easting (optional).
| `--help` | `-h` | – | Output available command-line arguments and quit.
| `--id _id_` | `-I` | – | Node, sensor, or target id (required).
| `--latitude _lat_` | `-L` | – | Node, sensor, or target latitude (optional).
| `--longitude _lon_` | `-G` | – | Node, sensor, or target longitude (optional).
| `--meta _meta_` | `-M` | – | Node, sensor, or target meta description (optional).
| `--name _name_` | `-n` | – | Node, sensor, or target name.
| `--node _id_` | `-N` | – | Id of node the sensor is associated with.
| `--northing _y_` | `-Y` | – | Node, sensor, or target northing (optional).
| `--read _type_` | `-R` | – | Read record of given type (`node`, `sensor`, or `target`).
| `--sn _sn_` | `-Q` | – | Serial number of sensor (optional).
| `--state _n_` | `-S` | – | Target state (optional).
| `--type _name_` | `-t` | `none` | <<data-sensor-types,Sensor type>> (`none`, `rts`, `gnss`, …).
| `--update _type_` | `-U` | – | Updates record of given type (`node`, `sensor`, or `target`).
| `--verbose` | `-V` | off | Print additional log messages to _stderr_.
| `--version` | `-v` | – | Output version information and quit.
| `--x _x_` | `-X` | – | Local node, sensor, or target x (optional).
| `--y _y_` | `-Y` | – | Local node, sensor, or target y (optional).
| `--z _z_` | `-Z` | – | Local node, sensor, or target z (optional).
|===

[discrete]
Expand Down Expand Up @@ -1849,8 +1853,8 @@ calling _gnuplot(1)_ and inlining the returned image (GIF, PNG, SVG) as a
base64-encoded data URI. Any style sheet file with classless CSS can be
included to alter the presentation of the report. A basic style sheet
`dmreport.css` and its minified version `dmreport.min.css` are provided in
`/usr/local/share/dmpack/`. The output of *dmreport* is a single HTML file with
inlined CSS. Use a command-line tool like
`/usr/local/share/dmpack/dmreport/`. The output of *dmreport* is a single HTML
file with inlined CSS. Use a command-line tool like
link:https://wkhtmltopdf.org/[wkhtmltopdf] to convert the HTML report to PDF
format.

Expand Down Expand Up @@ -1921,7 +1925,7 @@ dmreport = {
from = "1970-01-01T00:00:00.000000+00:00",
to = "2070-01-01T00:00:00.000000+00:00",
output = "%Y-%M-%D_dummy-report.html",
style = "/usr/local/share/dmpack/dmreport.min.css",
style = "/usr/local/share/dmpack/dmreport/dmreport.min.css",
title = "Monitoring Report",
subtitle = "Project",
meta = "",
Expand Down Expand Up @@ -1968,10 +1972,10 @@ $ dmreport --name dmreport --config dmreport.conf --output report.html
....

In order to update reports periodically, we can customise the shell script
`mkreport.sh` in `/usr/local/share/dmpack/`. The script determines the
`mkreport.sh` in `/usr/local/share/dmpack/dmreport/`. The script determines the
timestamps of the last and the current month (to allow observations to arrived
late), which will then be passed to *dmreport* to create monthly reports. Modify
the script according to your set-up:
late), which will then be passed to *dmreport* to create monthly reports.
Modify the script according to your set-up:

[source,sh]
....
Expand All @@ -1984,7 +1988,7 @@ output="/var/www/reports/"
The shell script writes two reports to `/var/www/reports/`.

....
$ sh /usr/local/share/dmpack/mkreport.sh
$ sh /usr/local/share/dmpack/dmreport/mkreport.sh
--- Writing report of 2023-08 to file /var/www/reports/2023-08_report.html ...
--- Writing report of 2023-09 to file /var/www/reports/2023-09_report.html ...
....
Expand Down Expand Up @@ -2303,10 +2307,10 @@ export GDFONTPATH="/usr/local/share/fonts/webfonts/"
| `DM_READ_ONLY` | Set to `1` to enable read-only database access.
|===

Copy the style sheet `dmpack.min.css` manually to the WWW root directory, or
create a symlink. Environment variables are used to configure *dmweb*. Transport
security and authentication have to be managed by the web server. See section
<<web-web-ui>> for an example configuration.
Copy the directory `/usr/local/share/dmpack/dmweb` manually to the WWW root
directory, or create a symlink. Environment variables are used to configure
*dmweb*. Transport security and authentication have to be managed by the web
server. See section <<web-web-ui>> for an example configuration.

.Plotting of time series through the *dmweb* user interface
[#img-dmweb]
Expand Down Expand Up @@ -2558,6 +2562,7 @@ setenv.add-environment = (
"DM_DB_BEAT" => "/var/dmpack/beat.sqlite",
"DM_DB_LOG" => "/var/dmpack/log.sqlite",
"DM_DB_OBSERV" => "/var/dmpack/observ.sqlite",
"DM_TILE_URL" => "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
"DM_READ_ONLY" => "0"
)
Expand Down Expand Up @@ -2590,13 +2595,13 @@ $HTTP["url"] =^ "/dmpack/" {
}
....

Copy the CSS file `dmpack.min.css` from `/usr/local/share/dmpack/`
(`/usr/share/dmpack/` on Linux) to the WWW root directory, in this case,
`/var/www/`, or simply create a symlinks:
Copy the directory `dmweb` from `/usr/local/share/dmpack/` (or
`/usr/share/dmpack/` on Linux) to the WWW root directory, in this case,
`/var/www/`, or simply create a symlink:

....
# cd /var/www/
# ln -s /usr/local/share/dmpack/dmpack.min.css dmpack.min.css
# ln -s /usr/local/share/dmpack/dmweb dmweb
....

If the files have to be served from a path other than the root path, add a
Expand Down Expand Up @@ -2884,7 +2889,7 @@ using utility script `mkreport.sh`:
SHELL=/bin/sh
MAILTO=/dev/null
# Create reports every hour, suppress logging.
@hourly -q /usr/local/share/dmpack/mkreport.sh
@hourly -q /usr/local/share/dmpack/dmreport/mkreport.sh
....

Status mails and logging are disabled. The shell script `mkreport.sh` must have
Expand Down Expand Up @@ -6489,17 +6494,17 @@ LOG%MESSAGE="dummy log message",

[cols="3,2,2,14"]
|===
| Attribute | Type | Size | Description
| Attribute | Type | Size | Description

| `id` | string | 32 | Node id (`-0-9A-Z_a-z`).
| `name` | string | 32 | Node name.
| `meta` | string | 32 | Node description (optional).
| `lng` | double | 8 | Node longitude (optional).
| `lat` | double | 8 | Node latitude (optional).
| `elev` | double | 8 | Node elevation (optional).
| `x` | double | 8 | Node x or easting (optional).
| `y` | double | 8 | Node y or northing (optional).
| `z` | double | 8 | Node z or altitude (optional).
| `id` | string | 32 | Node id (`-0-9A-Z_a-z`).
| `name` | string | 32 | Node name.
| `meta` | string | 32 | Node description (optional).
| `x` | double | 8 | Node local x (optional).
| `y` | double | 8 | Node local y (optional).
| `z` | double | 8 | Node local z (optional).
| `longitude` | double | 8 | Node longitude (optional).
| `latitude` | double | 8 | Node latitude (optional).
| `altitude` | double | 8 | Node altitude (optional).
|===

==== CSV [[data-node-csv]]
Expand All @@ -6508,15 +6513,15 @@ LOG%MESSAGE="dummy log message",
|===
| Column | Attribute | Description

| 1 | `id` | Node id.
| 2 | `name` | Node name.
| 3 | `meta` | Node description.
| 4 | `lng` | Node longitude.
| 5 | `lat` | Node latitude.
| 6 | `elev` | Node elevation.
| 7 | `x` | Node x or easting.
| 8 | `y` | Node y or northing.
| 9 | `z` | Node z or altitude.
| 1 | `id` | Node id.
| 2 | `name` | Node name.
| 3 | `meta` | Node description.
| 7 | `x` | Node local x.
| 8 | `y` | Node local y.
| 9 | `z` | Node local z.
| 4 | `longitude` | Node longitude.
| 5 | `latitude` | Node latitude.
| 6 | `altitude` | Node altitude.
|===

==== GeoJSON [[data-node-geojson]]
Expand All @@ -6528,13 +6533,13 @@ LOG%MESSAGE="dummy log message",
"properties": {
"id": "dummy-node",
"name": "Dummy Node",
"meta": "Description"
"lng": 0.0,
"lat": 0.0,
"elev": 0.0,
"meta": "Description",
"x": 0.0,
"y": 0.0,
"z": 0.0
"z": 0.0,
"longitude": 0.0,
"latitude": 0.0,
"altitude": 0.0
},
"geometry": {
"type": "Point",
Expand Down Expand Up @@ -6566,12 +6571,12 @@ DATASET "node_type" {
CSET H5T_CSET_ASCII;
CTYPE H5T_C_S1;
} } "meta";
H5T_IEEE_F64LE "lng";
H5T_IEEE_F64LE "lat";
H5T_IEEE_F64LE "elev";
H5T_IEEE_F64LE "x";
H5T_IEEE_F64LE "y";
H5T_IEEE_F64LE "z";
H5T_IEEE_F64LE "longitude";
H5T_IEEE_F64LE "latitude";
H5T_IEEE_F64LE "altitude";
}
DATASPACE SIMPLE { ( 8 ) / ( 8 ) }
}
Expand All @@ -6585,12 +6590,12 @@ DATASET "node_type" {
"id": "dummy-node",
"name": "Dummy Node",
"meta": "Description",
"lng": 0.0,
"lat": 0.0,
"elev": 0.0,
"x": 0.0,
"y": 0.0,
"z": 0.0
"z": 0.0,
"longitude": 0.0,
"latitude": 0.0,
"altitude": 0.0
}
....

Expand All @@ -6601,12 +6606,12 @@ DATASET "node_type" {
NODE%ID="dummy-node",
NODE%NAME="Dummy Node",
NODE%META="Description",
NODE%LNG=0.0,
NODE%LAT=0.0,
NODE%ELEV=0.0,
NODE%X=0.0,
NODE%Y=0.0,
NODE%Z=0.0,
NODE%LONGITUDE=0.0,
NODE%LATITUDE=0.0,
NODE%ALTITUDE=0.0
/
....

Expand Down
6 changes: 3 additions & 3 deletions man/dmdbctl.1
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,19 @@ Print additional log messages to \fIstderr\fP.
Output version information and quit.
.RE
.sp
\fB\-\-X\fP, \fB\-x\fP \fIx\fP
\fB\-\-x\fP, \fB\-X\fP \fIx\fP
.RS 4
Node, sensor, or target x, usually in metres. May be in local or global
coordinate system.
.RE
.sp
\fB\-\-Y\fP, \fB\-y\fP \fIz\fP
\fB\-\-y\fP, \fB\-Y\fP \fIz\fP
.RS 4
Node, sensor, or target z, usually in metres. May be in local or global
coordinate system.
.RE
.sp
\fB\-\-Z\fP, \fB\-z\fP \fIz\fP
\fB\-\-z\fP, \fB\-Z\fP \fIz\fP
.RS 4
Node, sensor, or target z, usually in metres. May be in local or global
coordinate system.
Expand Down
Loading

0 comments on commit af2637f

Please sign in to comment.