Re: [mico-devel] Problems using Objects of type Any and Qt

2009-01-17 Thread Karel Gardas

Hi Pascal,

first of all, by PI I mean PortableInterceptor, i.e. specification which
also specifies API for CodecFactory and Codec which you seems to use in
the code below, but you didn't use in your original email where you used
MICO specific codec API. So everything is OK from this point of view.

Now, to your issue. As I understand the situation is that you have
perfectly working code and when you add #include QApplication to it
which comes from Qt library, then your code is not working at all. The
first thing which comes to mind is that your added include silently
redefine or undefine something which is needed and defined by the former
includes (CORBA). Hence I recommended to see if reordering of the
includes solves your issue. BTW: What compiler and on which platform do
you use exactly? i.e. version numbers might be interesting here.

Also what's very dangerous is to use any namespace in globaly included
header files. I would recommend you to use absolute scope names in all
your header files, hence fixing anyserial.h to:

#ifndef __ANYSERIAL__
#define __ANYSERIAL__

#include CORBA.h
#include mico/throw.h
#include coss/CosNaming.h

void operator ( CORBA::Any anyobject, const CORBA::OctetSeq dataseq);
void operator ( const CORBA::Any anyobject, CORBA::OctetSeq dataseq);

#endif

And finally third attempt I would do is to carefully examine
preprocessed source of your application to see any issue with silent
symbol undefine or redefine...

Cheers,
Karel
PS: also please sign to mico-devel@mico.org mailing list here:
http://www.mico.org/mailman/listinfo/mico-devel from your address you
are using now, otherwise you still will not be able to sent any email
into the list.

ld1bp...@unibw.de wrote:
 Hi Karel,
 many thanks again for your suggestions. I tried to change the #include
 order in the file but the problem still comes up. To give you the best
 answer regarding the anyserial.h file I just write you down the header and
 the cpp files so that you can see how they are structured.
 
 --- anyserial.h ---
 
 #ifndef __ANYSERIAL__
 #define __ANYSERIAL__
 
 #include CORBA.h
 #include mico/throw.h
 #include coss/CosNaming.h
 
 using namespace CORBA;
 
 void operator ( Any anyobject, const OctetSeq dataseq);
 void operator ( const Any anyobject, OctetSeq dataseq);
 
 #endif
 
 
 --- anyserial.cpp ---
 
 // anyserial implementation
 
 #include anyserial.h
 
 void operator ( Any anyobject, const OctetSeq dataseq)
 {
   // Codec
   ORB_var orb;
   Object_var obj;
   IOP::CodecFactory_var cf;
   IOP::Encoding enc2;
   IOP::Codec_ptr codec_ptr;
 
   // Generate codec based on CodecFactory
   int argc = 1;
   char* argv[1];
   argv[0] = anyserial;
   orb = ORB_init( argc, argv, mico-local-orb );
   obj = orb-resolve_initial_references(CodecFactory);
   cf = IOP::CodecFactory::_narrow(obj);
   enc2.format = IOP::ENCODING_CDR_ENCAPS;
   enc2.major_version = 1;
   enc2.minor_version = 2;
   codec_ptr = cf-create_codec(enc2);
 
   // Decode dataseq and copy new generated object of type any into 
 anyobject
   anyobject = *(codec_ptr-decode(dataseq));
 
 }
 
 void operator ( const Any anyobject, OctetSeq dataseq)
 {
   // Codec
   ORB_var orb;
   Object_var obj;
   IOP::CodecFactory_var cf;
   IOP::Encoding enc2;
   IOP::Codec_ptr codec_ptr;
 
   // Generate codec based on CodecFactory
   int argc = 1;
   char* argv[1];
   argv[0] = anyserial;
   orb = ORB_init( argc, argv, mico-local-orb );
   obj = orb-resolve_initial_references(CodecFactory);
   cf = IOP::CodecFactory::_narrow(obj);
   enc2.format = IOP::ENCODING_CDR_ENCAPS;
   enc2.major_version = 1;
   enc2.minor_version = 2;
   codec_ptr = cf-create_codec(enc2);
 
   // Encode anyobject and generate a new octet sequence
   OctetSeq_var newdataseq_ptr = codec_ptr-encode(anyobject);
   int length = newdataseq_ptr-length();
 
   // Copy generated octet sequence into dataseq
   dataseq.length(length);
 
   for (int i=0; ilength; i++)
   dataseq[i] = (*newdataseq_ptr)[i];
 }
 
 I think I used what is really necessary of MICO/CORBA, am I right? As you
 can see I also specified using namespace MICO;. What is PI?
 
 Pasquale
 
 
 Hi Pascal,

 this is strange, please try to reorder your header files to

 #include anyserial.h
 #include ifDKAircraftInterface.h
 #include QApplication

 or to:

 #include ifDKAircraftInterface.h
 #include anyserial.h
 #include QApplication

 BTW, does your anyserial includes anything from MICO/CORBA? Do you use
 inside it `using namespace CORBA'?

 Also please try to use PI's codec API as your college Andreas does.

 Cheers,
 Karel
 --
 Karel Gardas  kgar...@objectsecurity.com
 ObjectSecurity Ltd.   http://www.objectsecurity.com


 ld1bp...@unibw.de wrote:
 Hallo Karel,
 thank you very much for your support. The anyobject Any variable
 contains
 

Re: [mico-devel] Problems using Objects of type Any and Qt

2009-01-14 Thread Karel Gardas

Hi Pascal,

this is strange, please try to reorder your header files to

#include anyserial.h
#include ifDKAircraftInterface.h
#include QApplication

or to:

#include ifDKAircraftInterface.h
#include anyserial.h
#include QApplication

BTW, does your anyserial includes anything from MICO/CORBA? Do you use
inside it `using namespace CORBA'?

