Pete I didn't want to describe how the automations systems works but
now I see that I have to...

))
ok.
so... the main control system is a PLC controller, actually only PLC
can open or close real valve and generally do not need any other
computers to work... but sometimes its very useful to disturb
automatic program in PLC and do some manual operation... then you can
use simple HMI (Human Machine Interface) touchpanel or use a more
complicated SCADA systems (PC based). Then the PLC works like a
gateway between mechanical equipment like valves, motors, pumps....
and the SCADA or HMI. But still all electrical control is located in
PLC.
SCADA system are mainly use to supervisory of the process, you can see
which equipments works good, which fails and so on...
If you want to do some manual control, you have to send information to
the PLC that you want to change a mode of control for some equipment
ex. valve. Then is possible to open/close the valve manually. SCADA
system uses labels which in deed is a reference to memory in PLC, but
its more user friendly to use TAG name ex. "Valve1.Status" instead a
real memory address like "DB10.WORD20" which tells nothing... Tag is
nothing more then a label assign to memory address.
You have to know that distance between PLC and SCADA computer could by
hundred of meters or in some case event hundred of kilometres
(miles)...the communications rate is different some times only
19,2kbps some times 100Mbps... thats why usually it's better to set a
value then call method...especially that PLC not use methods... You
can only read from - or write to PLC memory...
so...
when I want to send a command to PLC to open a Valve usually set a BIT
(or set a BIT in WORD) than PLC notice this and do action to open the
valve.
Present SCADA system are a container for ActiveX or .NET controls. So
it's very useful to prepare a library with typical template control
like valve, motors, pumps. Than you have only to assign a right
properties of control to Tags and your automation system is near to
ready... and what it's important it doesn't matter what SCADA software
use.
in other way you can prepare own SCADA in programming language like
C#, C++, VB.... but then you have to implement a driver to PLC which
is not easy... or what Jeroen ask me - it's use a OPC communication
standard.
Actually in this moment it's not matter do we use the prepared
controls in SCADA or in OPC client applications. At this moment I want
only to manage with the problem how automatic change valve status in
my faceplate when the real valve change status.
My usercontrol Valve template shoud have a graphic symbol and a text
label - valve symbol. Graphic symbol for this moment is a bitmap -
painted valve where filling colour according to state of real valve.
Gray means the valve is closed, green means opened, red means that
valve is in failure.
When I click on this control the faceplate (a form included in
usercontrol code) should appear to manual control of valve.
So the usercontrol should has at least 3 properties:
- state [for ex. 0 - closed, 1-opened, 2- failure)
- command
- valve label [for ex. VALVE1]
when SCADA read from PLC memory that state of valve changed then
change the property state on my control, the bitmap change to inform
the user that valve change state. If faceplate is opened then it
should also to change state in the valve symbol in faceplate...
I don't want to co synchronize write current state to faceplate
form...it's cost a lot of CPU time... that's why I prefer to use
event...
A usercontrol has to be like "black box" with only some properties
which are use as interface to PLC, and shouldn't need any code outside
the control. The control should provide full functionality itself.
That's why I want faceplate to handle the event of state property
change.
but the problem is how to determine the usercontrol instance name and
how to bind a event to it?
when in InitializeComponent method for my usercontrol form put:
ValveControl.ValveUserControl valve = new ValveUserControl();
valve.StatusChanged += new
ValveUserControl.MyEventHandler(ValveControlForm_StatusChanged);
and then when I change state: valve.uState = 1;
it's work how fine... but this code could should be created automatic
when I put the control on the form...
I cannot create new object I should use reference to object which is
created when I drag control on a container [C# form or SCADA
screen].... but I don't know how to do this...
Maybe my english is too poor to clarify my idea.... sorry
