Re: Batch reads with JPA like annotation magic?

2018-03-05 Thread Niclas Hedhman
Polygene is highly opinionated, for better and worse. Minimally, Polygene
requires to start a runtime, and that everything needed is declared
explicitly upfront at boot time. The minimal start code is something like;


public static void main( String[] args )
throws Exception
{
app = new SingletonAssembler( module -> {
module.transients( Boiler.class, Ahu.class, Fan.class )
  .withMixins( Plc4xBackingPropertyMixin.class );

module.services( Plc4xPollService.class )
  .withMixins( Plc4xModbusDriver.class );
:
:
} );
}


If one wants to implement additional behavior in the Boiler class, then you
create Mixin classes. Let's say we want to capture the temperature once an
hour.

@Mixins(HistoryMixin.class)
interface Boiler
{
@Plc4x( url="s7://..", period=6 )
Property temperature();

List temperatureHistory();
}

public abstract class HistoryMixin
implements Boiler, Scheduled
{
int maxHours = 24;

LinkedBlockingDeque history = new LinkedBlockingDeque<>();

@Override
public void tick()
{
Double value = temperature().get();
history.addLast(value);
while( history.size() > maxHours )
{
history.removeFirst();
}
}

@Override
public List temperatureHistory()
{
return new ArrayList<>( history );
}
}


Above, let's say that "Scheduled" is a service to allow something to get a
tick() upon some period/interval. What I want to draw attention to is that
the HistoryMixin is implementing only the method(s) it need to, and that
the Boiler interface can declare such permanent functionality as an
annotation, instead of as a start-up declaration in the assembly. The fact
that the Mixin is abstract is handled by the runtime and it will compose
all these individual (so called) fragments into a single object (we call it
a Composite) when you instantiate it from the builder.

It is a whole new different way of writing software. Some people love it,
and others have a hard time understanding how it can possibly work. Just
scratching the surface, and please read
https://hedhman.wordpress.com/2017/05/10/introducing-apache-polygene/ for a
larger introduction to the subject.


If you don't want to write the entire project in Polygene "style", you need
to either use the Spring library bridge (possibly need upgrade that one a
bit), where each Service in Polygene will show up as a Spring bean, or
leverage various points of external hooks for Polygene, such
importedServices.


Don't want to bore you too much.


My actual main point was that your suggestion/idea can quickly become quite
a large undertaking and detract from the primary focus that (I think) PLC4X
should have. And bringing up Polygene was more to show that what you
suggest can be done very easily already in Polygene, and all that work
wouldn't be needed.


Cheers
Niclas


On Tue, Mar 6, 2018 at 4:35 AM, Christofer Dutz 
wrote:

> Hi Niclas,
>
> after recovering from that nasty Flu, that is plaguing Germany at the
> moment, I am working on catching up on what I missed.
> I tried to follow, but some things I felt to worn out to work my head
> around.
>
> Could you elaborate a little on Ploygene? How would this allow extending
> our requests with additional magic? Does this work in a simple way: No need
> to configure plugins, code generation or learn some complex API? I would
> like to keep PLC4X as simple as possible, but as extendable as possible.
>
> So I'm always open for new ideas (
>
> Chris
>
>
>
> Am 20.02.18, 03:32 schrieb "hedh...@gmail.com im Auftrag von Niclas
> Hedhman" :
>
> Being the Overlord of Magic that can be done in Java, I have some
> comments
> to make on this idea.
>
> 1. In principle what you suggest can already be done quite easily in
> Apache
> Polygene, by creating a "generic mixin" that overrides the generic
> PropertyMixin. Polygene is probably way more powerful than anything you
> could dream up here. Although Polygene has a strong JSON serialization
> and
> persistence "story", both fully pluggable, it does not use the Glasgow
> spec, a.k.a JavaBeans, a.k.a "getter/setter naming convention", which
> has
> been plaguing the Java community for 2 decades now.
> If I created a Plc4xBackingPropertyMixin, which I think would only
> take a
> few hours, maybe a couple of days, depending on how advance we want
> it, you
> would end up with;
>
>
>
>
> *public interface Boiler{*
>
> *@Plc4x( url="s7://..", period=5000, priority=low )*
>
>
> *Property running();*
>
> *@Plc4x( url="s7://..", direction=out )*
>
>
> *Property onoff();*
>
> *@Plc4x( url="s7://..", period=500, priority=high )*
>
>
>
> *Property alarm();@Plc4x( url="s7://..",
> period=5000,
> priority=normal )*
>
> *Property temperature();*
> *}*
>
> and in the "assembly", we w

