#include "fsoL1.h"

//namespace fso_01 {

Define_Module(fsoL1);

fsoL1::fsoL1()
{
    // Set the pointer to NULL, so that the destructor won't crash
    // even if initialize() doesn't get called because of a runtime
    // error or user cancellation during the startup process.
    //event = tictocMsg = NULL;
}

fsoL1::~fsoL1()
{
    // Dispose of dynamically allocated the objects
    //cancelAndDelete(event);
    //delete tictocMsg;
}


void fsoL1::initialize()
{
    // Initialize counter to ten. We'll decrement it every time and delete
    // the message when it reaches zero.
    //counter = par("limit");

    // The WATCH() statement below will let you examine the variable under
    // Tkenv. After doing a few steps in the simulation, double-click either
    // `tic' or `toc', select the Contents tab in the dialog that pops up,
    // and you'll find "counter" in the list.
    //WATCH(counter);

    EV << "*** FSO: INIT *** \n";

}

void fsoL1::handleMessage(cMessage *msg)
{
    // There are several ways of distinguishing messages, for example by message
    // kind (an int attribute of cMessage) or by class using dynamic_cast
    // (provided you subclass from cMessage). In this code we just check if we
    // recognize the pointer, which (if feasible) is the easiest and fastest
    // method.
    //if (uniform(0,1) < 0.1) {
    //  EV << "\"Losing\" message\n";
    //  delete msg;
    //}
    //isSelfMessage()

    EV << "*** FSO: Message arrived ***\n";

    if (msg->arrivedOn("gateA$i"))
      send(msg, "gateB$o");
    else
      send(msg, "gateA$o");

}

//}; // namespace
