Hi,
able to send metric data collected from different tags as JSON format to other system using APIs.. challenge now they need the data in protobuf encoding format . Is there any guidance to do that
{
"metrics": [
{
"tagName": "speed1",
"value": 92.02906036376953,
"timestamp": 1729546154762
},
{
"tagName": "speed2",
"value": 92.02906036376953,
"timestamp": 1729546154763
},
{
"tagName": "temp1",
"value": 41.07870101928711,
"timestamp": 1729546154765
},
{
"tagName": "temp2",
"value": 92.02906036376953,
"timestamp": 1729546154767
}
]
Notice Ignition 8.3 going to use protoBuf for EAM .. I hope to get some guidance or way of work to be able to use protobuf encoding
"Protobuf" is a very broad umbrella. Protobuf is a schemaless encoding, so it cannot be written or read by either end without out-of-band communication to share message formats. That is, two totally different protobuf messages could have exactly the same binary representation on the wire. Ignition's use of protobuf is probably not going to help you with whatever you're trying to do.
The only way if found is using protobuf python library but it has some C dependency on C. Thus why we can't import it to pylib in ignition .
other way to use Flask as and end point to encoding outside ignition then get the result and pass to APIs to consumer ..
is my way of thinking is right or there's better approach .
You cannot do anything without the protobuf schemas for whatever you're trying to talk to. You could, in theory, either then use these to code-generate some Java code (what I'd recommend) that you then use from Jython, or try to find a pure-Python library (that works on Python 2.7) that you can integrate and use to generate the appropriate binary data at runtime.
Yes, Schema created and store in *.proto file ..
there's no pure-pyhton library to be used with jython2.7 .
How to start with this approach ?
1 Like
it's working after getting some guidance from Ignition support team
-
Define the Protobuf schema that describes the structure of the data you want to serialize/deserialize. This schema file (.proto
) defines the types and structure of the messages.
-
Generate Java code from the Protobuf schema using a Protobuf compiler (protoc
) to generate Java classes from the .proto
schema file.
- The
protoc
compiler reads the .proto
file and outputs Java source files corresponding to the schema.
- Compile the generated Java code using a Java compiler (
javac
).
- Use the generated Java code by adding the compiled Java classes & JAR file to Ignition, then importing these classes within your script.
- Now serialize/deserialize Protobuf messages using the generated code in your script.
1 Like