Log

Records the specified data in the logging shared memory.

Syntax

KsCommandStatus Log(
     int Length,
     KsLogChannel* Channels,
     int TriggerChannel,
     double TriggerValue,
     KsLogTriggerType TriggerType,
     double Duration
);

Parameters

Length: the length of the array that stores the logging channel. The maximum is eight channels.

Channels: the data that will be recorded in every channel. See the KsLogChannel structure.

TriggerChannel: the channel that is used for triggering the recording.

TriggerValue: when the logging channel's value reaches the trigger value, the recording starts.

TriggerType: the way to trigger the recording. See the KsLogTriggerType type.

Duration: how long you want to record the data. The unit is second. The log can be recorded up to 10 minutes. If you set it to zero, the system will continue recording and keep the latest 10-minute data.

Return value

Returns the KsCommandStatus structure.

Remarks

When you use RtOpenSharedMemory to get the log data, you must use "KSLogSpace" for the shared memory object's name.

Usable EtherCAT states

ecatOP

Example

Copy
double* LogData = NULL;

KsLogChannel Channels[3] =
{
    {KsLogSource::logAxis, 0, KsLogVariable::logActualPosition, 0, KsLogDataType::logDouble},
    {KsLogSource::logAxis, 0, KsLogVariable::logActualVelocity, 0, KsLogDataType::logDouble},
    {KsLogSource::logAxis, 0, KsLogVariable::logFollowingError, 0, KsLogDataType::logDouble}
};

// Stop current log
KsCommandStatus cmdStopLog = WaitForCommand(1, TRUE, StopLog());
if (!cmdStopLog.Error)
{
    // Log for 10 seconds
    KsCommandStatus cmdLog = Log(3, Channels, 0, 0, KsLogTriggerType::logImmediately, 10);
    cmdLog = WaitForCommand(11, TRUE, cmdLog);
    if (cmdLog.Done)
    {
        // Open log space
        HANDLE hLogMem = RtOpenSharedMemory(SHM_MAP_READ, FALSE, L"KSLogSpace", (void**)&LogData);
        double* data = (double*)malloc(sizeof(double) * 3 * (cmdLog.ValueLength));
        memcpy((void*)data, (void*)LogData, sizeof(double) * 3 * (cmdLog.ValueLength));
        RtCloseHandle(hLogMem); // Close log space

        // Access to log data

        free(data);
    }
}

Requirements

  RT Win32
Minimum supported version 4.0 4.0
Header ksapi.h ksapi.h
Library KsApi_Rtss.lib KsApi.lib

See also

AbortCommand

GetCommandStatus

StopLog

WaitForCommand