Пример #1
0
void SIM_PLOT_FRAME::onSimulate( wxCommandEvent& event )
{
    if( IsSimulationRunning() )
        StopSimulation();
    else
        StartSimulation();
}
Пример #2
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QFont f("Helvetica",10);
    this->setFont(f);

    LifeField = 0;
    OptionGroup = 0;
    GroupLayout = 0;
    isSimulationOn = false;
    LifeCount = 0;
    IterationCount = 0;


    WindowLayout= new QHBoxLayout;

    QWidget * mycentralwidget = new QWidget;
    mycentralwidget->setLayout(WindowLayout);

    this->setCentralWidget(mycentralwidget);
    this->setWindowTitle("Gra w Życie");

    connect(this, SIGNAL(CellsChanged(int,int)), &Algorithm, SLOT(NewDimension(int,int)));
    connect(&Algorithm, SIGNAL(CellChanged(int,int,bool)),this, SLOT(FeedCell(int,int,bool)));
    connect(&Algorithm, SIGNAL(ChangeStatus(int,int)), this, SLOT(StatusUpdate(int,int)));
    connect(this, SIGNAL(CellsChanged(int,int,bool)), &Algorithm, SLOT(CellModified(int,int,bool)));
    connect(this, SIGNAL(FeedsChanger(int)), &Algorithm, SLOT(FeedsStatus(int)));
    //connect(&Algorithm, SIGNAL(Clear()),this, SLOT(CleanNow()));

    InitLifeField();
    InitGroupBox();
    RowsChanged();
    ColumnsChanged();


