Promotic
WikipediaLinkedInYoutubeTwitterFacebook

Example of communication with Amit PLC devices

Example is placed in the folder: /Pm/Examples/Commun/Amit. This is an example of using the PmActiveX PROMOTIC object and its link-up to the ATOUCHX ActiveX object that was created by the AMiT company. The detailed manual is located in the atouchx.chm file supplied by the AMiT company. For simply understanding of the PROMOTIC example, the knowledge of the DB-net system (see the AMiT documentation) is necessary. For correct behaviour of this example, it is necessary to install the ATOUCHX library.

In the ExamPLCAMiT folder there are source codes of the application for PLC device. Then the configured PLC with these source codes can communicate with this PROMOTIC example.

 
The exampe has one panel opened from PmWorkspace after application launch - it is defined on the Frames page in the "main" frame edited in the Viewer of component configurator. There are buttons in the panel that launch the PmFolder methods via the onButtonUp event. All reports are stored by Debug method in the INFO system Debug_info item.
 
Description of installation of the ATOUCHX library:

It is possible to download the library from www.amit.cz.

In this example the AtouchApp object is used for the communication connection that is most suitable for using with the PROMOTIC system because it enables the creation of events. In general, this object is used so that "somewhere in the application" the methods are called that trigger the request for the communication, but the response is created as an event in the AtouchApp object. The followin example shows the usage of several methods.

The AtouchArch object is used for reading the archive created in DB-net. Similar description of working with archives is mentioned in the AtouchX manual. In the example, the object is configured as automatic.

The example doesn't use any panel (for simplicity). Controlling is made by the toolbar (on the left for the AtouchApp object, on the right for the AtouchArch object) and all logs are stored in the Debug_info item in the INFO system.

 
Caution:
- The property VariantOnly of the AtouchApp object has to be set to true in every PROMOTIC application !!
- In the example the number of the AMiT station is set to station=7 and WID=7003.
 
The structure of the example:
1. In the PmFolder type object, on the "Methods" page, there are the following methods defined:
Control_Run: Enables running of the automatic archive.
Control_Stop: Disables running of the automatic archive.
DbGetInfo: Finds out the information about db. variable
GetHWInfo: Finds out the information about the HW connection of the station
NetGetData: Reads the whole db. variable
NetGetTime: Read the time of the station
NetPutData: Writes the whole db. variable
NetIdentify: Reads the identification of the station
StartInit: Called from the onAppStartEnd event
Stop: Called from the onAppStopBegin event
 
2. In the Main panel (of the PmPanel type): there are the buttons (of the PmiButton type) that can be used for calling the specific methods using the onButtonUp event.
 
3. "App": The objekt of the PmActiveX type.
- The AtouchX.AtouchApp object is selected on the "ActiveX" page.
- On the "AxEvents" page there are events for which the appropriate scripts for processing the return data are defined. In this example only logs into the Debug_info item in the INFO system are made.

Note: the success of the communication is indicated in the Result variable. This variable is in fact a 32-bit number, in which a big amount of information is coded (see help of the AtouchX library). To simplify this, there is a general rule - if Result < 1024 (decimal), the communication is in order.

 
4. "Arch": The object of the PmActiveX type.
- The AtouchX.AtouchApp object is selected on the "ActiveX" page.
- On the "AxEvents" page there are events for which the appropriate scripts for processing the data are defined. In this example logs are made into the Debug_info item in the INFO system. For the SAMPLE event possible processing of the data is described. After processing, the Arch.Accept method has to be called.
 
In the PmRoot object there are defined the following events on the "Events" page:
- The onAppStartEnd event: the StartInit method is called, that executes the initialization of the AtouchX objects. In the example, the paths (specific location depends on the designer) to two initialization files (whose meaning is described in details in the Atouchx.chm file) are described:
sHWfile.ini: defines the HW type of the communication for App
sDBfile.ini: defines the database of variables for App
sArchiv.ini: defines the structure and parameters of the archive for Arch

Note: syntactic templates of the files (for this particular example) are placed in the \AMIT\INI folder

Used methods: InitFromFile: Initialization of the object from a file.

- The onAppStopBegin event: the Stop method is called, that executes the deinitialization of the AtouchX objects.

Used methods: Done: Termination of the object activity.

© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice