| ioPAC RTU Controllers C/C++ Sample Code Programming Guide

- Main Page
- Modules
- Data Structures
- Files

Modules | Data Structures | Macros | Typedefs | Enumerations | Functions
TagService
Library

Moxa TAG Library
More...

## Modules
| TagDataType
| TagEventCondition

## Data Structures
struct | TAG_INFO_T
struct | TAG_EVENT_CONDITION_T

## Macros
#define | TAG_MAX_NAME_SIZE 64

## Typedefs
typedef struct TAG_INFO_T | TAG_INFO
typedef struct TAG_EVENT_CONDITION_T | TAG_EVENT_CONDITION

## Enumerations
enum | TAG_ERR_CODE { TAG_ERR_OK = 0, TAG_ERR_INIT, TAG_ERR_SEM, TAG_ERR_MSGQUEUE, TAG_ERR_ALLOC, TAG_ERR_PARAM, TAG_ERR_REG, TAG_ERR_DESTROY, TAG_ERR_BIND, TAG_ERR_RESET, TAG_ERR_AGAIN, TAG_ERR_IO, TAG_ERR_READY, TAG_ERR_NO_TAG, TAG_ERR_MSGQUEUE_FULL, TAG_ERR_NOT_SUPPORT, TAG_ERR_EVENT_INIT, TAG_ERR_EVENT_REGISTER, TAG_ERR_EVENT_SPACE, TAG_ERR_EVENT_HANDLE, TAG_ERR_EVENT_EMPTY, TAG_ERR_AMOUNT }
enum | STATUS_CODE { STATUS_INIT = 0, STATUS_READY, STATUS_RUNNING, STATUS_SUCCESS, STATUS_FAIL, STATUS_ERR_AMOUNT }

## Functions
TAG_ERR_CODE | MX_RTU_Tag_Init (void)
| This API must be called at first. More...
TAG_ERR_CODE | MX_RTU_Tag_Uninit (void)
| This API must be called at the end. More...
TAG_ERR_CODE | MX_RTU_Tag_List_All (void)
| Listing all of the tags. More...
TAG_ERR_CODE | MX_RTU_Tag_Get_List (TAG_INFO ***list, UINT32 *quantity)
TAG_ERR_CODE | MX_RTU_Tag_Get_Info (UINT8 *tagName, TAG_INFO *info)
TAG_ERR_CODE | MX_RTU_Tag_Read (UINT8 *tagName, void *tagValue, UINT32 tagSize, UINT32 *readBytes, struct Timestamp *time)
TAG_ERR_CODE | MX_RTU_Tag_Write (UINT8 *tagName, void *tagValue, UINT32 tagSize)
TAG_ERR_CODE | MX_RTU_MultiTag_Read (UINT8 *prefixTagName, UINT8 *postfixTagName, UINT16 start, UINT16 count, UINT8 *tagValue, struct Timestamp *tagTimeStamp)
TAG_ERR_CODE | MX_RTU_MultiTag_Write (UINT8 *prefixTagName, UINT8 *postfixTagName, UINT16 start, UINT16 count, UINT8 *tagValue)
TAG_ERR_CODE | MX_RTU_Tag_Event_Register (UINT8 *tagName, TAG_EVENT_CONDITION *condition, int *handle)
TAG_ERR_CODE | MX_RTU_Tag_Event_Unregister (int handle)
TAG_ERR_CODE | MX_RTU_Tag_Event_Get (int handle, void *tagValue, struct Timestamp *time)
TAG_ERR_CODE | MX_RTU_Tag_Event_Clear (int handle)

## Detailed Description

Moxa TAG Library

Sample Code:

- tag_utility.c
- ioPAC8500_di_tag_event.c
- ioPAC8500_data_logging_service_dio_on_change.c
- ioPAC8500_email_alarm_service.c
- ioPAC8600_trap_alarm_service.c

## Macro Definition Documentation

#define TAG_MAX_NAME_SIZE 64

## Typedef Documentation

typedef struct TAG_INFO_T TAG_INFO

typedef struct TAG_EVENT_CONDITION_T TAG_EVENT_CONDITION

## Enumeration Type Documentation

enum TAG_ERR_CODE

Enumerator
TAG_ERR_OK | 0
TAG_ERR_INIT | 1
TAG_ERR_SEM | 2
TAG_ERR_MSGQUEUE | 3
TAG_ERR_ALLOC | 4
TAG_ERR_PARAM | 5
TAG_ERR_REG | 6
TAG_ERR_DESTROY | 7
TAG_ERR_BIND | 8
TAG_ERR_RESET | 9
TAG_ERR_AGAIN | 10
TAG_ERR_IO | 11
TAG_ERR_READY | 12
TAG_ERR_NO_TAG | 13
TAG_ERR_MSGQUEUE_FULL | 14
TAG_ERR_NOT_SUPPORT | 15
TAG_ERR_EVENT_INIT | 16
TAG_ERR_EVENT_REGISTER | 17
TAG_ERR_EVENT_SPACE | 18
TAG_ERR_EVENT_HANDLE | 19
TAG_ERR_EVENT_EMPTY | 20
TAG_ERR_AMOUNT | 21

enum STATUS_CODE

