[jira] [Created] (PLC4X-323) SocketCAN transport fails with out of memory error

2021-11-10 Thread Jira
Łukasz Dywicki created PLC4X-323:


 Summary: SocketCAN transport fails with out of memory error
 Key: PLC4X-323
 URL: https://issues.apache.org/jira/browse/PLC4X-323
 Project: Apache PLC4X
  Issue Type: Bug
  Components: Driver-CANopen
Affects Versions: 0.9.0, 0.8.0
Reporter: Łukasz Dywicki
Assignee: Łukasz Dywicki


After a month of continous work CANopen driver starts to fail with following 
error:

{code}
Exception in thread "javacan-reader" java.lang.OutOfMemoryError: Java heap space
at 
io.netty.util.internal.PlatformDependent.allocateUninitializedArray(PlatformDependent.java:285)
at 
io.netty.buffer.UnpooledUnsafeHeapByteBuf.allocateArray(UnpooledUnsafeHeapByteBuf.java:39)
at 
io.netty.buffer.UnpooledByteBufAllocator$InstrumentedUnpooledUnsafeHeapByteBuf.allocateArray(UnpooledByteBufAllocator.java:144)
at 
io.netty.buffer.UnpooledHeapByteBuf.capacity(UnpooledHeapByteBuf.java:133)
at 
io.netty.buffer.AbstractByteBuf.ensureWritable0(AbstractByteBuf.java:307)
at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1114)
at 
org.apache.plc4x.java.transport.socketcan.netty.SocketCANChannel.lambda$doConnect$0(SocketCANChannel.java:119)
at 
org.apache.plc4x.java.transport.socketcan.netty.SocketCANChannel$$Lambda$1043/0x000100d5a440.run(Unknown
 Source)
