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

- Main Page
- Modules
- Data Structures
- Files

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

Moxa ActiveOPC Server (AOPC Server) More...

## Modules
| AOPCTagType
| AOPCTagAccessRight
| AOPCTagQuality

## Data Structures
struct | TagInfo

## Macros
#define | AOPC_DEFAULT_PORT 9900
#define | AOPC_MAX_DEV_NAME 59
#define | AOPC_MAX_TAG_NAME 30
#define | AOPC_MAX_TAG_DESC 16
#define | AOPC_MAX_TAG_UNIT 16
#define | AOPC_MAX_MULTIVALUES_UPDATE 256

## Typedefs
typedef struct TagInfo | TAG

## Enumerations
enum | AOPC_ERR_CODE { AOPC_ERR_OK = 0, AOPC_ERR_LIB_INIT, AOPC_ERR_PARAM, AOPC_ERR_SOCKET, AOPC_ERR_TIMEOUT, AOPC_ERR_CONNECT, AOPC_ERR_CREATE_THREAD, AOPC_ERR_NO_MEMORY, AOPC_ERR_NO_QUEUE, AOPC_ERR_INTR, AOPC_ERR_FRAME_PENDING, AOPC_ERR_FRAME_ERROR, AOPC_ERR_SERVER_ERROR, AOPC_ERR_CLOSE, AOPC_ERR_NO_TAG, AOPC_ERR_EXIST_TAG, AOPC_ERR_NO_WRITE_FUNC, AOPC_ERR_ACCESS, AOPC_ERR_USER_WRITE, AOPC_ERR_NOT_SUPPORT, AOPC_ERR_NOT_WRITABLE, AOPC_ERR_FAIL, AOPC_ERR_NOT_REGISTERED, AOPC_ERR_INVALID_ATTR, AOPC_ERR_SYSTEM_INFO, AOPC_ERR_STR_LEN, AOPC_ERR_AMOUNT }

## Functions
AOPC_ERR_CODE | MX_RTU_AOPC_Init (void)
| This API must be called at first. More...
void | MX_RTU_AOPC_Uninit (void)
| This API must be called at the end. More...
AOPC_ERR_CODE | MX_RTU_AOPC_Connect (UINT8 *deviceName, UINT32 heartBeatS, UINT8 *ipAddress, UINT16 port, UINT32 timeoutMs, UINT32 *sHandle)
AOPC_ERR_CODE | MX_RTU_AOPC_Disconnect (UINT32 sHandle)
AOPC_ERR_CODE | MX_RTU_AOPC_Reconnect (UINT32 sHandle, UINT32 timeoutMs)
AOPC_ERR_CODE | MX_RTU_AOPC_AddTag (UINT32 sHandle, TAG *tagInfo, struct Timestamp *tagTime, UINT32 timeoutMs)
AOPC_ERR_CODE | MX_RTU_AOPC_DelTag (UINT32 sHandle, UINT8 *tagName, UINT32 timeoutMs)
AOPC_ERR_CODE | MX_RTU_AOPC_DelAllTag (UINT32 sHandle, UINT32 timeoutMs)
AOPC_ERR_CODE | MX_RTU_AOPC_UpdateTag (UINT32 sHandle, TAG *tagInfo, struct Timestamp *tagTime, UINT32 timeoutMs)
AOPC_ERR_CODE | MX_RTU_AOPC_UpdateValue (UINT32 sHandle, UINT8 *tagName, void *tagValue, struct Timestamp *tagTime, UINT32 timeoutMs)
AOPC_ERR_CODE | MX_RTU_AOPC_UpdateMultiValue (UINT32 sHandle, UINT16 nTags, UINT8 **tagName, void **tagValue, struct Timestamp *tagTime, UINT32 timeoutMs)
AOPC_ERR_CODE | MX_RTU_AOPC_UpdateHeartbeat (UINT32 sHandle, UINT32 heartbeatS, UINT32 timeoutMs)