Enumerator
STATUS_INIT | 0
STATUS_READY | 1
STATUS_RUNNING | 2
STATUS_SUCCESS | 3
STATUS_FAIL | 4
STATUS_ERR_AMOUNT | 5

## Function Documentation

TAG_ERR_CODE MX_RTU_Tag_Init | ( | void |  | ) |

This API must be called at first.

Returns
  TAG_ERR_CODE

TAG_ERR_CODE MX_RTU_Tag_Uninit | ( | void |  | ) |

This API must be called at the end.

Returns
  TAG_ERR_CODE

TAG_ERR_CODE MX_RTU_Tag_List_All | ( | void |  | ) |

Listing all of the tags.

Returns
  TAG_ERR_CODE

TAG_ERR_CODE MX_RTU_Tag_Get_List | ( | TAG_INFO *** | list,
|  | UINT32 * | quantity
| ) |  |

Parameters

  [out] | ppList | list of all tags.
  [out] | quantity | quantity of the tags.

Returns
  TAG_ERR_CODE

TAG_ERR_CODE MX_RTU_Tag_Get_Info | ( | UINT8 * | tagName,
|  | TAG_INFO * | info
| ) |  |

Parameters

  [in] | tagName | name of the tag
  [out] | info | TAG_INFO of the specified tag.

Returns
  TAG_ERR_CODE

TAG_ERR_CODE MX_RTU_Tag_Read | ( | UINT8 * | tagName,
|  | void * | tagValue,
|  | UINT32 | tagSize,
|  | UINT32 * | readBytes,
|  | struct Timestamp * | time
| ) |  |

Parameters

  [in] | tagName | name of the tag
  [out] | tagValue | buffer to store the tag value
  [in] | tagSize | size of the specified tag.
  [out] | readBytes | actually read bytes. A null pointer can be specified to not to return this value.
  [out] | time | Timestamp of the tag value. A null pointer can be specified to not to return this value.

Returns
  TAG_ERR_CODE

TAG_ERR_CODE MX_RTU_Tag_Write | ( | UINT8 * | tagName,
|  | void * | tagValue,
|  | UINT32 | tagSize
| ) |  |

Parameters

  [in] | tagName | name of the tag
  [in] | tagValue | value to be wrote to the tag
  [in] | tagSize | size of the specified tag.

Returns
  TAG_ERR_CODE

TAG_ERR_CODE MX_RTU_MultiTag_Read | ( | UINT8 * | prefixTagName,
|  | UINT8 * | postfixTagName,
|  | UINT16 | start,
|  | UINT16 | count,
|  | UINT8 * | tagValue,
|  | struct Timestamp * | tagTimeStamp
| ) |  |

Parameters

  [in] | prefixTagName | prefix tag name, it could be a null pointer.
  [in] | postfixTagName | postfix tag name, it could be a null pointer.
  [in] | start | tag start
  [in] | count | tag amount
  [out] | tagValue | buffer to store tag values
  [out] | tagTimeStamp | Timestamp of the tag value. A null pointer can be specified to not to return this value.

Returns
  TAG_ERR_CODE

TAG_ERR_CODE MX_RTU_MultiTag_Write | ( | UINT8 * | prefixTagName,
|  | UINT8 * | postfixTagName,
|  | UINT16 | start,
|  | UINT16 | count,
|  | UINT8 * | tagValue
| ) |  |

Parameters

  [in] | prefixTagName | prefix tag name, it could be a null pointer.
  [in] | postfixTagName | postfix tag name, it could be a null pointer.
  [in] | start | tag start
  [in] | count | tag amount
  [in] | tagValue | values to be wrote to tags

Returns
  TAG_ERR_CODE

TAG_ERR_CODE MX_RTU_Tag_Event_Register | ( | UINT8 * | tagName,
|  | TAG_EVENT_CONDITION * | condition,
|  | int * | handle
| ) |  |

Parameters

  [in] | tagName | name of the tag
  [in] | condition | condition of the event. Refer to TagEventCondition.
  [out] | handle | a handle, like a file descriptor, stands for this tag event.

Returns
  TAG_ERR_CODE

TAG_ERR_CODE MX_RTU_Tag_Event_Unregister | ( | int | handle | ) |

Parameters

  [in] | handle | a handle, like a file descriptor, stands for the tag event.

Returns
  TAG_ERR_CODE

TAG_ERR_CODE MX_RTU_Tag_Event_Get | ( | int | handle,
|  | void * | tagValue,
|  | struct Timestamp * | time
| ) |  |

Parameters

  [in] | handle | a handle, like a file descriptor, stands for the tag event.
  [out] | tagValue | buffer to store the tag value when the condition is matched.
  [out] | time | Timestamp of the tag value. A null pointer can be specified to not to return this value.

Returns
  TAG_ERR_CODE

Note
  A non-blocking function. TAG_ERR_EVENT_EMPTY will be returned, if there is no event occurred.

TAG_ERR_CODE MX_RTU_Tag_Event_Clear | ( | int | handle | ) |

Parameters

  [in] | handle | a handle, like a file descriptor, stands for the tag event.

Returns
  TAG_ERR_CODE

Note
  Clear all the tag events in the queue.