Help !!! Transform Message class to cPacket class.

閲覧: 27 回
最初の未読メッセージにスキップ

tung_dhqn

未読、
2014/07/23 9:13:172014/07/23
To: omn...@googlegroups.com
Hello !!!
I transform msg format to cpacket format by "check_and_cast<cPacket>(msg)->hasBitError"  but i don't, Omnet++4.1 inform error. So, Anybody know do it ? Please me. 

Ivo Calado

未読、
2014/07/23 9:15:432014/07/23
To: omn...@googlegroups.com

On Wed, Jul 23, 2014 at 10:13 AM, tung_dhqn <tung...@gmail.com> wrote:
check_and_cast<cPacket>(msg)->hasBitError

Try this => check_and_cast<cPacket*>(msg)->hasBitError()


--
Ivo Calado

Quidquid latine dictum sit, altum viditur

Putt's Law:
       Technology is dominated by two types of people:
               Those who understand what they do not manage.
               Those who manage what they do not understand.

tung_dhqn

未読、
2014/07/23 9:44:012014/07/23
To: omn...@googlegroups.com、ivo.c...@ee.ufcg.edu.br
Sorry. I didn't correctly write format , lack * sign. Do you have different way ?

Vào 20:15:43 UTC+7 Thứ tư, ngày 23 tháng bảy năm 2014, Ivo Calado đã viết:

Alfonso Ariza Quintana

未読、
2014/07/23 10:15:442014/07/23
To: omn...@googlegroups.com

You should read in the manual the difference between cPacket and cMessage

--
You received this message because you are subscribed to the Google Groups "omnetpp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omnetpp+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

メッセージは削除されました

tung_dhqn

未読、
2014/07/23 10:58:182014/07/23
To: omn...@googlegroups.com、aari...@hotmail.com
Hi Alfonso Ariza Quintana !
Do you have idea ? I have modified Physic.cc successfully !. Hello Message sent ! But. Nodes don't exam this msg (it does not "hasBitError" function) so I need transform msg format to packet format. do you think ???

Vào 21:15:44 UTC+7 Thứ tư, ngày 23 tháng bảy năm 2014, Alfonso Ariza Quintana đã viết:

Alfonso Ariza Quintana

未読、
2014/07/23 12:44:112014/07/23
To: omn...@googlegroups.com

It is a problem how the message has created, if the message was created like cPacket you can convert, but if the message was originally created like cMessage, you will never convert to cPacket and if you force the conversion with static_cast, the code will access to incorrect areas because cMessage doesn’t have error data.

 

It is a basic c++ inherence rule.

Check_and_cast does a dynamic_cast, like the result of the conversion is null it throws an error

 

An alternative is

 

cPacket pkt = dynamic_cast<cPacket*>(msg);

if (pk)

{

// it is a packet

       If (pk->hasBitError())

              …..

}

else

{

// it isn’t a packet, is it a timer?

    ….

全員に返信
投稿者に返信
転送
新着メール 0 件