Ejemplo n.º 1
0
 ActivationFactory::ActivationFactory() : ConstructionFactory<Activation*>("Activation") {
     registerConstructor("", fl::null);
     registerConstructor(First().className(), &(First::constructor));
     registerConstructor(General().className(), &(General::constructor));
     registerConstructor(Highest().className(), &(Highest::constructor));
     registerConstructor(Last().className(), &(Last::constructor));
     registerConstructor(Lowest().className(), &(Lowest::constructor));
     registerConstructor(Proportional().className(), &(Proportional::constructor));
     registerConstructor(Threshold().className(), &(Threshold::constructor));
 }
Ejemplo n.º 2
0
void Controller::Scan()
{
    while(Idlest() != NULL)
    {
        Elevator* idle = Idlest();
        if(idle->Get_pos()==0)
            idle->PushInst(new Instruction(Emulator::nFloor-1, 2));
        else
            idle->PushInst(new Instruction(0, 3));
        break;
    }
    EleIter iter = Emulator::elevators.begin();
    int k=Emulator::orders.size();
    while(k)
    {
        Order* order = Emulator::orders.front();
        if(Lowest()->Dir()==order->dir)
        {
            if(Lowest()->Dir()=='^')
                Lowest()->PushInst(new Instruction(order->from,2));
            else if(Lowest()->Dir()=='v')
                Lowest()->PushInst(new Instruction(order->from,3));
            Emulator::orders.pop_front();
            continue;
        }
        if(iter == Emulator::elevators.end())
            iter = Emulator::elevators.begin();
        for(; iter != Emulator::elevators.end(); iter++)
        {
            if((*iter)->Dir()==order->dir)
            {
                if((*iter)->Dir()=='^')
                    (*iter)->PushInst(new Instruction(order->from,2));
                else if(Lowest()->Dir()=='v')
                    (*iter)->PushInst(new Instruction(order->from,3));
                Emulator::orders.pop_front();
                break;
            }
        }

        k--;
    }
}