Select Git revision
expirament.cpp
expirament.cpp 11.69 KiB
#include "expirament.h"
#include "coincell.h"
#include "expiramentimpl.h"
#include "vcpps.h"
#include "panic.h"
#include "randomgen.h"
#include "watchdog.h"
#include <chrono>
#include <filesystem>
#include <sstream>
#include <thread>
#include <fstream>
/* Cell distrobution:
* 0 1 2 3 | 4 5 6
* 7 8 9 10 | 11 12 13
* 14 15 16 17 | 18 19 20
*/
Expirament::Expirament(std::vector<std::unique_ptr<CoinCell>>* coinCellsIn, Vcpps* psuIn, float voltageIn, float currentIn,
Heaters* heatersIn, Multiplexers* multiplexersIn, BioControl* biocontrolIn,
const std::filesystem::path& outdirIn, const std::filesystem::path& stepfileIn):
coinCells(coinCellsIn), psu(psuIn), heaters(heatersIn),
multiplexers(multiplexersIn), biocontrol(biocontrolIn),
voltage(voltageIn), current(currentIn), outdir(outdirIn),
stepfile(stepfileIn)
{
}
bool Expirament::preparePsu()
{
Vcpps::Status status;
Log(Log::INFO)<<"Setting psu voltage to "<<voltage;
bool ret = psu->setVoltage(voltage);
if(!ret)
{
Log(Log::ERROR)<<"Unable to set psu voltage";
return false;
}
Log(Log::INFO)<<"Setting psu current to "<<current;
ret = psu->setCurrent(current);
if(!ret)
{
Log(Log::ERROR)<<"Unable to set psu current";
return false;
}
ret = psu->setEnabled(true);
if(!ret)
{
Log(Log::ERROR)<<"Unable to enable psu output";
return false;
}
Log(Log::INFO)<<"Waiting for psu to stablize";
std::this_thread::sleep_for(std::chrono::seconds(2));
ret = psu->getStatus(status);
if(!ret)
{
Log(Log::ERROR)<<"Unable to read psu state, abort";
psu->setEnabled(false);
return false;
}
else if(status.curent_limited)
{
Log(Log::ERROR)<<"Psu is overcurrent at "<<status.current<<" abort";
psu->setEnabled(false);