Re: [DriverGen] Major refactoring and great improvements

2019-05-31 Thread Christofer Dutz
Hi all,

just in time for going to that free music festival in Darmstadt I finally 
finished the serialization code generation. 
I know there's still one or two issues with "optionalField"s but I think in 
general you should get the idea.

If you want to try it out, please checkout the "feature/code-gen" branch and 
update that. 

In the "sandbox/code-generation" directory is a maven project that's separate 
from the rest. 
You should be able to build it with: "mvn clean package" ... then in the 
"test-java-s7-driver/target/generated-sources/plc4x" directory, you should see 
the generated code. 

It doesn't do anything yet as I haven't implemented the ReadBuffer and 
WriteBuffer methods, so please just have a look at the code ... 
I'll fill the rest with life next weekend (or during the weekend as I do know 
that I just can't resist working on this ;-))


Chris



Am 30.05.19, 11:04 schrieb "Christofer Dutz" :

Hi Julian,

I think you misunderstood my question /problem.

The s7 protocol already is layered with 3 layers.
The problem I am currently having is more a problem if how to write the 
parser software.

In case of the s7 message there are slightly different header fields, 
depending on the type, but the payload is the same.

Ideally I would have parsed the data of the base type first and passed that 
to the sub-type, which then does the intantiation. Here however parameter and 
payload are still missing, because they haven't been parsed yet and can only be 
parsed after the sub-type is done parsing its parts.

Now I could make these properties mutable and set them using setters after 
the type is instantiated (which isn't nice)... Or I have the subtype parser 
return an object containing only the subtype fields and a builder method, which 
takes all the base-type fields and is called at the end of the base type 
parser. It then uses all the fields of the base-type which are passed as 
argument to the builder method plus the sub-type fields it contains and is then 
able to construct an immutable Object.

Chris

Outlook für Android herunterladen


From: Julian Feinauer 
Sent: Thursday, May 30, 2019 12:06:22 AM
To: dev@plc4x.apache.org
Subject: Re: [DriverGen] Major refactoring and great improvements

Hey Chris,

this is one oft he problems I also stumbled across when reasoning and which 
I consider 'hard'.
One way to make it way cleaner would be to switch to a layered architecture.
If we generally distinguish between Transport Layers and Communication 
Layer (better anmes are welcome) we can introduce a general format of these 
transport layers which is

[Type
[Some Type of header Stuff]
[byte[] payload]
[Some Type of fooder Stuff]
]

This would also enforce reusability.

Or am I getting things wrong?

Am 29.05.19, 23:55 schrieb "Christofer Dutz" :

Hi all,

so today I somewhat finished the POJO generation for Java and am 
currently implementing the IO classes to parse the POJOs (Second step will be 
serializing)

Now I stumbled into following problem (One example from the S7 
protocol):

[discriminatedType 'S7Message' ['payloadLength']
[const uint 8  'protocolId'  '0x32']
[discriminator uint 8  'messageType']
[reserved  uint 16 '0x']
[field uint 16 'tpduReference']
[implicit  uint 16 'parameterLength' 'parameters.size']
[implicit  uint 16 'payloadLength'   'payloads.size']
[typeSwitch 'messageType'
['0x01' Request
[context string 'messageType' 'request']
]
['0x03' Response
[context string 'messageType' 'response']
[field uint 8 'errorClass']
[field uint 8 'errorCode']
]
['0x07' UserData
[context string 'messageType' 'userData']
]
]
[field S7Parameter 'parameter' {messageType: 'messageType'}]
[field S7Payload 'payload' {messageType: 'messageType', parameter: 
'parameter'}]
]

As you can see there's properties that belong to the base type and 
parts that belong to Request, Response and UserData ... however this 
information is sort of in-between the header and the footer.

Enforcing the switch to be the last and pulling the parameter and 
payload into the cases, sounds like an ugly restriction.

So I thought that I might generate some parser classes for the 
sub-types, that contain the sub-type properties only and a factory method ... 
to in this case the Response factory pojo class which would sort of look like 
this:


Re: Exciting news for Apache comimtters

2019-05-31 Thread Niclas Hedhman
To clarify; The offer from Jetbrains refers to the "paid for" editions and
to be used for non-commercial, open source development ONLY. For other
uses, please use the "community editions" (where available) or subscribe to
the tool chain (which nowadays is a lot cheaper than it used to be).

To apply, go to https://www.jetbrains.com/community/opensource/ and to the
bottom of the page (Supporting the Apache Software Foundation)

Cheers
Niclas

On Fri, May 31, 2019 at 3:09 PM Christofer Dutz 
wrote:

> Hi all,
>
> As we are now supporting more and more languages, the question of IDEs for
> these Languages come up.
> I don’t know if you followed the latest announcements, but Jetbrains seem
> to have extended their offer to the ASF.
> In the past Apache Committers could request a free IntelliJ license from
> them. This seems to have been extended
> To the full toolbox. So now you could also use CLion for C++ and the
> Python IDE free of charge.
>
> If you’re interested, give me a ping and I’ll try to find out what you
> have to do to get that offer.
>
> Chris
>


-- 
Niclas Hedhman, Software Developer
http://polygene.apache.org - New Energy for Java


Exciting news for Apache comimtters

2019-05-31 Thread Christofer Dutz
Hi all,

As we are now supporting more and more languages, the question of IDEs for 
these Languages come up.
I don’t know if you followed the latest announcements, but Jetbrains seem to 
have extended their offer to the ASF.
In the past Apache Committers could request a free IntelliJ license from them. 
This seems to have been extended
To the full toolbox. So now you could also use CLion for C++ and the Python IDE 
free of charge.

If you’re interested, give me a ping and I’ll try to find out what you have to 
do to get that offer.

Chris