POGO c++ code

1 Tango::DevFloat DocDs::dev_simple(Tango::DevFloat argin)

2 {

3 Tango::DevFloat argout ;

4 DEBUG_STREAM << "DocDs::dev_simple(): entering... !" << endl;

5

6 // Add your own code to control device here

7

8 argout = argin * 2;

9 return argout;

10 }

1 Tango::DevVarLongArray *DocDs::dev_array(const Tango::DevVarLongArray *argin)

2 {

3 // POGO has generated a method core with argout allocation.

4 // If you would like to use a static reference without copying,

5 // See "TANGO Device Server Programmer’s Manual"

6 // (chapter x.x)

7 //------------------------------------------------------------

8 Tango::DevVarLongArray *argout = new Tango::DevVarLongArray();

9

10 DEBUG_STREAM << "DocDs::dev_array(): entering... !" << endl;

11

12 // Add your own code to control device here

13

14 long argin_length = argin->length();

15 argout->length(argin_length);

16 for (int i = 0;i < argin_length;i++)

17 (*argout)[i] = (*argin)[i] * 2;

18

19 return argout;

20 }

1 Tango::DevString DocDs::dev_string(Tango::DevString argin)

2 {

3 // POGO has generated a method core with argout allocation.

4 // If you would like to use a static reference without copying,

5 // See "TANGO Device Server Programmer’s Manual"

6 // (chapter x.x)

7 //------------------------------------------------------------

8 Tango::DevString argout;

9 DEBUG_STREAM << "DocDs::dev_string(): entering... !" << endl;

10

11 // Add your own code to control device here

12

13 cout << "the received string is " << argin << endl;

14

15 string str("Am I a good Tango dancer ?");

16 argout = new char[str.size() + 1];

17 strcpy(argout,str.c_str());

18

19 return argout;

20 }

1 Tango::DevVarStringArray *DocDs::dev_str_array()

2 {

3 // POGO has generated a method core with argout allocation.

4 // If you would like to use a static reference without copying,

5 // See "TANGO Device Server Programmer’s Manual"

6 // (chapter x.x)

7 //------------------------------------------------------------

8 Tango::DevVarStringArray *argout = new Tango::DevVarStringArray();

9

10 DEBUG_STREAM << "DocDs::dev_str_array(): entering... !" << endl;

11

12 // Add your own code to control device here

13

14 argout->length(3);

15 (*argout)[0] = CORBA::string_dup("Rumba");

16 (*argout)[1] = CORBA::string_dup("Waltz");

17 string str("Jerck");

18 (*argout)[2] = CORBA::string_dup(str.c_str());

19 return argout;

20 }

1 Tango::DevVarDoubleStringArray *DocDs::dev_struct()

2 {

3 // POGO has generated a method core with argout allocation.

4 // If you would like to use a static reference without copying,

5 // See "TANGO Device Server Programmer’s Manual"

6 // (chapter x.x)

7 //------------------------------------------------------------

8 Tango::DevVarDoubleStringArray *argout = new Tango::DevVarDoubleStringArray();

9

10 DEBUG_STREAM << "DocDs::dev_struct(): entering... !" << endl;

11

12 // Add your own code to control device here

13

14 argout->dvalue.length(3);

15 argout->dvalue[0] = 0.0;

16 argout->dvalue[1] = 11.11;

17 argout->dvalue[2] = 22.22;

18

19 argout->svalue.length(2);

20 argout->svalue[0] = CORBA::string_dup("Be Bop");

21 string str("Smurf");

22 argout->svalue[1] = CORBA::string_dup(str.c_str());

23

24 return argout;

25 }

 protected :

4 // Add your own data members here

5 //-----------------------------------------

6 Tango::DevString attr_str_array[5];

7 Tango::DevLong attr_rd;

8 Tango::DevLong attr_wr;

原文地址:https://www.cnblogs.com/greencolor/p/2842501.html