I'm working on making a class for an instrument I'm working with. This is done with a driver from the vendor.
Once I get the class done I will work on making some sort of GUI to see if my commands are working and setting the instrument as I want.
Am I on the right track? I think I define my own types in case I want to change the return types easily, error types, etc.
Code:
#pragma once#include <string>
class InstrumentX
{
public:
InstrumentX();
~InstrumentX();
long NA_Init(std::string rscr);
long NA_Close();
long NA_ErrorQuery(long *errorCode, std::string errorMessage);
private:
unsigned long handle;
};
Code:
#include "InstrumentX.h"#include "IXdriver.h"
#include <IviVisaType.h>
InstrumentX::InstrumentX()
{
}
InstrumentX::~InstrumentX()
{
}
long InstrumentX::NA_Init(std::string rscr)
{
long status;
status = IX_InitWithOptions(const_cast<char *>(rscr.c_str()), VI_TRUE, VI_TRUE, "", &handle);
return status;
}
long InstrumentX::NA_Close()
{
long status;
status = IX_close(handle);
return status;
}
long InstrumentX::NA_ErrorQuery(long *errorCode, std::string errorMessage)
{
long status;
char* temp = nullptr;
status = IX_error_query(handle, errorCode, temp);
errorMessage = temp;
return status;
}