## Detailed Description

Moxa ActiveOPC Server (AOPC Server)

Sample Code:
aopc_io_update.c

## Macro Definition Documentation

#define AOPC_DEFAULT_PORT 9900

#define AOPC_MAX_DEV_NAME 59

#define AOPC_MAX_TAG_NAME 30

#define AOPC_MAX_TAG_DESC 16

#define AOPC_MAX_TAG_UNIT 16

#define AOPC_MAX_MULTIVALUES_UPDATE 256

## Typedef Documentation

typedef struct TagInfo TAG

## Enumeration Type Documentation

enum AOPC_ERR_CODE

Enumerator
AOPC_ERR_OK | 0
AOPC_ERR_LIB_INIT | 1
AOPC_ERR_PARAM | 2
AOPC_ERR_SOCKET | 3
AOPC_ERR_TIMEOUT | 4
AOPC_ERR_CONNECT | 5
AOPC_ERR_CREATE_THREAD | 6
AOPC_ERR_NO_MEMORY | 7
AOPC_ERR_NO_QUEUE | 8
AOPC_ERR_INTR | 9
AOPC_ERR_FRAME_PENDING | 10
AOPC_ERR_FRAME_ERROR | 11
AOPC_ERR_SERVER_ERROR | 12
AOPC_ERR_CLOSE | 13
AOPC_ERR_NO_TAG | 14
AOPC_ERR_EXIST_TAG | 15
AOPC_ERR_NO_WRITE_FUNC | 16
AOPC_ERR_ACCESS | 17
AOPC_ERR_USER_WRITE | 18
AOPC_ERR_NOT_SUPPORT | 19
AOPC_ERR_NOT_WRITABLE | 20
AOPC_ERR_FAIL | 21
AOPC_ERR_NOT_REGISTERED | 22
AOPC_ERR_INVALID_ATTR | 23
AOPC_ERR_SYSTEM_INFO | 24
AOPC_ERR_STR_LEN | 25
AOPC_ERR_AMOUNT | 26

## Function Documentation

AOPC_ERR_CODE MX_RTU_AOPC_Init | ( | void |  | ) |

This API must be called at first.

Returns
  AOPC_ERR_CODE

void MX_RTU_AOPC_Uninit | ( | void |  | ) |

This API must be called at the end.

AOPC_ERR_CODE MX_RTU_AOPC_Connect | ( | UINT8 * | deviceName,
|  | UINT32 | heartBeatS,
|  | UINT8 * | ipAddress,
|  | UINT16 | port,
|  | UINT32 | timeoutMs,
|  | UINT32 * | sHandle
| ) |  |

Parameters

  [in] | deviceName | A device name displayed on AOPC Server.
  [in] | heartBeatS | Alive Check for the connection by seconds, giving zero will disable this function.
  [in] | ipAddress | AOPC Server IP.
  [in] | port | AOPC Server Port, default port is 9900.
  [in] | timeoutMs | AOPC connecting timeout by mini seconds.
  [out] | sHandle | A handle, like a file descriptor, stands for the connection.

Returns
  AOPC_ERR_CODE

AOPC_ERR_CODE MX_RTU_AOPC_Disconnect | ( | UINT32 | sHandle | ) |

Parameters

  [in] | sHandle | A handle, like a file descriptor, stands for the connection.

Returns
  AOPC_ERR_CODE

AOPC_ERR_CODE MX_RTU_AOPC_Reconnect | ( | UINT32 | sHandle,
|  | UINT32 | timeoutMs
| ) |  |

Parameters

  [in] | sHandle | A handle, like a file descriptor, stands for the connection.
  [in] | timeoutMs | AOPC reconnecting timeout by mini seconds.

Returns
  AOPC_ERR_CODE