Also please try to use PI's codec API as your college Andreas does.

Cheers,
Karel
-- 
Karel Gardas  kgar...@objectsecurity.com
ObjectSecurity Ltd.   http://www.objectsecurity.com


ld1bp...@unibw.de wrote:
 Hallo Karel,
 thank you very much for your support. The anyobject Any variable contains
 all data coming from a complex structure (struct) defined in two specific
 IDL files: commonBasicTypes.idl and AircraftInterface.idl. Here are the
 files:
 
 --- commonBasicTypes.idl ---
 
 #ifndef __COMMONBASICTYPES_IDL__
 #define __COMMONBASICTYPES_IDL__
 
 struct SGeoPos
 {
   double lat_wgs84;   // degrees
   double lon_wgs84;   // degrees
   double alt_wgs84_m;
 };
 
 typedef sequence SGeoPos LGeoPos;
 
 struct S2dPos // e.g. referring to a pos in an OpenGL display
 {
   double x; // normally -1.0 to +1.0
   double y; // normally -1.0 to +1.0
 };
 
 typedef sequence S2dPos L2dPos;
 
 struct STime
 {
   long  hour;
   long  min;
   long  sec;
   doublems;  // milliseconds
 };
 
 
 /**
   Operation modes of a flight management system
  */
 enum EFMSMode
 {
   FMS_MODE_OFFLINE,   //! FMS is offline (caused by operator 
 or
 end-of-track)
   FMS_MODE_TEMPORARY_OFFLINE, //! The FMS is offline for batch 
 processing
   FMS_MODE_LNAV,  //! horizontal navigation only
   FMS_MODE_VNAV,  //! horizontal and vertical 
 navigation, no speed control
   FMS_MODE_VNAV_SPEED //! HNAV + VNAV + speed control
 };
 
 // Different approach modes for waypoints.
 enum EWPMode
 {
   WAYPOINT_MODE_TRACK,//! The default: Use the waypoint as 
 fly-by
 navigation hint.
   WAYPOINT_MODE_OVERFLY,  //! Fly over the waypoint. No 
 pre-turning is
 allowed.
   WAYPOINT_MODE_HOVER,//! Hover at the waypoint. The FMS is 
 not allowed
 to advance to the next waypoint. This is only supported for rotorcrafts.
   WAYPOINT_MODE_CIRCLE//! Circle around the waypoint. The 
 FMS is not
 allowed to advance to the next waypoint.
 };
 
 enum EWaypointType
 {
   WAYPOINTTYPE_UNKNOWN,
   WAYPOINTTYPE_GROUND,
   WAYPOINTTYPE_AIR,
   WAYPOINTTYPE_TRAJECTORY //more to come
 };
 
 enum EDesiredTurnMode
 {
   TURNMODE_TURNFLYBY,
   TURNMODE_TURNFLYOVER,
   TURNMODE_TURNFLYOVERINTERCEPT
 };
 
 struct STurnModeConstraint
 {
   boolean constraintDefined;
   EDesiredTurnMode eTurnMode;
 };
 
 struct SPositionConstraint
 {
   boolean constraintDefined;
   double allowedLateralDeviation_m;
 };
 
 enum EAltitudeType
 {
   ALTTYPE_WGS84,
   ALTTYPE_AGL,
   ALTTYPE_MSL,
   ALTTYPE_FL
 };
 
 struct SAltitudeConstraint
 {
   boolean constraintDefined;
   boolean preferdAltSet;
   double preferedAlt_m;
   EAltitudeType ePreferdAltType;
   boolean maxAltSet;
   double maxAlt_m;
   EAltitudeType eMaxAltType;
   boolean minAltSet;
   double minAlt_m;
   EAltitudeType eMinAltType;
 };
 
 struct STimeConstraint
 {
   boolean constraintDefined;
   STime   sTargetTime;
   longtimeEarly_s;
   longtimeLate_s;
 };
 
 struct SWaypoint
 {
   boolean initialized; // A waypoint is valid if this flag is true.
   long id; // Unique ID for identification
   string  name; // The name of this waypoint.
   SGeoPos sPos; // The WGS84 coordinates of the waypoint
   boolean hasHeading; // If set to true, the waypoint has an ingress
 heading. e.g. for VOR navigation or corridor entrance.
   double  heading_rad; // If hasHeading is true, then this is the ingress
 heading for the waypoint.
   double  ingress_speed_m_s; // Ingress speed in meter per second for this
 waypoint.
   double  circle_radius_m;// Circle radius in meter (only valid, 
 if mode =
 WAYPOINT_MODE_CIRCLE)
   boolean circle_clockwise;   // true for clockwise, false for
 counter-clockwise (only valid, if mode = WAYPOINT_MODE_CIRCLE)
   EWPMode mode;
   EWaypointType eWaypointType;
   STurnModeConstraint sTurnModeConstraint; // TODO: shift constraints to
 routenplaner_cmd_qe
   SPositionConstraint sPositionConstraint;
   SAltitudeConstraint sAltitudeConstraint;
   STimeConstraint sTimeConstraint;
 };
 
 typedef sequenceSWaypoint LWaypoint;
 
 typedef sequencelong LWpId;
 
 struct SRoute
 {
   boolean initialized; // A Route is valid if this flag is true.
   long id; // Unique ID for identification
   string name;
   //long nextRoutepointId; 

Re: [mico-devel] Problems using Objects of type Any and Qt

2009-01-12 Thread Karel Gardas

Hello,

what exactly does your anyobject Any variable contain? The strange thing
is that you are only able to duplicate the issue when you use Qt...

Cheers,
Karel

Andreas Benzler wrote:
 Hallo,
 I´m using a client-server model based on Mico and I defined an idl
 interface like this:
 
 interface ifRec
 {
   long Register( in string name, in string ns );
   void WriteData( in long id, in any data );
   void SetEnv( in string Key, in string Value );
   void Rec();
   void Break();
   void Resume();
   void Replay( in double speed );
   void Stop();
   long Load( in string filename );
 };
 
 The WriteData function uses the parameter data of type Any, which
 represents a structure (struct) containing other structures inside, and I
 get a run-time error whenever a client calls this function. The client has
 been compiled with Qt and uses the QApplication function. I discovered
 that the run-time error it´s based on the problem that the object of type
 Any is codified in the wrong way from Mico during the serialization
 process only when the QApplication function is used in the client code and
 also when the tree´s depth of the structures codified in the Any object is
 too big, otherwise no run-time error comes up and the octet sequence that
 represents the object, made by the Mico serialization process, has the
 correct length. I also discovered that the difference between the octet
 sequence with and without using QApplication is fixed and always 268 bytes
 (more bytes without QApplication) and it does not depend on the complexity
 of the structure that the Any object represents. I discovered this last
 detail simulating a serialization process of the Any object using the
 available Mico internal codec. I tried to compile the system with the two
 Mico versions 2.3.11 and 2.3.13, both versions compiled specifying also the
 --with-qt=qt-path directive for the configure script, but I have same
 problems.
 
 Here is also the Mico codec I used to simulate the serialization process:
 
 void operator ( const Any anyobject, OctetSeq dataseq)
 {
   // Codec
   ORB_var orb;
   Object_var obj;
   IOP::CodecFactory_var cf;
   IOP::Encoding enc2;
   IOP::Codec_ptr codec_ptr;
 
   // Generate codec based on CodecFactory
   int argc = 1;
   char* argv[1];
   argv[0] = anyserial;
   orb = ORB_init( argc, argv, mico-local-orb );
   obj = orb-resolve_initial_references(CodecFactory);
   cf = IOP::CodecFactory::_narrow(obj);
   enc2.format = IOP::ENCODING_CDR_ENCAPS;
   enc2.major_version = 1;
   enc2.minor_version = 2;
   codec_ptr = cf-create_codec(enc2);
 
   // Encode anyobject and generate a new octet sequence
   OctetSeq_var newdataseq_ptr = codec_ptr-encode(anyobject);
   int length = newdataseq_ptr-length();
 
   // Copy generated octet sequence into dataseq
   dataseq.length(length);
 
   for (int i=0; ilength; i++)
   dataseq[i] = (*newdataseq_ptr)[i];
 }
 
 Any and OctetSeq types are exactly CORBA::Any and CORBA::OctetSeq types
 defined in MICO.
 
 Could please anyone help to understand why Mico has this strange behavior
 and eventually to find a solution?
 
 Many Thanks in advance,
 Pasquale Zarcone
 
 Because the mail did not come trough with my colleges account I post
 this message on his behalf
 
 Andreas
 ___
 Mico-devel mailing list
 Mico-devel@mico.org
 http://www.mico.org/mailman/listinfo/mico-devel
 


-- 
Karel Gardas  kgar...@objectsecurity.com
ObjectSecurity Ltd.   http://www.objectsecurity.com
___
Mico-devel mailing list
Mico-devel@mico.org
http://www.mico.org/mailman/listinfo/mico-devel


[mico-devel] Problems using Objects of type Any and Qt

2008-12-03 Thread Andreas Benzler
Hallo,
I´m using a client-server model based on Mico and I defined an idl
interface like this:

interface ifRec
{
long Register( in string name, in string ns );
void WriteData( in long id, in any data );
void SetEnv( in string Key, in string Value );
void Rec();
void Break();
void Resume();
void Replay( in double speed );
void Stop();
long Load( in string filename );
};

The WriteData function uses the parameter data of type Any, which
represents a structure (struct) containing other structures inside, and I
get a run-time error whenever a client calls this function. The client has
been compiled with Qt and uses the QApplication function. I discovered
that the run-time error it´s based on the problem that the object of type
Any is codified in the wrong way from Mico during the serialization
process only when the QApplication function is used in the client code and
also when the tree´s depth of the structures codified in the Any object is
too big, otherwise no run-time error comes up and the octet sequence that
represents the object, made by the Mico serialization process, has the
correct length. I also discovered that the difference between the octet
sequence with and without using QApplication is fixed and always 268 bytes
(more bytes without QApplication) and it does not depend on the complexity
of the structure that the Any object represents. I discovered this last
detail simulating a serialization process of the Any object using the
available Mico internal codec. I tried to compile the system with the two
Mico versions 2.3.11 and 2.3.13, both versions compiled specifying also the
--with-qt=qt-path directive for the configure script, but I have same
problems.

Here is also the Mico codec I used to simulate the serialization process:

void operator ( const Any anyobject, OctetSeq dataseq)
{
// Codec
ORB_var orb;
Object_var obj;
IOP::CodecFactory_var cf;
IOP::Encoding enc2;
IOP::Codec_ptr codec_ptr;

// Generate codec based on CodecFactory
int argc = 1;
char* argv[1];
argv[0] = anyserial;
orb = ORB_init( argc, argv, mico-local-orb );
obj = orb-resolve_initial_references(CodecFactory);
cf = IOP::CodecFactory::_narrow(obj);
enc2.format = IOP::ENCODING_CDR_ENCAPS;
enc2.major_version = 1;
enc2.minor_version = 2;
codec_ptr = cf-create_codec(enc2);

// Encode anyobject and generate a new octet sequence
OctetSeq_var newdataseq_ptr = codec_ptr-encode(anyobject);
int length = newdataseq_ptr-length();

// Copy generated octet sequence into dataseq
dataseq.length(length);

for (int i=0; ilength; i++)
dataseq[i] = (*newdataseq_ptr)[i];
}

Any and OctetSeq types are exactly CORBA::Any and CORBA::OctetSeq types
defined in MICO.

Could please anyone help to understand why Mico has this strange behavior
and eventually to find a solution?

Many Thanks in advance,
Pasquale Zarcone

Because the mail did not come trough with my colleges account I post
this message on his behalf

Andreas
___
Mico-devel mailing list
Mico-devel@mico.org
http://www.mico.org/mailman/listinfo/mico-devel