 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Jonni Lazzerini Guest
|
Posted: Tue Oct 07, 2003 1:01 pm Post subject: Which design pattern(s) should I use for this? |
|
|
Hi,
for my next project I have to build a framework to communicate with several
Programmable Logic Controllers and use it to build a Process Visualization
Software. Basically this framework should give me the possibility to
establish a connection to a PLC, subscribe the variables I need, specifying
update rate, scaling and so on, and have a set of objects that reflects the
data on the plc and inform me when something changes. This should happen in
the reverse direction too, allowing me to set properties on my "local" data
layer managing itself the update on the plc. I think on some stage I'll
need to implement the observer pattern to reflects some changes on the GUI,
but my first two problems are the PLC Communication Layer and my "shadow"
Data Layer
1) The PLC Communication Layer.
There are some different methods I can play with to speak with a PLC. Each
PLC brand has his proprietary way to do that. Mosts implements the OPC
standard, but sometimes the way they do that, penalizes heavy the
performance. Sometimes I should go "native" without such overhead. There are
common operations that best fit on a base abstract class or set of classes
but others that are simply dedicated to only one system. I would use some
pattern something like the one used on a TXMLDocument for his operations (I
can select the DOMVendor to one available on the system and go with it) or
the one used on the ADO components allowing me to change DB drivers without
influencing the upper layers. In my case I should be able to go OPC,
XNative, YNative and so on with the possibility to use some XNative Methods
that OPC does not have! What is / are the right patterns? Facade? Strategy?
Where can I find some examples on somewhat similar applications?
2) The "shadow" Data Layer.
That's probably the more delicated part! I know that data on PLCs may be of
a basic type such an integer, a float, a string and so on but complexes type
too such as as records or arrays (in Delphi jargon) or a file. Sometimes I
can only subscribe a single entity throught the communication layer such as
an 32bit integer sometimes I can subscribe a whole structure such as a 100
bytes big block (may be consisting in an array of 10 records each of them
having five 16 bit integer field). With such complexes structures i need a
shadow object that mimic the real structure on the PLC. Here I'm thinking on
a composite pattern in which each element may be subscribed on the
Communication Layer. Such composition may allow me to add new types and
implement them in the future.I don't know if this is the right way to
implement it. I would be pleased to receive some suggestions here.
Thank you very much.
Jonni Lazzerini.
|
|
| Back to top |
|
 |
Eric Hill Guest
|
Posted: Wed Oct 08, 2003 6:06 pm Post subject: Re: Which design pattern(s) should I use for this? |
|
|
| Quote: | for my next project I have to build a framework to communicate with
several
Programmable Logic Controllers and use it to build a Process
Visualization
Software. Basically this framework should give me the possibility to
establish a connection to a PLC, subscribe the variables I need,
specifying
update rate, scaling and so on, and have a set of objects that reflects
the
data on the plc and inform me when something changes. This should happen
in
the reverse direction too, allowing me to set properties on my "local"
data
layer managing itself the update on the plc. I think on some stage I'll
need to implement the observer pattern to reflects some changes on the
GUI,
but my first two problems are the PLC Communication Layer and my "shadow"
Data Layer
|
Is there any reason you're not using any off-the-shelf automation package?
| Quote: | 1) The PLC Communication Layer.
There are some different methods I can play with to speak with a PLC.
Each
PLC brand has his proprietary way to do that. Mosts implements the OPC
standard, but sometimes the way they do that, penalizes heavy the
performance. Sometimes I should go "native" without such overhead. There
are
common operations that best fit on a base abstract class or set of
classes
but others that are simply dedicated to only one system. I would use some
pattern something like the one used on a TXMLDocument for his operations
(I
can select the DOMVendor to one available on the system and go with it)
or
the one used on the ADO components allowing me to change DB drivers
without
influencing the upper layers. In my case I should be able to go OPC,
XNative, YNative and so on with the possibility to use some XNative
Methods
that OPC does not have! What is / are the right patterns? Facade?
Strategy?
Where can I find some examples on somewhat similar applications?
|
Start looking at MODBUS as many many PLC vendors support this in one way or
another. What you're really looking for are the core features of the
MODBUS protocol built into an abstract communications class. Think
Factory. Each PLC that your application needs to communicate registers a
certain communications method type of "TAbstractCommProtocol". You can
provide concrete implementations of this for MODBUS, OPC, etc. and your
framework can load the proper class at runtime to poll the device. The
abstract class should define base methods like "ReadInteger" and
"WriteInteger". If you need specialized support for certain devices, you
can bolt an interface onto the concrete implementation, and call "if
Supports(...) then" in code.
| Quote: | 2) The "shadow" Data Layer.
That's probably the more delicated part! I know that data on PLCs may be
of
a basic type such an integer, a float, a string and so on but complexes
type
too such as as records or arrays (in Delphi jargon) or a file. Sometimes
I
can only subscribe a single entity throught the communication layer such
as
an 32bit integer sometimes I can subscribe a whole structure such as a
100
bytes big block (may be consisting in an array of 10 records each of them
having five 16 bit integer field). With such complexes structures i need
a
shadow object that mimic the real structure on the PLC. Here I'm thinking
on
a composite pattern in which each element may be subscribed on the
Communication Layer. Such composition may allow me to add new types and
implement them in the future.I don't know if this is the right way to
implement it. I would be pleased to receive some suggestions here.
|
I would let the polling layer collect the data and store it in proper
Delphi record form. You could probably build classes that store the data
internally the way you get it from the PLC, but it's going to get
translated at some time for use so it would probably be easier to just
translate it into the record when you receive the data stream from the PLC.
Eric
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|