AOPC_ERR_CODE MX_RTU_AOPC_AddTag | ( | UINT32 | sHandle,
|  | TAG * | tagInfo,
|  | struct Timestamp * | tagTime,
|  | UINT32 | timeoutMs
| ) |  |

Parameters

  [in] | sHandle | A handle, like a file descriptor, stands for the connection.
  [in] | tagInfo | Tag Information for AOPC Server.
  [in] | tagTime | Tag timestamp, NULL stands for no timestamp.
  [in] | timeoutMs | Adding timeout by mini seconds.

Returns
  AOPC_ERR_CODE

AOPC_ERR_CODE MX_RTU_AOPC_DelTag | ( | UINT32 | sHandle,
|  | UINT8 * | tagName,
|  | UINT32 | timeoutMs
| ) |  |

Parameters

  [in] | sHandle | A handle, like a file descriptor, stands for the connection.
  [in] | tagName | Deleting a specific tag by name, the tag should be added already.
  [in] | timeoutMs | Deleting timeout by mini seconds.

Returns
  AOPC_ERR_CODE

AOPC_ERR_CODE MX_RTU_AOPC_DelAllTag | ( | UINT32 | sHandle,
|  | UINT32 | timeoutMs
| ) |  |

Parameters

  [in] | sHandle | A handle, like a file descriptor, stands for the connection.
  [in] | timeoutMs | Deleting timeout by mini seconds.

Returns
  AOPC_ERR_CODE

AOPC_ERR_CODE MX_RTU_AOPC_UpdateTag | ( | UINT32 | sHandle,
|  | TAG * | tagInfo,
|  | struct Timestamp * | tagTime,
|  | UINT32 | timeoutMs
| ) |  |

Parameters

  [in] | sHandle | A handle, like a file descriptor, stands for the connection.
  [in] | tagInfo | Tag Information for AOPC Server.
  [in] | tagTime | Tag timestamp, NULL stands for no timestamp.
  [in] | timeoutMs | Updating timeout by mini seconds.

Returns
  AOPC_ERR_CODE

AOPC_ERR_CODE MX_RTU_AOPC_UpdateValue | ( | UINT32 | sHandle,
|  | UINT8 * | tagName,
|  | void * | tagValue,
|  | struct Timestamp * | tagTime,
|  | UINT32 | timeoutMs
| ) |  |

Parameters

  [in] | sHandle | A handle, like a file descriptor, stands for the connection.
  [in] | tagName | Updating a specific tag by name, the tag should be added already.
  [in] | tagValue | Updated tag value.
  [in] | tagTime | Tag timestamp, NULL stands for no timestamp.
  [in] | timeoutMs | Updating timeout by mini seconds.

Returns
  AOPC_ERR_CODE

AOPC_ERR_CODE MX_RTU_AOPC_UpdateMultiValue | ( | UINT32 | sHandle,
|  | UINT16 | nTags,
|  | UINT8 ** | tagName,
|  | void ** | tagValue,
|  | struct Timestamp * | tagTime,
|  | UINT32 | timeoutMs
| ) |  |

Parameters

  [in] | sHandle | A handle, like a file descriptor, stands for the connection.
  [in] | nTags | Number of tags.
  [in] | tagName | Updating multi-tags by name, these tags should be added already.
  [in] | tagValue | Updating multi-tags value.
  [in] | tagTime | Tag timestamp, NULL stands for no timestamp.
  [in] | timeoutMs | Updating timeout by mini seconds.

Returns
  AOPC_ERR_CODE

AOPC_ERR_CODE MX_RTU_AOPC_UpdateHeartbeat | ( | UINT32 | sHandle,
|  | UINT32 | heartbeatS,
|  | UINT32 | timeoutMs
| ) |  |

Parameters

  [in] | sHandle | A handle, like a file descriptor, stands for the connection.
  [in] | heartbeatS | Updated heartbeat by seconds.
  [in] | timeoutMs | Updating timeout by mini seconds.

Returns
  AOPC_ERR_CODE