Revision 2f5cc443

View differences:

include/cenvir.h
177 177
     */
178 178
    virtual void simulationEvent(cMessage *msg) = 0;
179 179

  
180
    virtual void simulationEventEnd(double complexity) = 0;
181

  
180 182
    /**
181 183
     * Notifies the environment that a message was sent. Details can be
182 184
     * extracted from the message object itself. The user interface
include/csimulation.h
53 53
class  cDefaultList;
54 54
class  cThreadPool;
55 55
class  cAsyncModule;
56
class  cStopWatch;
56 57

  
57 58
SIM_API extern cDefaultList defaultList; // also in globals.h
58 59

  
......
122 123

  
123 124
    unsigned int eventsPerSimTimeInstance; // count how many event occur at the same sim time
124 125

  
126
    cStopWatch sequentialWatch;
127

  
125 128
  private:
126 129
    // internal
127 130
    void checkActive()  {if (getActiveSimulation()!=this) throw cRuntimeError(this, eWRONGSIM);}
src/cmdenv/cmdenv.cc
664 664
    }
665 665
}
666 666

  
667
void Cmdenv::simulationEventEnd(double complexity)
668
{
669
    EnvirBase::simulationEventEnd(complexity);
670
}
671

  
667 672
void Cmdenv::printUISpecificHelp()
668 673
{
669 674
    ev << "Cmdenv-specific options:\n";
src/cmdenv/cmdenv.h
69 69
     virtual void moduleCreated(cModule *newmodule);
70 70
     virtual void messageSent_OBSOLETE(cMessage *msg, cGate *directToGate);
71 71
     virtual void simulationEvent(cMessage *msg);
72
     virtual void simulationEventEnd(double complexity);
72 73
     virtual bool isGUI() const {return false;}
73 74
     virtual cEnvir& flush();
74 75
     virtual std::string gets(const char *prompt, const char *defaultReply);
src/envir/envirbase.cc
1213 1213
        eventlogmgr->simulationEvent(msg);
1214 1214
}
1215 1215

  
1216
void EnvirBase::simulationEventEnd(double complexity)
1217
{
1218
    if (record_eventlog)
1219
        eventlogmgr->simulationEventEnd(complexity);
1220
}
1221

  
1222

  
1216 1223
void EnvirBase::beginSend(cMessage *msg)
1217 1224
{
1218 1225
    if (record_eventlog)
src/envir/envirbase.h
156 156
    // eventlog callback interface
157 157
    virtual void objectDeleted(cObject *object);
158 158
    virtual void simulationEvent(cMessage *msg);
159
    virtual void simulationEventEnd(double complexity);
159 160
    // leave to subclasses: virtual void messageSent_OBSOLETE(cMessage *msg, cGate *directToGate=NULL);
160 161
    virtual void messageScheduled(cMessage *msg);
161 162
    virtual void messageCancelled(cMessage *msg);
src/envir/eventlogfilemgr.cc
32 32
#include "ccompoundmodule.h"
33 33
#include "cdisplaystring.h"
34 34
#include "cclassdescriptor.h"
35
#include "casyncmodule.h"
35 36

  
36 37
USING_NAMESPACE
37 38

  
......
161 162
        cMessage *message = *it;
162 163
        if (currentEvent != message->getPreviousEventNumber()) {
163 164
            currentEvent = message->getPreviousEventNumber();
164
            EventLogWriter::recordEventEntry_e_t_m_msg(feventlog, currentEvent, message->getSendingTime(), currentEvent == 0 ? simulation.getSystemModule()->getId() : message->getSenderModuleId(), -1);
165
            EventLogWriter::recordEventEntry_e_t_m_msg_d(feventlog, currentEvent, message->getSendingTime(), currentEvent == 0 ? simulation.getSystemModule()->getId() : message->getSenderModuleId(), -1,0);
165 166
        }
166 167
        if (currentEvent == 0)
167 168
            componentMethodBegin(simulation.getSystemModule(), message->getSenderModule(), "initialize", empty_va);
......
225 226
        const char *runId = ev.getConfigEx()->getVariable(CFGVAR_RUNID);
226 227
        // TODO: we can't use simulation.getEventNumber() and simulation.getSimTime(), because when we start a new run
227 228
        // these numbers are still set from the previous run (i.e. not zero)
228
        EventLogWriter::recordEventEntry_e_t_m_msg(feventlog, 0, 0, simulation.getSystemModule()->getId(), -1);
229
        EventLogWriter::recordEventEntry_e_t_m_msg_d(feventlog, 0, 0, simulation.getSystemModule()->getId(), -1,0);
229 230
        EventLogWriter::recordSimulationBeginEntry_v_rid(feventlog, OMNETPP_VERSION, runId);
230 231
        fflush(feventlog);
231 232
    }
......
273 274

  
274 275
    if (isEventLogRecordingEnabled)
275 276
    {
276
        EventLogWriter::recordEventEntry_e_t_m_ce_msg(feventlog,
277
            simulation.getEventNumber(), simulation.getSimTime(), mod->getId(),
278
            msg->getPreviousEventNumber(), msg->getId());
277
        log_eventNumber = simulation.getEventNumber();
278
        log_simtime = simulation.getSimTime();
279
        log_modid = mod->getId();
280
        log_previd =msg->getPreviousEventNumber();
281
        log_msgid = msg->getId();
282
        log_duration = msg->getEventDuration();
283

  
284
        EventLogWriter::recordEventEntry_e_t_m_ce_msg_d(feventlog,
285
                log_eventNumber, log_simtime, log_modid,
286
                log_previd, log_msgid, log_duration);
287
    }
288
}
289

  
290
void EventlogFileManager::simulationEventEnd(double complexity) {
291
    if (isEventLogRecordingEnabled)
292
    {
293
        EventLogWriter::recordEventEndEntry_e_c(feventlog, log_eventNumber,
294
                        complexity);
279 295
    }
280 296
}
281 297

  
src/envir/eventlogfilemgr.h
45 45
    bool isModuleEventLogRecordingEnabled;
46 46
    bool isIntervalEventLogRecordingEnabled;
47 47

  
48
    //Buffering
49
    eventnumber_t log_eventNumber;
50
    simtime_t log_simtime;
51
    int log_modid;
52
    eventnumber_t log_previd;
53
    long log_msgid;
54
    simtime_t log_duration;
55

  
48 56
  public:
49 57
    EventlogFileManager();
50 58
    virtual ~EventlogFileManager();
......
67 75
    /** @name Functions called from cEnvir's similar functions */
