diff --git a/app/dmbot.f90 b/app/dmbot.f90 index ef6ac1c..d6ad696 100644 --- a/app/dmbot.f90 +++ b/app/dmbot.f90 @@ -55,19 +55,19 @@ program dmbot type :: bot_type !! User data to be passed to libstrophe callbacks. - type(im_type) :: im !! IM context type. - character(len=ID_LEN) :: name = APP_NAME !! Bot name. - character(len=NODE_ID_LEN) :: node_id = ' ' !! Node id. - character(len=IM_JID_LEN) :: jid = ' ' !! JID of bot account. - character(len=IM_PASSWORD_LEN) :: password = ' ' !! Password of bot account. - character(len=IM_HOST_LEN) :: host = ' ' !! Domain of XMPP server. - integer :: port = IM_PORT !! Port of XMPP server. - logical :: tls = .true. !! Force TLS encryption. - logical :: reconnect = .false. !! Reconnect on error. - character(len=IM_ID_LEN) :: ping_id = ' ' !! XMPP ping id (XEP-0199). - character(len=FILE_PATH_LEN) :: db_path_log = ' ' !! Path to log database. - character(len=FILE_PATH_LEN) :: db_path_observ = ' ' !! Path to observ database. - character(len=IM_JID_LEN), allocatable :: group(:) !! Authorised JIDs. + type(im_type) :: im !! IM context type. + character(len=ID_LEN) :: name = APP_NAME !! Bot name. + character(len=NODE_ID_LEN) :: node_id = ' ' !! Node id. + character(len=IM_JID_LEN) :: jid = ' ' !! JID of bot account. + character(len=IM_PASSWORD_LEN) :: password = ' ' !! Password of bot account. + character(len=IM_HOST_LEN) :: host = ' ' !! Domain of XMPP server. + integer :: port = IM_PORT !! Port of XMPP server. + logical :: tls = .true. !! Force TLS encryption. + logical :: reconnect = .false. !! Reconnect on error. + character(len=IM_ID_LEN) :: ping_id = ' ' !! XMPP ping id (XEP-0199). + character(len=FILE_PATH_LEN) :: db_path_log = ' ' !! Path to log database. + character(len=FILE_PATH_LEN) :: db_path_observ = ' ' !! Path to observ database. + character(len=IM_JID_FULL_LEN), allocatable :: group(:) !! Authorised JIDs. end type bot_type class(logger_class), pointer :: logger ! Logger object. diff --git a/src/dm_modbus.f90 b/src/dm_modbus.f90 index faa45bf..d6031be 100644 --- a/src/dm_modbus.f90 +++ b/src/dm_modbus.f90 @@ -146,17 +146,13 @@ integer function dm_modbus_byte_order_from_name(name, byte_order) result(rc) name_ = dm_to_upper(name) select case (name_) - case ('ABCD') - byte_order = MODBUS_REAL_ABCD - case ('BADC') - byte_order = MODBUS_REAL_BADC - case ('CDAB') - byte_order = MODBUS_REAL_CDAB - case ('DCBA') - byte_order = MODBUS_REAL_DCBA + case ('ABCD'); byte_order = MODBUS_REAL_ABCD + case ('BADC'); byte_order = MODBUS_REAL_BADC + case ('CDAB'); byte_order = MODBUS_REAL_CDAB + case ('DCBA'); byte_order = MODBUS_REAL_DCBA case default - byte_order = MODBUS_REAL_ABCD rc = E_INVALID + byte_order = MODBUS_REAL_ABCD end select end function dm_modbus_byte_order_from_name @@ -207,32 +203,23 @@ integer function dm_modbus_create_rtu(modbus, path, baud_rate, byte_size, parity ! Byte size: 5, 6, 7, 8 (start bits). select case (byte_size) - case (TTY_BYTE_SIZE5) - byte_size_ = 5 - case (TTY_BYTE_SIZE6) - byte_size_ = 6 - case (TTY_BYTE_SIZE7) - byte_size_ = 7 - case (TTY_BYTE_SIZE8) - byte_size_ = 8 + case (TTY_BYTE_SIZE5); byte_size_ = 5 + case (TTY_BYTE_SIZE6); byte_size_ = 6 + case (TTY_BYTE_SIZE7); byte_size_ = 7 + case (TTY_BYTE_SIZE8); byte_size_ = 8 end select ! Parity: none, odd, even. select case (parity) - case (TTY_PARITY_NONE) - parity_ = PARITY_NONE - case (TTY_PARITY_ODD) - parity_ = PARITY_ODD - case (TTY_PARITY_EVEN) - parity_ = PARITY_EVEN + case (TTY_PARITY_NONE); parity_ = PARITY_NONE + case (TTY_PARITY_ODD); parity_ = PARITY_ODD + case (TTY_PARITY_EVEN); parity_ = PARITY_EVEN end select ! Stop bits: 1, 2. select case (stop_bits) - case (TTY_STOP_BITS1) - stop_bits_ = 1 - case (TTY_STOP_BITS2) - stop_bits_ = 2 + case (TTY_STOP_BITS1); stop_bits_ = 1 + case (TTY_STOP_BITS2); stop_bits_ = 2 end select rc = E_MODBUS @@ -309,17 +296,13 @@ real function dm_modbus_get_real(registers, byte_order, error) result(value) if (present(error)) error = E_NONE select case (byte_order) - case (MODBUS_REAL_ABCD) - value = modbus_get_float_abcd(registers) - case (MODBUS_REAL_BADC) - value = modbus_get_float_badc(registers) - case (MODBUS_REAL_CDAB) - value = modbus_get_float_cdab(registers) - case (MODBUS_REAL_DCBA) - value = modbus_get_float_dcba(registers) + case (MODBUS_REAL_ABCD); value = modbus_get_float_abcd(registers) + case (MODBUS_REAL_BADC); value = modbus_get_float_badc(registers) + case (MODBUS_REAL_CDAB); value = modbus_get_float_cdab(registers) + case (MODBUS_REAL_DCBA); value = modbus_get_float_dcba(registers) case default - value = 0.0 if (present(error)) error = E_INVALID + value = 0.0 end select end function dm_modbus_get_real @@ -613,17 +596,13 @@ subroutine dm_modbus_set_real(value, registers, byte_order, error) if (present(error)) error = E_NONE select case (byte_order) - case (MODBUS_REAL_ABCD) - call modbus_set_float_abcd(value, registers) - case (MODBUS_REAL_BADC) - call modbus_set_float_badc(value, registers) - case (MODBUS_REAL_CDAB) - call modbus_set_float_cdab(value, registers) - case (MODBUS_REAL_DCBA) - call modbus_set_float_dcba(value, registers) + case (MODBUS_REAL_ABCD); call modbus_set_float_abcd(value, registers) + case (MODBUS_REAL_BADC); call modbus_set_float_badc(value, registers) + case (MODBUS_REAL_CDAB); call modbus_set_float_cdab(value, registers) + case (MODBUS_REAL_DCBA); call modbus_set_float_dcba(value, registers) case default - registers = 0 if (present(error)) error = E_INVALID + registers = 0 end select end subroutine dm_modbus_set_real