Welcome, Guest
Username: Password: Remember me

TOPIC: Application against proview db

Application against proview db 4 years 2 months ago #10495

  • Snarf77
  • Snarf77's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 847
  • Thank you received: 2
  • Karma: 5
Hi all,
I was attempting to follow the example described in the designer guide manual for building a C application that is attached to proview db and I'm annoyed with the ld_appl starting file syntax.

1) is the # character to activate or to inhibit the start of the application (it is written that is an inhibit for the system processes but is that the same for user application ?
2) what is the difference / purprose of the load/no load vs run/norun ?

At the moment, if I put a # at the line start, proview tells me "Not starting ra_myapp" like if it was disable
If I remove it, I have no line at all during startup log message
in both cases, I can't see any "ra_appl" in the System monitoring window of proview neither any erh_Info message I inserted just to be sure my appl is running so I guess the init method is not started at all ?

Thank you for your help if anyone has already played with this wonderful feature
Snarf
The administrator has disabled public write access.

Application against proview db 4 years 2 months ago #10496

  • claes
  • claes's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 3176
  • Thank you received: 502
  • Karma: 133
Hi Snarf,

Lines starting with # are comments.

The lines for system servers are written with 'norun', so if you remove the comment for one server this server will not be started at system startup.

For applications you should set 'run' if you wan't the application to be started at system startup.

'load/noload' is not used in Linux.

/Claes
The administrator has disabled public write access.

Application against proview db 4 years 2 months ago #10497

  • Snarf77
  • Snarf77's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 847
  • Thank you received: 2
  • Karma: 5
Ok much clear concerning the ld_appl file, thank you

Concerning my application, now I have put the following line in the ld_appl file:
ra_myappl, ra_myappl, load, run, ra_myappl, 12, debug, ""
but at proview Startup, I still have the line:
Not starting ra_myappl, file ra_myappl

What is required in order to make it start ?
I have so much stupid question I don't dare to ask but...

- where is the executable file located ? included in proview plc executable ? At the moment, I have generated a ra_myappl.o object file but I don't understand the mechanism from where this is called ? Do I need to add this .o in BuildOption modules ?

- I have inserted under the node an "Application" object but am not sure if I need to enter the name of the class (ra_myappl) or the instance (myappl) ?

- What is triggering the apparition of the user application in the system status log ? errh_Init function I guess ? this function is called in the "main" section of the c++ file but what is calling the "main" at proview startup ? just the declaration of the Application object ?

Thanks in advance for those beginner questions
Snarf
The administrator has disabled public write access.

Application against proview db 4 years 2 months ago #10499

  • claes
  • claes's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 3176
  • Thank you received: 502
  • Karma: 133
Hi Snarf,

An application is a separate executable and your application should be not only compiled but also linked to $pwr_exe/rt_myappl.

You specify the Application object in the code with a call to aproc_RegisterObject(), but you don't have to specify the application in the object. It's common though to set the object name to the name of the application.

When you have created the executable $pwr_exe/rt_myappl and added the application to the ld_appl file, the application will be started as a separate process by rt_ini at system startup.

/Claes
The administrator has disabled public write access.

Application against proview db 4 years 2 months ago #10500

  • Snarf77
  • Snarf77's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 847
  • Thank you received: 2
  • Karma: 5
Yes I agree, and I used a makefile for this which build and link the source code.
I correctly obtain a .o in $pwrp_obj and an executable file in $pwrp_exe (in development station)
Now I don't know if I need if I have to manually copy this exec file onto the target or if it included in the proview pacakge (.tgz) ? At the moment I can't find it on my target but I don't know where to place it ?

Concerning the registration, I have the following line in my C code:
// Register application object  
sts = gdh_NameToObjid( "Nodes-plc1p-myappl", &aoid);  
if ( EVEN(sts)) throw co_error(sts);

And the following Object in my Target Node:
Nodes-PLC-myappl (object of type :Application)


To summarize name convention, name of Nodes Application object can be different of executable name until the correct Object name is correctly reference in the source code at parameter to the errh_Init function, correct ?


[EDIT] One step further, copying the exec file into $pwrp_exe makes it start finally. Now application is listed in the system log page but has status time out.
In the documentation it is written to use aproc_TimeStamp() to indicate application is running but according programmer manual the function aproc_TimeStamp is expecting 2 parameters (cycletime and maxdelay). I don't know exactly how to set those values. I have set aproc_TimeStamp(1,10) assuming a 1 sec time cycle (there is a Sleep(1) in the scan method) and I put the maxdelay to 10 sec. Unfortunatly I got time out and I don't understand why.


[EDIT 2] In proview log, my application is exited with status 139. Is that a consequence of he time out or can this be a failure in the source code that make the application exits and consequently time out ?

[EDIT 3] OK Application up and running. I discovered that Actualvalue for signal is a pointer int32 instead of int32 so I was referencing the value content badly in my test which probably breaks my application and makes the code exit

Thank your for your guideline


Thanks a lot for your help
snarf
Last Edit: 4 years 2 months ago by Snarf77.
The administrator has disabled public write access.

Application against proview db 4 years 2 months ago #10501

  • claes
  • claes's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 3176
  • Thank you received: 502
  • Karma: 133
Yes, name of application object can be different.

Use an ApplDistribute object in the directory volume to add the executable to the distribution package.

/Claes
The administrator has disabled public write access.
Time to create page: 8.251 seconds