Re: Batch reads with JPA like annotation magic?

2018-03-05 Thread Christofer Dutz
Hi Niclas,

after recovering from that nasty Flu, that is plaguing Germany at the moment, I 
am working on catching up on what I missed. 
I tried to follow, but some things I felt to worn out to work my head around. 

Could you elaborate a little on Ploygene? How would this allow extending our 
requests with additional magic? Does this work in a simple way: No need to 
configure plugins, code generation or learn some complex API? I would like to 
keep PLC4X as simple as possible, but as extendable as possible. 

So I'm always open for new ideas (

Chris



Am 20.02.18, 03:32 schrieb "hedh...@gmail.com im Auftrag von Niclas Hedhman" 
:

Being the Overlord of Magic that can be done in Java, I have some comments
to make on this idea.

1. In principle what you suggest can already be done quite easily in Apache
Polygene, by creating a "generic mixin" that overrides the generic
PropertyMixin. Polygene is probably way more powerful than anything you
could dream up here. Although Polygene has a strong JSON serialization and
persistence "story", both fully pluggable, it does not use the Glasgow
spec, a.k.a JavaBeans, a.k.a "getter/setter naming convention", which has
been plaguing the Java community for 2 decades now.
If I created a Plc4xBackingPropertyMixin, which I think would only take a
few hours, maybe a couple of days, depending on how advance we want it, you
would end up with;




*public interface Boiler{*

*@Plc4x( url="s7://..", period=5000, priority=low )*


*Property running();*

*@Plc4x( url="s7://..", direction=out )*


*Property onoff();*

*@Plc4x( url="s7://..", period=500, priority=high )*



*Property alarm();@Plc4x( url="s7://..", period=5000,
priority=normal )*

*Property temperature();*
*}*

and in the "assembly", we would need to override the default PropertyMixin,
by doing;

*module.transients( Boiler.class ).withMixins(
Plc4xBackingPropertyMixin.class );*

That said, Apache Polygene is quite overwhelming for new users, so although
the idea is very persuasive for myself, I am under no illusion that others
are as easily convinced. And it is quite likely that I will create this,
since you brought it up, and the effort is rather small.


2. I have been doing PLC Master apps in Java since 1997 (and other
languages since 1984), and experience tells me that the biggest challenge
for really large applications is how to handle "permanent" vs "temporary"
values. What do I mean? In really large systems, it is not feasible to scan
all variables at all times. The latency will not be acceptable. Instead, we
acknowledge that many values are only of interest when someone is looking
at them, be it a person or a datalogger. Not saying it is unsolvable, but
it adds a fair bit of complexity in a Java world with GC, and relying on
finalize() is not really a solution and the outside "javabeans-friendly"
frameworks are clueless about resource management.

GutFeeling(tm) says that this can and should probably be postponed until we
have more experience and made all compatibility-breaking changes that comes
along the way.



Cheers
Niclas


On Tue, Feb 20, 2018 at 5:32 AM, Christofer Dutz 
wrote:

> Hi Dale,
>
> The direction thing was inspired by the way the Beckhoff ADS protocol was
> designed.
>
> There they sometimes Send Data alongside read requests and sometimes have
> strange "return what's in there and then overwrite with this" type of
> requests.
> The Beckhoff support guy mentioned that they are used quite a lot.
>
> That was the main reasoning for me mentioning the direction thing. In
> general this could be set to a default of being bedirectional.
>
> Chris
>
>
> Am 19.02.18, 18:25 schrieb "Dale LaBossiere" :
>
> Doesn’t the user need access to the response code for each annotated
> item?
>
> I’m unclear on why a Direction is needed/desired.  Is it just for
> “documentation" of what is possible for an item at that address?  Maybe it
> would be checked when the annotated class is used in a Read vs Write
> request to verify the request makes sense for that item?  Or… ?
>
> Could you provide some small pseudo-code of how the app would use the
> API with such an annotated class.
>
> class MyAnnotatedClass { … };
> PlcConnection connection = PlcDriver(…);
>
> // make a read requests
> …?
>
> // access data in the responses
> …?
>
> — Dale
>
>
> > On Feb 19, 2018, at 6:16 AM, Christofer Dutz <
> christofer.d...@c-ware.de> wrote:
> >
> > 

Re: life event

2018-03-05 Thread Christofer Dutz
Hi Dale,

