On Mon, Feb 11, 2019 at 3:17 AM Christofer Dutz <christofer.d...@c-ware.de> wrote: > > Hi all, > > my PLC4X driver using a combination of Apache Commons SCXML (2.0) and Apache > Daffodil is doing even better than I imagined, when starting the whole thing. > > Right now I’m improving the thing to be more on-par with the existing drivers. > > However there are still a few little things bugging me and I’ve spent quite > some time working on them. > > > 1. Is it possible to spawn multiple execution heads (Similar to threads in > Java)? > The reason is that in my protocol state machine, there is a single-threaded > connection part (that works fine) … part of this connection process is to > negotiate the number of parallel requests the client is allowed to send to > the PLC. In my S7-1200 this is usually 3 or so. So I am allowed to send up to > 3 requests in parallel … after that, I have to wait with sending the next, > till one of these is acknowledged by receiving a response. > Right now I’m serializing everything … but that’s a simplification that > greatly impacts the drivers performance. So I know there are parallel > executions … but how can I enter multiple instances of “sendRequest” and wait > for them to pass “readResponse” … and the number is dynamic.
If <send> used, I think the only option is to inject a custom org.apache.commons.scxml2.EventDispatcher into your org.apache.commons.scxml2.SCXMLExecutor to spawn multiple threads. You could nest N states in <parallel> for each nested state to send, or you could have a transition with one send transitioning back to itself again until the number is met, I guess. > > > 1. Is there a way to pass data with a transition? > As I mentioned, I have a static part of my state machine which ends in a > “connected” state. Here is where the driver can branch to process the > different types of requests by transitioning to a “sendReadRequest”, > “sendWriteRequest”, “sendDisconnectRequest” state. Now my driver > programmatically initiates one of these by sending a “read”, “write” or > “disconnect” event and I take the _event.data and assign it to a data element > in the global datamodel … however this would prevent me from using and form > of parallelism … so I guess this is a follow up from question 1: If > paralellizm is possible, how can I pass the “readRequest” provided to the > “read” event to the “sendReadRequest” state without using a global variable? I'd try with a custom action (of org.apache.commons.scxml2.model.Action), in onentry for instance. The custom action will probably be able to retrieve the current parent state and read _event data and set state scope context variable. Regards, Woonsan > > > Chris --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org