Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic Rhapsody (steve huntington)
Decrease font size
Increase font size
Topic Title: Initializing static element
Topic Summary:
Created On: 9-Jan-2006 14:50
Status: Read Only
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 9-Jan-2006 14:50
User is offline View Users Profile Print this message


Andreas Anderegg

Posts: 3
Joined: 21-Apr-2005

I have a static attibute in a class. The data type of this attribute is also a class (VxSemaphore). The constructor of this class needs 2 function parameters.

The generated code looks like this:
// Static class member attribute
VxSemaphore CQuadratureDecoder::mSemaphore = SEM_Q_FIFO, 0;

Which Rhaposody property needs to be changed to generate the correct code like this:
// Static class member attribute
VxSemaphore CQuadratureDecoder::mSemaphore(SEM_Q_FIFO, 0);

Regards
Report this to a Moderator Report this to a Moderator
 11-Jan-2006 09:55
User is offline View Users Profile Print this message


Simon Morrish

Posts: 127
Joined: 17-May-2005

Hi!

If the attribute was non-static, you could control the initialisation using the property CPP_CG::Attribute::InitializationStyle. This doesn't have any effect on static attribute initialisation, which appears rather like a defect to me!

Would anyone from I-Logix care to comment on this?

In the meantime, you could consider accessing your static semaphore using a static accessor function as follows:
[CODE]VxSemaphore* CQuadratureDecoder::getItsVxSemaphore(void) {
//#[ operation getItsVxSemaphore()
static VxSemaphore itsVxSemaphore(SEM_Q_FIFO, 0);

return &itsVxSemaphore;
//#]
}[/CODE]

Better, in my view, would be to keep your model OS-independent by accessing your semaphore via an OMOSSemaphore base class pointer:

[CODE]OMOSSemaphore* CQuadratureDecoder::getItsSemaphore(void) {
//#[ operation getItsSemaphore()
static OMOSSemaphore *itsSemaphore=NULL;

if (itsSemaphore == NULL) {
itsSemaphore = OMOSFactory::instance()->createOMOSSemaphore(SEM_Q_FIFO, 0);
}

return itsSemaphore;
//#]
}[/CODE]

This function will return an Win32 semaphore object if you're running on the host, or a VxWorks semaphore object if you're running on a VxWorks target.

The only proviso is that you need to take care over the meaning and availability of SEM_Q_FIFO on different operating systems. Even if this leads to custom initialisation code for your semaphore, at least the use of it will be OS-independent.

best regards,
Simon

-------------------------
Simon Morrish
simon.morrish@eu.panasonic.com
http://panasonic.co.uk
Panasonic ideas for life
Report this to a Moderator Report this to a Moderator
 12-Jan-2006 17:50
User is offline View Users Profile Print this message


Andreas Anderegg

Posts: 3
Joined: 21-Apr-2005

Hello Simon
Many thanks for your great help. It works.

Best regards,
Andreas Anderegg
Hamilton Medical, Switzerland
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic Rhapsody forum.
There are currently 1 users logged in.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.