this->setMinimumSize(700, 480);

    connect(ColumnChanger, SIGNAL(valueChanged(int)), this, SLOT(ColumnsChanged()));
    connect(RowChanger, SIGNAL(valueChanged(int)), this, SLOT(RowsChanged()));
    connect(Quiter, SIGNAL(clicked()), qApp, SLOT(quit()));
    connect(Generator, SIGNAL(clicked()),this, SLOT(GenerateField()) );
    connect(Cleaner, SIGNAL(clicked()),this, SLOT(CleanNow()));
    connect(LifeField, SIGNAL(cellClicked(int, int)), this, SLOT(FeedCell(int, int)));
    connect(Starter,SIGNAL(clicked()),this ,SLOT(SimulationTrigger()));
    connect(OneMove,SIGNAL(clicked()),&Algorithm ,SLOT(SingleStep()));
    connect(comboBox, SIGNAL(activated(QString)), this, SLOT(Prepared(QString)));

    connect(this,SIGNAL(StartSimulation()), &Algorithm, SLOT(SetTimer()));
    connect(this, SIGNAL(StopSimulation()),&Algorithm, SLOT(StopTimer()));


    qsrand(QTime::currentTime().msecsTo(QTime(0,0,0,0)));

}
Пример #3
0
void MainWindow::SimulationOff()
{
    OneMove->setEnabled(true);
    Cleaner->setEnabled(true);
    Generator->setEnabled(true);
    ColumnChanger->setEnabled(true);
    comboBox->setEnabled(true);
    RowChanger->setEnabled(true);

    emit StopSimulation();

}
Пример #4
0
void SIM_PLOT_FRAME::onSimUpdate( wxCommandEvent& aEvent )
{
    if( IsSimulationRunning() )
        StopSimulation();

    if( CurrentPlot() != m_lastSimPlot )
    {
        // We need to rerun simulation, as the simulator currently stores
        // results for another plot
        StartSimulation();
    }
    else
    {
        // Incremental update
        m_simConsole->Clear();
        // Do not export netlist, it is already stored in the simulator
        applyTuners();
        m_simulator->Run();
    }
}
Пример #5
0
//-----------------------------------------------------------------------------
// Evaluate a circuit, calling ourselves recursively to evaluate if/else
// constructs. Updates the on/off state of all the leaf elements in our
// internal tables. Returns when it reaches an end if or an else construct,
// or at the end of the program.
//-----------------------------------------------------------------------------
static void SimulateIntCode(void)
{
    for(; IntPc < IntCodeLen; IntPc++) {
        IntOp *a = &IntCode[IntPc];
        switch(a->op) {
            case INT_SIMULATE_NODE_STATE:
                if(*(a->poweredAfter) != SingleBitOn(a->name1))
                    NeedRedraw = TRUE;
                *(a->poweredAfter) = SingleBitOn(a->name1);
                break;

            case INT_SET_BIT:
                SetSingleBit(a->name1, TRUE);
                break;

            case INT_CLEAR_BIT:
                SetSingleBit(a->name1, FALSE);
                break;

            case INT_COPY_BIT_TO_BIT:
                SetSingleBit(a->name1, SingleBitOn(a->name2));
                break;

            case INT_SET_VARIABLE_TO_LITERAL:
                if(GetSimulationVariable(a->name1) !=
                    a->literal && a->name1[0] != '$')
                {
                    NeedRedraw = TRUE;
                }
                SetSimulationVariable(a->name1, a->literal);
                break;

			case  INT_READ_SFR_LITERAL:
			case  INT_WRITE_SFR_LITERAL:
			case  INT_SET_SFR_LITERAL:
			case  INT_CLEAR_SFR_LITERAL:
			case  INT_TEST_SFR_LITERAL:
			case  INT_READ_SFR_VARIABLE:
			case  INT_WRITE_SFR_VARIABLE:
			case  INT_SET_SFR_VARIABLE:
			case  INT_CLEAR_SFR_VARIABLE:
			case  INT_TEST_SFR_VARIABLE:
			case  INT_TEST_C_SFR_LITERAL:
			case  INT_WRITE_SFR_LITERAL_L:
			case  INT_WRITE_SFR_VARIABLE_L:
			case  INT_SET_SFR_LITERAL_L:
			case  INT_SET_SFR_VARIABLE_L:
			case  INT_CLEAR_SFR_LITERAL_L:
			case  INT_CLEAR_SFR_VARIABLE_L:
			case  INT_TEST_SFR_LITERAL_L:
			case  INT_TEST_SFR_VARIABLE_L:
			case  INT_TEST_C_SFR_VARIABLE:
			case  INT_TEST_C_SFR_LITERAL_L:
			case  INT_TEST_C_SFR_VARIABLE_L:
                break;

            case INT_SET_VARIABLE_TO_VARIABLE:
                if(GetSimulationVariable(a->name1) != 
                    GetSimulationVariable(a->name2))
                {
                    NeedRedraw = TRUE;
                }
                SetSimulationVariable(a->name1,
                    GetSimulationVariable(a->name2));
                break;

            case INT_INCREMENT_VARIABLE:
                IncrementVariable(a->name1);
                break;

            {
                SWORD v;
                case INT_SET_VARIABLE_ADD:
                    v = GetSimulationVariable(a->name2) +
                        GetSimulationVariable(a->name3);
                    goto math;
                case INT_SET_VARIABLE_SUBTRACT:
                    v = GetSimulationVariable(a->name2) -
                        GetSimulationVariable(a->name3);
                    goto math;
                case INT_SET_VARIABLE_MULTIPLY:
                    v = GetSimulationVariable(a->name2) *
                        GetSimulationVariable(a->name3);
                    goto math;
                case INT_SET_VARIABLE_DIVIDE:
                    if(GetSimulationVariable(a->name3) != 0) {
                        v = GetSimulationVariable(a->name2) /
                            GetSimulationVariable(a->name3);
                    } else {
                        v = 0;
                        Error(_("Division by zero; halting simulation"));
                        StopSimulation();
                    }
                    goto math;
math:
                    if(GetSimulationVariable(a->name1) != v) {
                        NeedRedraw = TRUE;
                        SetSimulationVariable(a->name1, v);
                    }
                    break;
            }

#define IF_BODY \
    { \
        IfConditionTrue(); \
    } else { \
        IfConditionFalse(); \
    }
            case INT_IF_BIT_SET:
                if(SingleBitOn(a->name1))
                    IF_BODY
                break;

            case INT_IF_BIT_CLEAR:
                if(!SingleBitOn(a->name1))
                    IF_BODY
                break;

            case INT_IF_VARIABLE_LES_LITERAL:
                if(GetSimulationVariable(a->name1) < a->literal)
                    IF_BODY
                break;

            case INT_IF_VARIABLE_EQUALS_VARIABLE:
                if(GetSimulationVariable(a->name1) ==
                    GetSimulationVariable(a->name2))
                    IF_BODY
                break;

            case INT_IF_VARIABLE_GRT_VARIABLE:
                if(GetSimulationVariable(a->name1) >
                    GetSimulationVariable(a->name2))
                    IF_BODY
                break;

            case INT_SET_PWM:
                // Dummy call will cause a warning if no one ever assigned
                // to that variable.
                (void)GetSimulationVariable(a->name1);
                break;

            // Don't try to simulate the EEPROM stuff: just hold the EEPROM
            // busy all the time, so that the program never does anything
            // with it.
            case INT_EEPROM_BUSY_CHECK:
                SetSingleBit(a->name1, TRUE);
                break;

            case INT_EEPROM_READ:
            case INT_EEPROM_WRITE:
                oops();
                break;

            case INT_READ_ADC:
                // Keep the shadow copies of the ADC variables because in
                // the real device they will not be updated until an actual
                // read is performed, which occurs only for a true rung-in
                // condition there.
                SetSimulationVariable(a->name1, GetAdcShadow(a->name1));
                break;

            case INT_UART_SEND:
                if(SingleBitOn(a->name2) && (SimulateUartTxCountdown == 0)) {
                    SimulateUartTxCountdown = 2;
                    AppendToUartSimulationTextControl(
                        (BYTE)GetSimulationVariable(a->name1));
                }
                if(SimulateUartTxCountdown == 0) {
                    SetSingleBit(a->name2, FALSE);
                } else {
                    SetSingleBit(a->name2, TRUE);
                }
                break;

            case INT_UART_RECV:
                if(QueuedUartCharacter >= 0) {
                    SetSingleBit(a->name2, TRUE);
                    SetSimulationVariable(a->name1, (SWORD)QueuedUartCharacter);
                    QueuedUartCharacter = -1;
                } else {
                    SetSingleBit(a->name2, FALSE);
                }
                break;

            case INT_END_IF:
            case INT_ELSE:
                return;

            case INT_COMMENT:
                break;
            
            default:
                oops();
                break;
        }
    }
}
Пример #6
0
int Fenfloss::quit()
{
	StopSimulation();
        return 0;
}
Пример #7
0
void Fenfloss::quit()
{
	StopSimulation();
}