package project.baseNetwork;

import project.baseNetwork.node.battery.MyBatteryStats;
import project.baseNetwork.node.battery.Battery;
import org.mixim.base.modules.IBaseNetwLayer;
import org.mixim.base.modules.IBaseMobility;
import org.mixim.base.modules.IBaseApplLayer;
import org.mixim.base.modules.BaseUtility;
import org.mixim.base.modules.BaseArp;


module BaseNode
{
    parameters:
        string applType; //type of the application layer
        string netwType; //type of the network layer
        string mobType; //type of the mobility module

        bool isBS = default(false);

        @display("bgb=152,202,white");
    gates:
        input radioIn; // gate for sendDirect
    submodules:
        utility: BaseUtility {
            parameters:
                @display("p=111,44;b=24,24,,black");
        }
        arp: BaseArp {
            parameters:
                @display("p=111,90;b=24,24,,blue");
        }
        mobility: <mobType> like IBaseMobility {
            parameters:
                @display("p=111,151;i=cogwheel2");
        }
        appl: <applType> like IBaseApplLayer {
            parameters:
                @display("p=41,35;i=app");
        }
        net: <netwType> like IBaseNetwLayer {
            parameters:
                @display("p=41,93;i=prot1");
        }
}

module BatteryNode extends BaseNode
{
    @display("bgb=152,236");
    submodules:
        nic: BatteryNic {
            parameters:
                @display("p=41,151;i=iface");
        }

        battery: Battery {
            parameters:
                @display("p=41,209;b=24,24,,yellow");
        }
        batteryStats: MyBatteryStats {
            parameters:
                @display("p=111,209;b=24,24,,#FF8000");
                detail = true;
        }

    connections:
        nic.upperGateOut --> net.lowerGateIn;
        nic.upperGateIn <-- net.lowerGateOut;
        nic.upperControlOut --> { @display("ls=red;m=m,70,0,70,0"); } --> net.lowerControlIn;
        nic.upperControlIn <-- { @display("ls=red;m=m,70,0,70,0"); } <-- net.lowerControlOut;

        net.upperGateOut --> appl.lowerGateIn;
        net.upperGateIn <-- appl.lowerGateOut;
        net.upperControlOut --> { @display("ls=red;m=m,70,0,70,0"); } --> appl.lowerControlIn;
        net.upperControlIn <-- { @display("ls=red;m=m,70,0,70,0"); } <-- appl.lowerControlOut;

        radioIn --> nic.radioIn;
}

module BaseStation extends BaseNode
{
    submodules:
        nic: BSNic {
            parameters:
                @display("p=41,151;i=iface");
        }

    connections:
        nic.upperGateOut --> net.lowerGateIn;
        nic.upperGateIn <-- net.lowerGateOut;
        nic.upperControlOut --> { @display("ls=red;m=m,70,0,70,0"); } --> net.lowerControlIn;
        nic.upperControlIn <-- { @display("ls=red;m=m,70,0,70,0"); } <-- net.lowerControlOut;

        net.upperGateOut --> appl.lowerGateIn;
        net.upperGateIn <-- appl.lowerGateOut;
        net.upperControlOut --> { @display("ls=red;m=m,70,0,70,0"); } --> appl.lowerControlIn;
        net.upperControlIn <-- { @display("ls=red;m=m,70,0,70,0"); } <-- appl.lowerControlOut;

        radioIn --> nic.radioIn;
}