at java.base/java.lang.Thread.run(Thread.java:834)
{code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[BUILD-STABLE]: Job 'PLC4X/PLC4X/develop [develop] [667]'

2021-11-10 Thread Apache Jenkins Server
BUILD-STABLE: Job 'PLC4X/PLC4X/develop [develop] [667]':

Is back to normal.

[GitHub] [plc4x] hutcheb merged pull request #285: Matching Pull request from type PR from the build tools.

2021-11-10 Thread GitBox


hutcheb merged pull request #285:
URL: https://github.com/apache/plc4x/pull/285


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [plc4x-build-tools] hutcheb merged pull request #7: fix typo

2021-11-10 Thread GitBox


hutcheb merged pull request #7:
URL: https://github.com/apache/plc4x-build-tools/pull/7


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




Change in name of module plc4x-code-generaton

2021-11-10 Thread Ben Hutcheson
Hi All,

Thanks to hboutemy there is a PR in the plc4x-build-tools repo to change
the name of the plc4x-code-generaton module to plc4x-code-generation.

This fixes a type in the name of it. I don't see it causing any issues but
if you rely on it for something make sure that you update it.

Kind Regards

Ben


Re: Visitor pattern

2021-11-10 Thread Cesar Garcia
Hi Chris,

By having the behavior of the driver defined, each object generated by the
driver (based on the mspec) must add its control logic.

In general, the way to solve the answers is based on the differentiation of
the classes in two ways, using "instanceof" or checking the values of the
"properties".

In code it would be something like this:

if (payloadItems[0] instanceof
S7PayloadUserDataItemCpuFunctionMsgSubscriptionResponse) {
...
} else if (payloadItems[0] instanceof
S7PayloadUserDataItemCpuFunctionMsgSubscriptionSysResponse) {
...
} else if (payloadItems[0] instanceof
S7PayloadUserDataItemCpuFunctionMsgSubscriptionAlarmResponse) {
...
}  else if (payloadItems[0] instanceof
S7PayloadUserDataItemCpuFunctionAlarmAckResponse) {
...
}   else if (payloadItems[0] instanceof
S7PayloadUserDataItemCpuFunctionAlarmAckErrorResponse) {
...
}

An so on, and

if ((myparameter.getCpuFunctionGroup() == 0x04) &&
(myparameter.getCpuFunctionType() == 0x00) &&
(myparameter.getCpuSubfunction() == 0x03)) {
...
} else if ((myparameter.getCpuFunctionGroup() == 0x02) &&
(myparameter.getCpuFunctionType() == 0x00) &&
(myparameter.getCpuSubfunction() == 0x01)){
...
} else if  ((myparameter.getCpuFunctionGroup() == 0x02) &&
(myparameter.getCpuFunctionType() == 0x00) &&
(myparameter.getCpuSubfunction() == 0x05)) {
...
}

And so on

This is something that works and solves the problem, it is not in
discussion, and it is a good interceptor point for other languages, but how
can we help make it more readable and automatic from the mspec.


@startuml
interface Message
Message : public void accept(MessageVisitor visitor);

class S7PayloadUserDataItem
Message <-- S7PayloadUserDataItem
S7PayloadUserDataItem <--
S7PayloadUserDataItemCpuFunctionMsgSubscriptionResponse
S7PayloadUserDataItem <--
S7PayloadUserDataItemCpuFunctionMsgSubscriptionSysResponse
S7PayloadUserDataItem <--
S7PayloadUserDataItemCpuFunctionMsgSubscriptionAlarmResponse
S7PayloadUserDataItem <-- S7PayloadUserDataItemCpuFunctionAlarmAckResponse
S7PayloadUserDataItem <--
S7PayloadUserDataItemCpuFunctionAlarmAckErrorResponse

S7PayloadUserDataItemCpuFunctionMsgSubscriptionResponse : public void
accept(MessageVisitor visitor);
S7PayloadUserDataItemCpuFunctionMsgSubscriptionSysResponse : public void
accept(MessageVisitor visitor);
S7PayloadUserDataItemCpuFunctionMsgSubscriptionAlarmResponse : public void
accept(MessageVisitor visitor);
S7PayloadUserDataItemCpuFunctionAlarmAckResponse : public void
accept(MessageVisitor visitor);
S7PayloadUserDataItemCpuFunctionAlarmAckErrorResponse : public void
accept(MessageVisitor visitor);
@enduml

The only code required within each generated instance is

S7PayloadUserDataItemCpuFunctionMsgSubscriptionResponse() {
...
   public void accept(MessageVisitor visitor) {
   v.visit(this);
   }
...
}

Now the visitor interface can be generated manually or from the mspec.

@startuml
interface S7MessageVisitor
S7MessageVisitor : public void
visit(S7PayloadUserDataItemCpuFunctionMsgSubscriptionResponse visitable);
S7MessageVisitor : public void
visit(S7PayloadUserDataItemCpuFunctionMsgSubscriptionSysResponse visitable);
S7MessageVisitor : public void
visit(S7PayloadUserDataItemCpuFunctionMsgSubscriptionAlarmResponse
visitable);
S7MessageVisitor : public void
visit(S7PayloadUserDataItemCpuFunctionAlarmAckResponse visitable);
S7MessageVisitor : public void
visit(S7PayloadUserDataItemCpuFunctionAlarmAckErrorResponse visitable);
@enduml

Having this interface defined, we can implement directly on the protocol
logic object, in the case of S7 "S7ProtocolLogic".

After implementing the logic associated with the objects, the main code
would look like:

...
payloadItems [0] .accept (this);
...

Something more elegant, I think.

For the control of the state machine we would surely have to pass specific
parameters, so the interface of the visitors should be something like:

public void accept (MessageVisitor visitor, Object ... args);

or something similar,

As for why this pattern applies to our case.

1. The objects associated with the protocol do not change over time, unless
the protocol is changed, which in itself is another protocol.
2. The objects generated by the mspec only have properties and not
associated logic.
3. The logic associated with each object can be implemented by the Visitor
pattern, which from my point of view generates more organized code, while
remaining optional.

My grain of sand,




El mar, 9 nov 2021 a las 5:45, Christofer Dutz ()
escribió:

> Hi Cesar,
>
> could you possibly whip up some example code that shows how it's currently
> done and how you propose to do it?
>
> Sebastian and I are currently greatly refactoring the code-generation, so
> now would be a perfect time for optimizing things.
>
> Chris
>
> -Ursprüngliche Nachricht-
> Von: Cesar Garcia 
> Gesendet: Montag, 8. November 2021 21:02
> An: Apache PLC4X 
> Betreff: Visitor pattern
>
> Hi everyone,
>
> I have a query for you.
>
> In the case of mspec for