Skip to content
Snippets Groups Projects
Select Git revision
  • f9d54fc789327de70647f080b468f338ae8b08d1
  • main default protected
  • release
3 results

help.py

Blame
  • test.cpp 6.10 KiB
    #include <thread>
    #include <readline/readline.h>
    #include <readline/history.h>
    
    #include "coincell.h"
    #include "log.h"
    #include "options.h"
    
    #include "tokenize.h"
    #include "vcpps.h"
    #include "heaters.h"
    #include "multiplexers.h"
    #include "coincells.h"
    #include "startupfailure.h"
    
    void devicefailed(Vcpps& psu, int device, uint16_t serial, int code)
    {
    	std::stringstream ss;
    	Log(Log::WARN)<<"Heater device "<<device<<" with serial number "<<serial<<" has "
    	<<(code == Heaters::ERR_RECOVERED ? "recovered" : "failed")<<" with code "<<code;
    }
    
    void heaterfailed(int heater, int device)
    {
    	Log(Log::WARN)<<"Heater "<<heater<<" on device "<<device<<" has failed";
    }
    
    bool preparePsu(Vcpps* psu, float voltage, float current)
    {
    	Vcpps::Status status;
    	Log(Log::INFO, true, false)<<"Setting psu voltage to "<<voltage;
    	bool ret = psu->setVoltage(voltage);
    	if(!ret)
    	{
    		Log(Log::ERROR, true, false)<<"Unable to set psu voltage";
    		return false;
    	}
    	Log(Log::INFO, true, false)<<"Setting psu current to "<<current;
    	ret = psu->setCurrent(current);
    	if(!ret)
    	{
    		Log(Log::ERROR, true, false)<<"Unable to set psu current";
    		return false;
    	}
    	ret = psu->setEnabled(true);
    	if(!ret)
    	{
    		Log(Log::ERROR, true, false)<<"Unable to enable psu output";
    		return false;
    	}
    
    	Log(Log::INFO, true, false)<<"Waiting for psu to stablize";
    	std::this_thread::sleep_for(std::chrono::seconds(2));
    
    	ret = psu->getStatus(status);
    	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);
    		return false;
    	}
    
    	Log(Log::INFO, true, false)<<"PSU voltage: "<<status.voltage<<" current: "<<status.current