mtconnect / cppagent

C++ Agent toolkit - Pre-built binaries, visit: https://github.com/mtconnect/cppagent/releases Docker images available at https://hub.docker.com/repositories/mtconnect
http://mtcup.org/
Apache License 2.0
143 stars 91 forks source link

`SAMPLE` cannot be represented as a `DATA_SET` #500

Closed robot-ranger closed 2 days ago

robot-ranger commented 5 days ago

I was expecting to be able to represent a sample as a dataset, but the agent complains about not being able to convert to a double:

SHDR:

[11]: DATAITEMS SHDR: 2024-11-24T00:10:16.033491Z|mxi_m001_target_q|j0=-105.939 j1=-64.723 j2=-129.918 j3=-90.387 j4=128.378 j5=-21.754

Agent log:

2024-11-24T00:10:16.879811Z (0x0000007fa7fff000) [warning] Connector::reader->Connector::parseSocketBuffer->Connector::processLine->ShdrAdapter::processData->DataItemMapper.ShdrTokenMapper.operator->DataItemMapper.ShdrTokenMapper.mapTokensToDataItem->zipProperties: Cannot convert value for data item id 'mxi_m001_target_q': j0=-105.939 j1=-64.723 j2=-129.918 j3=-90.387 j4=128.378 j5=-21.754 - (VALUE): cannot convert string 'j0=-105.939 j1=-64.723 j2=-129.918 j3=-90.387 j4=128.378 j5=-21.754' to double

device.xml:

<?xml version="1.0" encoding="UTF-8"?>
<MTConnectDevices
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="urn:mtconnect.org:MTConnectDevices:2.3"
  xsi:schemaLocation="urn:mtconnect.org:MTConnectDevices:2.3 https://schemas.mtconnect.org/schemas/MTConnectDevices_2.3.xsd">
    <Header deviceModelChangeTime="2022-06-17T16:33:21.188094Z" creationTime="2013-04-02T03:40:04Z" assetBufferSize="1024" sender="localhost" assetCount="0" version="2.3" instanceId="1" bufferSize="131072"/>
    <Devices>
        <Device name="machine_1" id="mxi_m001" uuid="mxi_m001">
            <DataItems>
                <DataItem id="mxi_m001_target_q" name="target_q" type="ANGLE" representation="DATA_SET" category="SAMPLE" subType="COMMANDED"/>
            </DataItems>
        </Device>
    </Devices>
</MTConnectDevices>

the use case here is a digital twin of a 6-axis robot. the joint angles are provided from the robot.

It seems to work if i change category="EVENT" instead of SAMPLE. technically type="ANGLE" is not an EVENT, but the agent doesnt seem to care about that?

Is there a better way to model this?

wsobel commented 5 days ago

I’ll need to check the code. I’m not sure if we’ve done a sample as a data set as of yet. It should override he sample category conversion, but I’m not sure what takes precidece. You’re right this is not the behavior desired.

Sent from my iPad

robot-ranger commented 5 days ago

what is the functional or parsing difference between a sample and an event? or are they truely just 'categories'?

wsobel commented 5 days ago

They are just categories, but a sample is fixed as a floating point number where as an event can have a controlled vocabulary or a string value. Representation is handled as a special case when parsing.

I may have inverted the checks on the observation factory method that messed this up. I’ll check tomorrow. The code is fairly complex handling all the type construction and checks.

robot-ranger commented 2 days ago

SAMPLE as DATA_SET Works great now! 👍