/******************************************************************* * * DESCRIPTION: definitions of messages ( Y, *, D,@, X, I ) * * AUTHOR: Amir Barylko & Jorge Beyoglonian * Version 2: Daniel A. Rodriguez * Version 3: Alejandro Troccoli * * EMAIL: mailto://amir@dc.uba.ar * mailto://jbeyoglo@dc.uba.ar * mailto://drodrigu@dc.uba.ar * mailto://atroccol@dc.uba.ar * * DATE: 27/6/1998 * DATE: 25/4/1999 (v2) * DATE: 16/2/2001 (v3) * *******************************************************************/ /** include files **/ #include "message.h" // base header class #include "JackyDebugStream.h" /******************************************************************* *CLASS BASICMSGVALUE ********************************************************************/ BasicMsgValue::BasicMsgValue(){}; BasicMsgValue::BasicMsgValue(const BasicMsgValue& thisValue) {} /******************************************************************* * Function Name: Destructor ********************************************************************/ BasicMsgValue::~BasicMsgValue(){} /******************************************************************* * Function Name: valueSize ********************************************************************/ int BasicMsgValue::valueSize() const { return sizeof(BasicMsgValue); } /******************************************************************* * Function Name: asString ********************************************************************/ string BasicMsgValue::asString() const { return string(""); } /******************************************************************* * Function Name: clone ********************************************************************/ BasicMsgValue* BasicMsgValue::clone() const { return new BasicMsgValue; } /******************************************************************* *CLASS REALMSGVALUE ********************************************************************/ /******************************************************************* * Function Name: Constructor ********************************************************************/ RealMsgValue::RealMsgValue() {}; RealMsgValue::RealMsgValue( const Value& val) : v (val){} /******************************************************************* * Function Name: Copy Constructor ********************************************************************/ RealMsgValue::RealMsgValue( const RealMsgValue& thisValue ) { v = thisValue.v; } /******************************************************************* * Function Name: valueSize ********************************************************************/ int RealMsgValue::valueSize() const { return sizeof(RealMsgValue); } /******************************************************************* * Function Name: asString ********************************************************************/ string RealMsgValue::asString() const { return Value2StrReal(v); } /******************************************************************* * Function Name: clone ********************************************************************/ BasicMsgValue* RealMsgValue::clone() const { return new RealMsgValue(*this); } /******************************************************************* * CLASS: Message ********************************************************************/ /******************************************************************* * Function Name: asString ********************************************************************/ const string Message::asString() const { //Sept, 2005 //Jacky: procId() is the sending procId, if a (X) msg is sending from a remote NC to the local NC, the procId() will //return the procId of the sending NC. But this procId of the remote NC is NOT included in the local ParallelProcessorAdmin! //Thus the following line will result in a runtime error! #ifndef JACKY_REVISION Model& mdl = SingleParallelProcessorAdmin::Instance().model( procId()); return type() + " / " + time().asString() + " / " + mdl.description() + "(" + procId() + ")" ; #else //Jacky's version to construct the log message //Now, if the sending processor is local, it will exist in the ProcessorDB, we can get the model; if the sending processor //is remote, it will be a remote NC since only remote NC can send us (X) msgs! The model for this remote NC also does NOT //exist in the local ModelDB. Thus, we have to synthesize the sending model's description string sendingModelDescription; if ( SingleParallelProcessorAdmin::Instance().findProcId( procId() ) ){ //local sending processor sendingModelDescription = SingleParallelProcessorAdmin::Instance().model(procId()).description() + "(" + procId() + ")" ; } else { //remote sending processor sendingModelDescription = "ParallelNodeCoordinator(" + int2Str(procId()) + ")"; } return type() + " / " + time().asString() + " / " + sendingModelDescription; #endif } /******************************************************************* * Function Name: asStringReceived ********************************************************************/ const string Message::asStringReceived() const { string origin; //Sept, 2005 //Jacky: procId() is the sending procId, if a (X) msg is sending from a remote NC to the local NC, the procId() will //return the procId of the sending NC. But this procId of the remote NC is NOT included in the local //ParallelProcessorAdmin::ProcessorDB! //Thus the following block will result in a runtime error! #ifndef JACKY_REVISION Model& mdl = SingleParallelProcessorAdmin::Instance().model( procId()); if ( mdl.localProc() == proc ) origin = "L"; else origin = "R"; return int2Str ( ParallelMainSimulator::Instance().getMachineID() ) + " / " + origin + " / " + asString(); #else //Jacky's version //Jacky: in order to find out a received msg is from local source or remote source, we only need to search the procId of //the sending processor in the ProcessorDB, if it is found, then it is local; otherwise, it is remote if ( SingleParallelProcessorAdmin::Instance().findProcId( procId() ) ) origin = "L"; else origin = "R"; return int2Str ( ParallelMainSimulator::Instance().getMachineID() ) + " / " + origin + " / " + asString(); #endif } /******************************************************************* * Function Name: asStringSent ********************************************************************/ //Jacky: this function also has problem if it is called in a distributed environment. But I do not change it since //it is not used! const string Message::asStringSent( const ProcId& dest ) const{ string destination; Model& mdl = SingleParallelProcessorAdmin::Instance().model( dest ); if ( mdl.localProc() == dest ) destination = "L"; else destination = "R"; return " << " + int2Str ( ParallelMainSimulator::Instance().getMachineID() ) + " / " + destination + " / " + asString() + " / " + mdl.description() + "(" + dest + ")"; } /******************************************************************* * CLASS: DoneMessage ********************************************************************/ /******************************************************************* * Function Name: asString ********************************************************************/ const string DoneMessage::asString() const { return Message::asString() + " / " + nextChange().asString(); } /******************************************************************* * CLASS: BasicPortMessage ********************************************************************/ /******************************************************************* * Function Name: asString ********************************************************************/ const string BasicPortMessage::asString() const { return Message::asString() + " / " + port().asString() + " / " + value()->asString(); } #ifdef JACKY_REVISION /******************************************************************* * CLASS: BasicExternalMessage ********************************************************************/ /******************************************************************* * Function Name: asString() ********************************************************************/ const string BasicExternalMessage::asString() const { //Jacky: add the sendingModel to the log file if it is a BasicExternalMessage! return BasicPortMessage::asString() + " / " + SingleParallelModelAdm::Instance().model(senderModelId()).description(); } #endif