well I guess it will take a while till I can write an equal mail (Wonder which 
age we will be able to retire here in Germany ... probably something around 80 
or so) __

Regarding the batch requests, I did add one method that allows passing in a 
ReadRequest instead of an address and that seems to be working right now. 
Unfortunately that made me realize I need to implement some feature in the S7 
driver to fragment packets as soon as they reach a certain size. Right now I 
can request about 15 different addresses but as soon as I add one more, the 
packet size exceeds the 256 bytes my S7 1200 accepts. But besides this, my 
batch hack seems to be working nicely. 

I really think some API discussion net-meeting would be a great thing. Maybe I 
should restart a discussion on finding a date for something like that.


Chris


Am 28.02.18, 16:47 schrieb "Dale LaBossiere" :

All,

My first day of retirement starts tomorrow!  At this time it’s unclear what 
my level of participation in Edgent and PLC4X will become.  We’ll just have to 
see how it goes.

I’m encouraged by the synergy between Edgent and PLC4X.  Chris is a great 
promoter and contributor so I’m optimistic that interest in both communities 
grows.

In the short term for Edgent I think it would be good to push out another 
release.   Hmm… perhaps a good short term background task for me. And I’m 
interested in enhancing the PLC4X / Edgent integration to support batch PLC 
requests.

In any case, just wanted to share what’s up on my end.

— Dale



[DRAFT] February Podling Report PLC4X

2018-03-05 Thread Christofer Dutz
New month, new report … here a report I whipped up … please comment on this.

Chris

---

Apache PLC4X (incubating)


PLC4X is a set of libraries for communicating with industrial programmable 
logic controllers (PLCs) using a variety of protocols but with a shared API.


Most important issues to address while moving towards graduation:

Building the community: The PPMC and committer group has a large percentage of 
codecentric employees, we have been recruiting people from other companies, but 
will have to continue these efforts for establishing a healthy Apache community.
Onboarding of new committers: With PLC4X several people on the team are not 
very familiar with the Apache Way. We have started and will continue our 
efforts on this onboarding.
Make our first release

Any Issues the Incubator PMC or ASF Board might wish/need to be aware of:

In order to get access to some of the specifications the ASF will eventually 
have to become Members of some external foundations: OPC, EtherCat, Modbus … 
these memberships usually have a free level, that allows us to use the 
specifications but doesn’t result in any regular costs. We will have to discuss 
these details with the ASF and the other foundations.
One of the external foundations (Profinet) doesn’t have a free membership. In 
general, the CEO of the European branch of the Profinet Foundation has signaled 
that it should be possible for the ASF to become a member and have an outside 
company pay the membership fees, but we have to discuss the details (With them 
as well as the ASF).

How has the community developed since the last report?

Christofer has invested most of his time in February spreading the word about 
PLC4X.
A first POC has been created for the company “Kampf Schneid- und Wickeltechnik 
GmbH & Co. KG”
Two articles for IoT Special editions of German tech magazines have been 
submitted. The “JavaSPEKTURM – IoT Sonderheft” is scheduled for sale end or 
March, the “iX – IoT Sonderheft” is scheduled later.
The university of Stuttgart has shown great interest in joining our effort, as 
they had just started a project with a similar goal. Chris will continue 
on-boarding efforts in March.
At this year’s AALE Conference in Cologne, Chris has talked to a lot of people 
from different German universities. We’re hoping to get at least a hand full of 
them on board too.
We have continuing our onboarding of new Apache committers (extended emails 
with a lot of explanations on why we are doing things the way we are)
In the next few months we are expecting to spread the word and hopefully grow 
the community due to the tech magazine articles as well as several talks on 
different conferences.

How has the project developed since the last report?

The work on the RawSocket Netty transport which is a requirement to implement 
protocols that are IP based, but are not TCP or UDP has continued and we are 
currently waiting for infra to setup a dedicated Jenkins VM for our project so 
we can enable the RawSocket releated tests.
We have finished a first version of the Beckhoff ADS driver, and are looking 
forward to first tests with this.
The functionality of the S7 driver has improved due to experience collected 
with the Kampf POC.
Next we are aiming to implement Modbus and OPC-UA protocols.

How does the podling rate their own maturity?

We have a mix of new participants and experienced Apache people involved.
So far, the new participants have shown great willingness and success in 
adopting the Apache Way.
However, we still need to continue:
the on-boarding
increasing the diversity of the team
Also, will we need to decide and establish all the processes involved in 
releasing software at Apache