Ejemplo n.º 1
0
void ExperimentController::calculateEstimatedDuration()
{
    Experiment experiment = this->experiment();
    double duration = (boost::posix_time::microsec_clock::local_time() - experiment.startedAt()).total_milliseconds() - (experiment.pausedDuration() * 1000);
    double previousTargetTemp = HeatBlockInstance::getInstance()->temperature();

    do
    {
        Stage *stage = experiment.protocol()->currentStage();
        std::time_t holdTime = stage->currentStep()->holdTime();

        double temperature = stage->currentStep()->temperature();

        if (stage->autoDelta() && stage->currentCycle() > stage->autoDeltaStartCycle())
        {
            holdTime += stage->currentStep()->deltaDuration() * (stage->currentCycle() - stage->autoDeltaStartCycle());

            if (holdTime < 0)
                holdTime = 0;

            temperature += stage->currentStep()->deltaTemperature() * (stage->currentCycle() - stage->autoDeltaStartCycle());

            if (temperature < HeatBlockInstance::getInstance()->minTargetTemperature())
                temperature = HeatBlockInstance::getInstance()->minTargetTemperature();
            else if (temperature > HeatBlockInstance::getInstance()->maxTargetTemperature())
                temperature = HeatBlockInstance::getInstance()->maxTargetTemperature();
        }

        double rate = stage->currentRamp()->rate();
        rate = rate > 0 && rate <= kDurationCalcHeatBlockRampSpeed ? rate : kDurationCalcHeatBlockRampSpeed;

        if (previousTargetTemp < temperature)
            duration += (((temperature - previousTargetTemp) / rate) + holdTime) * 1000;
        else
            duration += (((previousTargetTemp - temperature) / rate) + holdTime) * 1000;

        previousTargetTemp = temperature;
    }
    while (experiment.protocol()->advanceNextStep());

    {
        Poco::RWLock::ScopedWriteLock lock(*_machineMutex);
        _experiment.setEstimatedDuration(std::round(duration / 1000));
    }
}
Ejemplo n.º 2
0
ExperimentController::StartingResult ExperimentController::start(int experimentId)
{
    if (OpticsInstance::getInstance()->lidOpen())
        return LidIsOpen;

    Experiment experiment = _dbControl->getExperiment(experimentId);

    if (experiment.empty() || !experiment.protocol())
        return ExperimentNotFound;
    else if (experiment.startedAt() != boost::posix_time::not_a_date_time)
        return ExperimentUsed;

    experiment.setStartedAt(boost::posix_time::microsec_clock::local_time());

    if (machineState() != IdleMachineState)
        return MachineRunning;

    stopLogging();

    {
        Poco::RWLock::ScopedWriteLock lock(*_machineMutex);

        _settings.temperatureLogsState = false;
        _settings.debugTemperatureLogsState = false;

        LidInstance::getInstance()->setTargetTemperature(experiment.protocol()->lidTemperature());

        _dbControl->startExperiment(experiment);

        _machineState = LidHeatingMachineState;
        _experiment = std::move(experiment);

        LidInstance::getInstance()->setEnableMode(true);
    }

    startLogging();

    return Started;
}