DSRemoteConnect C++ Library 1.1.3.24 Remote connection library for Dewesoft measurement applications

Loading...
Searching...
No Matches
DSRemoteConnect Library Documentation

# Introduction

DSRemoteConnect is a C++ library that provides remote connectivity to Dewesoft measurement applications. It supports two connection types:

- DCOM: For local/remote Windows applications using Microsoft's Distributed Component Object Model
- NET: For network-based connections using TCP/IP protocols

# Key Features

- Remote control of Dewesoft measurement sessions
- Real-time data acquisition from measurement channels
- Setup file loading and management
- Channel enumeration and property access
- Control channel writing capabilities
- Cross-platform support (Windows primary, with network support for other platforms)

# Basic Usage

## Basic Connection and Data Reading

#include "DSRemoteConnect.h"
int main() {
DSXInstanceHandle instance;
// Create instance for NET connection
dsconCreateInstance(&instance, DSX_CONNECTION_TYPE_NET);
// Connect to Dewesoft (localhost:8999:8001 = telnet_port:data_port)
dsconConnect(instance, "localhost:8999:8001");
// Load measurement setup
dsconLoadSetup(instance, "C:\\path\\to\\setup.dxs");
// Get channel count
size_t channelCount;
dsconGetChannelCount(instance, &channelCount);
// Enumerate channels
ChannelIdList channelList;
dsconEnumerateChannels(instance, &channelList, &channelCount);
// Create channel instance for first channel
ChannelInstanceHandle channel;
dsconCreateChannelInstance(instance, channelList[0], &channel);
// Start measurement
dsconStartMeasurement(instance);
// Read data in loop
double* data = new double[1000];
double* timestamps = new double[1000];
size_t dataCount = 1000;
while (measurement_active) {
if (dsconChannelReadScalarData_2(channel, data, timestamps, &dataCount) == DSX_NO_ERROR) {
// Process data...
}
}
// Cleanup
dsconStopMeasurement(instance);
dsconFreeChannelInstance(channel);
dsconFreeEnumerateChannels(instance, &channelList);
dsconDisconnect(instance);
dsconDestroyInstance(instance);
delete[] data;
delete[] timestamps;
return 0;
}
DSX_NO_ERROR
@ DSX_NO_ERROR
No error - operation successful.
Definition ConstsAndTypeDefs_Documented.h:25
DSX_CONNECTION_TYPE_NET
@ DSX_CONNECTION_TYPE_NET
Network connection using TCP/IP protocols.
Definition ConstsAndTypeDefs_Documented.h:123
dsconFreeChannelInstance
DSREMOTECONNECT_API int dsconFreeChannelInstance(ChannelInstanceHandle chInstance)
Free a channel instance.
dsconDestroyInstance
DSREMOTECONNECT_API int dsconDestroyInstance(DSXInstanceHandle handle)
Destroy a DSX instance.
dsconLoadSetup
DSREMOTECONNECT_API int dsconLoadSetup(DSXInstanceHandle handle, char *fileName)
Load a Dewesoft setup file.
DSXInstanceHandle
DSXInstance * DSXInstanceHandle
Handle to a DSX instance for connection management.
Definition DSRemoteConnect_Documented.h:150
dsconStopMeasurement
DSREMOTECONNECT_API int dsconStopMeasurement(DSXInstanceHandle handle)
Stop measurement.
dsconCreateChannelInstance
DSREMOTECONNECT_API int dsconCreateChannelInstance(DSXInstanceHandle handle, ChannelID id, ChannelInstanceHandle *chInstance)
Create a channel instance by ID.
dsconChannelReadScalarData_2
DSREMOTECONNECT_API int dsconChannelReadScalarData_2(ChannelInstanceHandle handle, double *data, double *timestamps, size_t *count)
Read scalar data from channel (recommended version)
dsconEnumerateChannels
DSREMOTECONNECT_API int dsconEnumerateChannels(DSXInstanceHandle handle, ChannelIdList *channelIdList, size_t *count)
Enumerate all available channels.
ChannelInstanceHandle
ChannelInstance * ChannelInstanceHandle
Handle to a measurement channel instance.
Definition DSRemoteConnect_Documented.h:159
dsconFreeEnumerateChannels
DSREMOTECONNECT_API int dsconFreeEnumerateChannels(DSXInstanceHandle handle, ChannelIdList *channelIdList)
Free memory allocated by channel enumeration.
dsconCreateInstance
DSREMOTECONNECT_API int dsconCreateInstance(DSXInstanceHandle *handle, int connectionType)
Create a new DSX instance.
dsconStartMeasurement
DSREMOTECONNECT_API int dsconStartMeasurement(DSXInstanceHandle handle)
Start measurement.
dsconDisconnect
DSREMOTECONNECT_API int dsconDisconnect(DSXInstanceHandle handle)
Disconnect from Dewesoft application.
dsconGetChannelCount
DSREMOTECONNECT_API int dsconGetChannelCount(DSXInstanceHandle handle, size_t *count)
Get the total number of available channels.
dsconConnect
DSREMOTECONNECT_API int dsconConnect(DSXInstanceHandle handle, char *connectionString)
Connect to a Dewesoft application.

## DCOM Connection Example

// For DCOM connections (local Dewesoft instance)
DSXInstanceHandle instance;
dsconCreateInstance(&instance, DSX_CONNECTION_TYPE_DCOM);
dsconConnect(instance, ""); // Empty string for local DCOM
DSX_CONNECTION_TYPE_DCOM
@ DSX_CONNECTION_TYPE_DCOM
DCOM connection for local/remote Windows applications.
Definition ConstsAndTypeDefs_Documented.h:120

# Error Handling

All functions return DX_ERROR_CODE values. Always check return codes:

int result = dsconStartMeasurement(instance);
if (result != DSX_NO_ERROR) {
printf("Failed to start measurement: error code %d\n", result);
// Handle error...
}

# Threading Considerations

- The library is not thread-safe by default
- Use proper synchronization when accessing from multiple threads
- Data reading functions can be called from different threads than control functions

# Memory Management

- Always call dsconFreeChannelInstance() for created channel instances
- Always call dsconFreeEnumerateChannels() after dsconEnumerateChannels()
- Always call dsconDestroyInstance() for created instances
- Manage your own data buffers (arrays passed to read functions)