cnullmessageprot.h

00001 //=========================================================================
00002 //  CNULLMESSAGEPROT.H - part of
00003 //
00004 //                  OMNeT++/OMNEST
00005 //           Discrete System Simulation in C++
00006 //
00007 //   Written by:  Andras Varga, 2003
00008 //
00009 //=========================================================================
00010 
00011 /*--------------------------------------------------------------*
00012   Copyright (C) 2003-2005 Andras Varga
00013   Monash University, Dept. of Electrical and Computer Systems Eng.
00014   Melbourne, Australia
00015 
00016   This file is distributed WITHOUT ANY WARRANTY. See the file
00017   `license' for details on this and other legal matters.
00018 *--------------------------------------------------------------*/
00019 
00020 #ifndef __CNULLMESSAGEPROT_H__
00021 #define __CNULLMESSAGEPROT_H__
00022 
00023 #include "cparsimprotocolbase.h"
00024 #include "cmessage.h"  // MK_PARSIM_BEGIN
00025 
00026 // forward declarations
00027 class cCommBuffer;
00028 class cNMPLookahead;
00029 
00030 
00038 class cNullMessageProtocol : public cParsimProtocolBase
00039 {
00040   protected:
00041     struct PartitionInfo
00042     {
00043         cMessage *eitEvent;  // EIT received from partition
00044         cMessage *eotEvent;  // events which marks that a null message should be sent out
00045         double lastEotSent;  // last EOT value that was sent
00046     };
00047 
00048     // partition information
00049     int numSeg;            // number of partitions
00050     PartitionInfo *segInfo;  // partition info array, size numSeg
00051 
00052     // controls null message resend frequency, 0<=laziness<=1
00053     double laziness;
00054 
00055     // internally used message kinds
00056     enum
00057     {
00058         MK_PARSIM_EIT =       MK_PARSIM_BEGIN - 1,
00059         MK_PARSIM_RESENDEOT = MK_PARSIM_BEGIN - 2
00060     };
00061 
00062     bool debug;
00063 
00064     cNMPLookahead *lookaheadcalc;
00065 
00066   protected:
00067     // process buffers coming from other partitions
00068     virtual void processReceivedBuffer(cCommBuffer *buffer, int tag, int sourceProcId);
00069 
00070     // processes a received EIT: reschedule partition's EIT message
00071     virtual void processReceivedEIT(int sourceProcId, simtime_t eit);
00072 
00073     // resend null message to this partition
00074     virtual void sendNullMessage(int procId, simtime_t now);
00075 
00076     // reschedule event in FES, to the given time
00077     virtual void rescheduleEvent(cMessage *msg, simtime_t t);
00078 
00079   public:
00083     cNullMessageProtocol();
00084 
00088     virtual ~cNullMessageProtocol();
00089 
00094     virtual void setContext(cSimulation *sim, cParsimPartition *seg, cParsimCommunications *co);
00095 
00103     void setLaziness(double d)  {laziness = d;}
00104 
00108     double getLaziness()  {return laziness;}
00109 
00113     virtual void startRun();
00114 
00118     virtual void endRun();
00119 
00123     virtual cMessage *getNextEvent();
00124 
00130     virtual void processOutgoingMessage(cMessage *msg, int procId, int moduleId, int gateId, void *data);
00131 };
00132 
00133 #endif

Generated on Sat Oct 21 17:48:01 2006 for OMNeT++ Parallel Simulation Support by  doxygen 1.4.6