Skip to content

Commit

Permalink
Minor updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
interkosmos committed Mar 5, 2024
1 parent f13bb98 commit 772a734
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 16 deletions.
6 changes: 5 additions & 1 deletion app/dmlua.f90
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ program dmlua
end if

! Register DMPACK API for Lua.
rc = dm_lua_api_register(lua, add_errors=.true., add_levels=.true., add_procedures=.true.)
rc = dm_lua_api_register(lua = lua, &
add_errors = .true., &
add_log_levels = .true., &
add_procedures = .true., &
add_response_types = .true.)

if (dm_is_error(rc)) then
call dm_log_error('failed to register Lua API', error=rc)
Expand Down
2 changes: 1 addition & 1 deletion app/dmserial.f90
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ integer function read_config(app) result(rc)
rc = E_NONE
if (len_trim(app%config) == 0) return

rc = dm_config_open(config, app%config, app%name)
rc = dm_config_open(config, app%config, app%name, geocom=.true.)

if (dm_is_ok(rc)) then
rc = dm_config_get(config, 'baudrate', app%baud_rate)
Expand Down
9 changes: 5 additions & 4 deletions src/dm_config.f90
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,15 @@ integer function dm_config_open(config, path, name, geocom) result(rc)
if (.not. dm_file_exists(path)) exit open_block

! Initialise Lua interpreter.
rc = dm_lua_init(config%lua)
rc = dm_lua_init(config%lua, libs=.true.)
if (dm_is_error(rc)) exit open_block

! Register DMPACK API for Lua.
rc = dm_lua_api_register(config%lua, &
add_errors = .true., & ! Add error codes.
add_levels = .true., & ! Add log levels.
add_procedures = .true.) ! Add Lua procedures.
add_errors = .true., & ! Add error codes.
add_log_levels = .true., & ! Add log levels.
add_procedures = .true., & ! Add Lua procedures.
add_response_types = .true.) ! Add response types.
if (dm_is_error(rc)) exit open_block

! Register GeoCOM API for Lua.
Expand Down
10 changes: 5 additions & 5 deletions src/dm_db.f90
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ integer function dm_db_close(db, optimize) result(rc)
if (optimize_) rc = dm_db_optimize(db)

rc = E_DB
if (sqlite3_close_v2(db%ptr) /= SQLITE_OK) return
if (sqlite3_close(db%ptr) /= SQLITE_OK) return

db%ptr = c_null_ptr
rc = E_NONE
Expand Down Expand Up @@ -765,7 +765,7 @@ integer function dm_db_delete_log(db, log_id) result(rc)
!! * `E_DB_BIND` if value binding failed.
!! * `E_DB_PREPARE` if statement preparation failed.
!! * `E_DB_STEP` if step execution failed or no write permission.
!! * `E_INVALID` if node id is invalid.
!! * `E_INVALID` if log id is invalid.
!! * `E_READ_ONLY` if database is opened read-only.
type(db_type), intent(inout) :: db !! Database type.
character(len=*), intent(in) :: log_id !! Log id.
Expand Down Expand Up @@ -847,7 +847,7 @@ integer function dm_db_delete_observ(db, observ_id) result(rc)
!! * `E_DB_ROLLBACK` if transaction rollback failed.
!! * `E_DB_STEP` if step execution failed or no write permission.
!! * `E_DB_TRANSACTION` if transaction failed.
!! * `E_INVALID` if node id is invalid.
!! * `E_INVALID` if observation id is invalid.
!! * `E_READ_ONLY` if database is opened read-only.
type(db_type), intent(inout) :: db !! Database type.
character(len=*), intent(in) :: observ_id !! Observation id.
Expand Down Expand Up @@ -899,7 +899,7 @@ integer function dm_db_delete_sensor(db, sensor_id) result(rc)
!! * `E_DB_BIND` if value binding failed.
!! * `E_DB_PREPARE` if statement preparation failed.
!! * `E_DB_STEP` if step execution failed or no write permission.
!! * `E_INVALID` if node id is invalid.
!! * `E_INVALID` if sensor id is invalid.
!! * `E_READ_ONLY` if database is opened read-only.
type(db_type), intent(inout) :: db !! Database type.
character(len=*), intent(in) :: sensor_id !! Sensor id.
Expand Down Expand Up @@ -937,7 +937,7 @@ integer function dm_db_delete_target(db, target_id) result(rc)
!! * `E_DB_BIND` if value binding failed.
!! * `E_DB_PREPARE` if statement preparation failed.
!! * `E_DB_STEP` if step execution failed or no write permission.
!! * `E_INVALID` if node id is invalid.
!! * `E_INVALID` if target id is invalid.
!! * `E_READ_ONLY` if database is opened read-only.
type(db_type), intent(inout) :: db !! Database type.
character(len=*), intent(in) :: target_id !! Target id.
Expand Down
10 changes: 5 additions & 5 deletions src/dm_test.f90
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ module dm_test
integer, parameter :: TEST_COLORS(0:3) = [ COLOR_WHITE, COLOR_YELLOW, COLOR_GREEN, COLOR_RED ]

abstract interface
logical function dm_test_function()
logical function dm_test_callback()
!! Logical test function that either returns `TEST_PASSED` or
!! `TEST_FAILED`.
end function dm_test_function
end function dm_test_callback
end interface

type, public :: test_type
!! Test type.
character(len=TEST_NAME_LEN) :: name = 'N/A' !! Test name.
procedure(dm_test_function), pointer, nopass :: proc !! Test procedure.
character(len=TEST_NAME_LEN) :: name = 'N/A' !! Test name.
procedure(dm_test_callback), pointer, nopass :: proc => null() !! Test procedure.
end type test_type

interface dm_test_dummy
Expand All @@ -52,6 +52,7 @@ end function dm_test_function
module procedure :: dm_test_dummy_target
end interface

public :: dm_test_callback
public :: dm_test_dummy
public :: dm_test_dummy_beat
public :: dm_test_dummy_log
Expand All @@ -60,7 +61,6 @@ end function dm_test_function
public :: dm_test_dummy_request
public :: dm_test_dummy_sensor
public :: dm_test_dummy_target
public :: dm_test_function
public :: dm_test_run
public :: dm_test_skip
contains
Expand Down

0 comments on commit 772a734

Please sign in to comment.