68 76
    //@{
69 77
    virtual void simulationEvent(cMessage *msg);
78
    virtual void simulationEventEnd(double complexity);
70 79
    virtual void bubble(cComponent *component, const char *text);
71 80
    virtual void messageScheduled(cMessage *msg);
72 81
    virtual void messageCancelled(cMessage *msg);
src/eventlog/event.cc
150 150

  
151 151
        Assert(eventEntry);
152 152

  
153
        EventEndEntry * readEventEndEntry = dynamic_cast<EventEndEntry*>(eventLogEntry);
154

  
155
        if(readEventEndEntry) {
156
            eventEndEntry = readEventEndEntry;
157
        }
158

  
153 159
        // handle module method end
154 160
        ModuleMethodEndEntry *moduleMethodEndEntry = dynamic_cast<ModuleMethodEndEntry *>(eventLogEntry);
155 161
        if (moduleMethodEndEntry)
......
173 179
        if (dynamic_cast<BeginSendEntry *>(eventLogEntry))
174 180
            numBeginSendEntries++;
175 181
    }
176

  
177 182
    return endOffset = reader->getCurrentLineStartOffset();
178 183
}
179 184

  
src/eventlog/event.h
43 43
        file_offset_t beginOffset; // file offset where the event starts
44 44
        file_offset_t endOffset; // file offset where the event ends (ie. begin of next event)
45 45
        EventEntry *eventEntry; // the event log entry that corresponds to the actual event ("E" line)
46
        EventEndEntry* eventEndEntry; //the event end entry that stores the measured complexity
46 47
        ModuleCreatedEntry *moduleCreatedEntry;
47 48
        int numEventLogMessages;
48 49
        int numBeginSendEntries;
......
76 77
        virtual file_offset_t getEndOffset() { return endOffset; }
77 78

  
78 79
        virtual EventEntry *getEventEntry() { return eventEntry; }
