|
|
Line 1: |
Line 1: |
− | <p>Proview Designer's Guide Chapter 13<br /><br />'''Open Proview'''<br />* Ctrl+E<br />* MB1 $Hier<br />* MB2 right panel<br />* right key on Oxx $Hier<br />* ObjectName application<br />* MB1 ProjectReg<br />* MB2 in application $Hier<br />* right key on Oxx $ProjectReg<br />* ObjectName cpp<br />* Ctrl+E<br />* Yes<br />* Yes<br />* MB3 cpp Open Project...<br />* Next<br />* Next<br />* No<br />* Next<br />* Next<br />* Next<br />* Next<br />* Yes<br />'''Configure RootVolume'''<br />* Next<br />* Next<br />* Next<br /><br />* MB1 Plant -> $PlantHier<br />* MB2 right panel<br />* right key on Oxx $PlantHier<br />* ObjectName plant<br />* MB1 AllClases -> pwrb -> XyCurve<br />* MB2 in plant $PlantHier<br />* right key on Oxx XyCurve<br />* ObjectName curve<br />* Ctrl+E<br />* Yes<br /><br />'''''/usr/local/pwrp/cpp/src/appl/ra_myappl.cpp'''''<br /> <nowiki><br />#include <math.h><br />#include "pwr.h"<br />#include "pwr_baseclasses.hpp"<br />#include "rt_gdh.h"<br /><br /><br />class ra_myappl {<br /> pwr_Class_XyCurve *curve_ptr;<br /> pwr_tRefId dlid;<br />public:<br /> ra_myappl() {}<br /> void init();<br /> void scan();<br /> void close();<br />};<br /><br />void ra_myappl::init()<br />{<br /> pwr_tStatus sts;<br /> pwr_tOName name = "plant-curve";<br /> <br /> // Connect to database<br /> sts = gdh_Init( "ra_myappl");<br /> if ( EVEN(sts)) exit(0);<br /><br /> // Direct link to curve object<br /> sts = gdh_RefObjectInfo( name, (void **)&curve_ptr, &dlid, sizeof(*curve_ptr));<br /> if ( EVEN(sts)) exit(0);<br />}<br /><br />void ra_myappl::scan()<br />{<br /> for ( unsigned int i = 0;;i++) {<br /> if ( i % 5 == 0) {<br /> // Calculate x and y coordinates for a sine curve every fifth second<br /> for ( int j = 0; j < 100; j++) {<br /> curve_ptr->XValue[j] = j;<br /> curve_ptr->YValue[j] = 50 + 50 * sin( 2.0 * M_PI * (j + i) / 100);<br /> }<br /> // Indicate new curve to graph<br /> curve_ptr->Update = 1;<br /> }<br /> else if ( i % 5 == 2)<br /> curve_ptr->Update = 0;<br /> sleep(1);<br /> if ( i > 360)<br /> i = 0;<br /> }<br />}<br /><br />void ra_myappl::close()<br />{<br /> gdh_UnrefObjectInfo( dlid);<br />}<br /><br /><br />int main()<br />{<br /> ra_myappl myappl;<br /> <br /> myappl.init();<br /> myappl.scan(); <br /> myappl.close();<br />}<br /><br /></nowiki><br /><br /><br />'''On terminal'''<br /><br /> $ sdf cpp<br /> $ cd /usr/local/pwrp/cpp/src/appl/<br /> $ g++ -g -c ra_myappl.cpp -o $pwrp_obj/ra_myappl.o -I$pwr_inc -DOS_LINUX=1 -DOS=linux -DHW_X86=1 -DHW=x86<br /> $ g++ -g -o $pwrp_exe/ra_myappl $pwrp_obj/ra_myappl.o $pwr_obj/pwr_msg_rt.o -L$pwr_lib -lpwr_rt -lpwr_co -lpwr_msg_dummy -lrt<br /><br /><br />'''On proview'''<br />* Shift+Ctrl+B Node + B<br />* Tools -> Runtime Monitor<br />* Start Runtime<br />* File -> Start Runtime Navigator<br />* right key Database<br />* right key plant<br />* MB3 curve Object Graph<br /><br /><br />'''On terminal'''<br /> $ ra_myappl</p>
| + | |