Can FreeOpcUa python be used to generate a custom event with a set of nodeIds? - opc-ua

From my OPC-UA server I want to generate a custom event. The custom event shall contain a set of "nodes".
Each "node" shall contain nodeId, parent nodeId and node name.
Is that possible using https://github.com/FreeOpcUa/python-opcua?

Indeed you can use the server-event example:
https://github.com/FreeOpcUa/python-opcua/blob/master/examples/server-events.py
It contains the creation of custom events.

Related

How do I add at runtime an https header to a Power App custom connector

In PowerApps, custom connector, I need to define the entire structure of the call when I create the custom connector. I know I can mark certain fields (query params) as parameters that can be filled during run time.
What I try to do is to set the value of one of my security http headers at run time.
My connector, with an API key, makes a call to the /extra/auth end point
/extra/auth returns another key value.
I need to use this new key value in any consecutive calls to my APIs in the HEADER of the request.
I can use two separate connectors for the auth and for the application logic (which seems logic to me).
How would you go to set an http header value at run time for a custom connector - REST api?

Marklogic DHF5:- Can we return multiple content for one document in main.sjs

We are migrating from MarkLogic DHF4 to DHF5 (Data Hub Framework)
We are having scenario where for one entity, depending on criteria we need to create more than one harmonize document for a single input document. This scenario was possible in legacy flow where we used to call write:write method.
But in DHF5 implementation we are supposed to return only one content for one input document getting processed in main module main.sjs.
Is there a way where we can create multiple harmonize document as required from one input document in DHF5?
We expect that one input document should be able to create more than one harmonized document in single step(in main.sjs)
Your custom module is expected to return a Content object or an array of them. Each Content object must have uri, value, and context properties and may also specify provenance.
Based on this, your one input can be turned into multiple outputs.
See the "Required Outputs" section on this page for more details.
Your module must return the following:
For a Custom-Ingestion step, a Content object.
For all other custom steps, a Content object or an array of Content objects.

LoopBack: How do I use PUT to replace an entry

I struggle a bit with a basic PUT in a LoopBack project, but I cannot find any information about my problem. If use PUT to add an entry everything works fine, I just pass my data and there is a new entry in the database. Now I want to replace an entry, as described in the documentation for PUT (I am using the API explorer for my tests). My idea was to pass an 'id' (in addition to the changed data) and LoopBack would replace the corresponding entry. But that does not work, I get the error:
The `Model` instance is not valid. Details: `id` can't be set
How can I use PUT to replace an entry?
The id property in the PUT payload should be optional. If you're using the standard Loopback model CRUD endpoints that are set up during model generation you have two options:
Using the PUT /ModelName/{id} option where LB will find the model instance based on the query parameter passed into the URL.
Using the POST /ModelName/{id}/replace endpoint. This endpoint will replace all attributes of a given model instance based on the id that's passed into the URL.
Passing in the id property in the payload of the request is optional for both endpoints. Loopback will find the model instance based on the id param of the URL.

Using visjs manipulation to create workflow dependencies

We are currently using visjs version 3 to map the dependencies of our custom built workflow engine. This has been WONDERFUL because it helps us to visualize the flow and find invalid or missing dependencies. What we want to do next is simplify the process of building the dependencies using the visjs manipulation feature. The idea would be that we would display a large group of nodes and allow the user to order them correctly. We then want to be able to submit that json structure back to the server for processing.
Would this be possible?
Yes, this is possible.
Vis.js dispatches various events that relate to user interactions with graph (e.g. manipulations, or position changes) for which you can add handlers that modify or store the data on change. If you use DataSets to store nodes and edges in your network, you can always use the DataSets' get() function to retrieve all elements in you handler in JSON format. Then in your handler, just use an ajax request to transmit the JSON to your server to store the entire graph in your DB or by saving the JSON as a file.
The oppposite for loading the graph: simply query the JSON from your server and inject it into the node and edge DataSets' using the set method.
You can also store the networks current options using the network's getOptions method, which returns all applied options as json.

Strategy to generate auto increment unique number in CQ

I have a requirement to create CQ pages programmatically. But the challenge is that the page name/uri should be autogenerated combination of a string + unique number (eg. PT2000, PT2001).
Can someone tell me a way way to generate an autoincrement-id/constant in CQ in a way that the id's are unique even with multiple concurrent request?
Use a service that provides you with the ID and that manages the counter inside a volatile instance variable to make sure that state changes by one thread are immediately communicated to all other threads.
This should do the trick as long as your can guarantee that your implementation runs on a single author node. In a cluster scenario you additionally have to care about executing it only on one node.
i'd suggest creating a service that manages its counters somewhere in the repository, and also acts as a jcr EventListener. the service should listen for NODE_ADDED events on parent nodes of type cq:Page, and once onEvent is called, it can assigned the unique id at that point. you'd want to use synchronization obviously so that overlapping calls to onEvent() won't use up the same id.
You can use a GUID, Graphic User ID, the ID generated has a great probablity of uniqueness.
See wiki reference http://en.wikipedia.org/wiki/Globally_unique_identifier
and to create GUID:
Create a GUID in Java
This will ease you effort to verify the number is unique so just generate the ID and create the pages with that ID.
Doesn't AEM automatically append numbers to same name pages?
If it doesn't, then presumably this would fail, at which point you start over with the next number. Best guess should be enough in this case.