80
        virtual EventEndEntry *getEventEndEntry() { return eventEndEntry; }
79 81
        virtual int getNumEventLogEntries() { return eventLogEntries.size(); }
80 82
        virtual EventLogEntry *getEventLogEntry(int index) { return eventLogEntries[index]; }
81 83

  
src/eventlog/eventlogentries.txt
96 96
   m int moduleId                       // id of the processing module
97 97
   ce eventnumber_t causeEventNumber -1 // event number from which the message being processed was sent, or -1 if the message was sent from initialize
98 98
   msg long messageId                   // lifetime-unique id of the message being processed
99
   d simtime_t duration                 // duration of the event
100
}
101

  
102
EE EventEndEntry //indicates end of an event
103
{
104
   e eventnumber_t eventNumber          // event number of the corresponding event
105
   c simtime_t complexity               // measured complexity of event in seconds (stored in simtime_t for compatibility issues)
99 106
}
100 107

  
101 108
CE CancelEventEntry // canceling an event caused by self message
src/eventlog/filteredevent.h
74 74
        virtual file_offset_t getEndOffset() { return getEvent()->getEndOffset(); }
75 75

  
76 76
        virtual EventEntry *getEventEntry() { return getEvent()->getEventEntry(); }
77
        virtual EventEndEntry *getEventEndEntry() { return getEvent()->getEventEndEntry(); }
77 78
        virtual int getNumEventLogEntries() { return getEvent()->getNumEventLogEntries(); }
78 79
        virtual EventLogEntry *getEventLogEntry(int index) { return getEvent()->getEventLogEntry(index); }
79 80

  
src/eventlog/ievent.h
63 63
         */
64 64
        virtual EventEntry *getEventEntry() = 0;
65 65
        /**
66
         * Returns the 'EE' entry (line) corresponding to this event.
67
         */
68
        virtual EventEndEntry *getEventEndEntry() = 0;
69
        /**
66 70
         * Returns the number of log file entries (lines) for this event.
67 71
         */
68 72
        virtual int getNumEventLogEntries() = 0;
src/sim/csimulation.cc
110 110
    setScheduler(new cSequentialScheduler());
111 111

  
112 112
    eventsPerSimTimeInstance = 0;
113

  
114
    //calibrate stopwatch
115
    sequentialWatch.calibrateTSC();
113 116
}
114 117

  
115 118
cSimulation::~cSimulation()
......
702 705
                setContextType(CTX_EVENT);
703 706

  
704 707
                EVCB.simulationEvent(msg);
705
                // store arrival event number of this message; it is useful input for the
706
                // sequence chart tool if the message doesn't get immediately deleted or
707
                // sent out again
708

  
708 709
                msg->setPreviousEventNumber(event_num);
709 710

  
711
                sequentialWatch.reset();
712
                sequentialWatch.startTicking();
710 713
                // take ownership in callHandleMessage after concurrency check
711 714
                aMod->callHandleMessage(msg);
715
                sequentialWatch.stopTicking();
716

  
717
                //Store measured complexity and write to file
718
                EVCB.simulationEventEnd(sequentialWatch.getTicksTime());
719

  
720
                // take ownership in callHandleMessage after concurrency check
712 721
                // unset busy to release module for further events
713 722
                aMod->unsetBusy();
714 723
            }
......
720 729
            setContext(mod);
721 730
            setContextType(CTX_EVENT);
722 731

  
723
            EVCB.simulationEvent(msg);
732
            //Disabled logging for simpleModules as we assume to have a duration.
733
            //EVCB.simulationEvent(msg);
724 734
            // store arrival event number of this message; it is useful input for the
725 735
            // sequence chart tool if the message doesn't get immediately deleted or
726 736
            // sent out again
......
917 927
    // eventlog callback interface
918 928
    virtual void objectDeleted(cObject *object) {}
919 929
    virtual void simulationEvent(cMessage *msg)  {}
930
    virtual void simulationEventEnd(double complexity)  {}
920 931
    virtual void messageSent_OBSOLETE(cMessage *msg, cGate *directToGate=NULL)  {}
921 932
    virtual void messageScheduled(cMessage *msg)  {}
922 933
    virtual void messageCancelled(cMessage *msg)  {}

Also available in: Unified diff