riclolsen / json-scada

A portable and scalable SCADA/IIoT-I4.0/Gateway platform centered on the MongoDB database server.
https://riclolsen.github.io/json-scada/
GNU General Public License v3.0
291 stars 77 forks source link

New tag will not be processed by cs_data_processor. #38

Closed Drincann closed 3 years ago

Drincann commented 3 years ago

Hello.

When I created a new label on the admin page and configured it, sending data to the mqtt subject of the new label did not work.

I checked the realtimeData collection of mongo db and confirmed that the sourceDataUpdate field of this collection has been written with the data I just sent, which shows that the sparkplug-mqtt module is working properly.

So I went to debug the cs_data_processor module and found that the data update of the new label did not trigger the change event of the changeStream of cs_data_processor, so I saw this piece of code. It seems that one condition that triggers the change event is that the tag has a value field.

json-scada/src/cs_data_processor/cs_data_processor.js: image

I noticed that creating a new tag is achieved through the /Invoke/auth/createTag route of server_realtime_auth.

json-scada/src/server_realtime_auth/app/controllers/auth.controller.js: image

But the mongooseSchema used by this route does not contain the value field.

json-scada/src/server_realtime_auth/app/models/tag.model.js: image

Is the reason for the missing value field because of my wrong way of using it?

Did I miss something?

Thank you!

riclolsen commented 3 years ago

It was missing the value field and many others. I've committed the fixes now. Great contribution, thanks.