diff --git a/CMakeLists.txt b/CMakeLists.txt index 7fe225ad..ffb43595 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ add_subdirectory(common_tools_lib) add_subdirectory(playground) # TODO temporary disable python interface to satisfy CI +set(ENABLE_PYTHON 1) if(ENABLE_PYTHON) add_subdirectory(py_icl) endif() # ENABLE_PYTHON diff --git a/include/Device.h b/include/Device.h index 3b14897a..1235c3f1 100644 --- a/include/Device.h +++ b/include/Device.h @@ -34,7 +34,7 @@ class Device { PIL_ERROR_CODE Disconnect(); [[nodiscard]] bool IsOpen() const; - std::string GetDeviceIdentifier(); + const char* GetDeviceIdentifier(); std::string WhatAmI(); PIL_ERROR_CODE Exec(std::string message, char *result = nullptr, bool br = true, int size = 1024); diff --git a/py_icl/main.cpp b/py_icl/main.cpp index b80a2f93..50afba0e 100644 --- a/py_icl/main.cpp +++ b/py_icl/main.cpp @@ -2,6 +2,7 @@ #include "Device.h" #include "devices/types/DCPowerSupply.h" #include "devices/SPD1305.h" +#include "devices/types/SMU.h" #include "devices/KEI2600.h" #include "ctlib/Logging.hpp" @@ -29,16 +30,39 @@ BOOST_PYTHON_MODULE(libpy_icl) .value("UNKNOWN_ERROR", PIL_ERROR_CODE::PIL_UNKNOWN_ERROR) .value("XML_PARSING_ERROR", PIL_ERROR_CODE::PIL_XML_PARSING_ERROR); + enum_<SMU::SMU_CHANNEL>("SMU_CHANNEL") + .value("CHANNEL_A", SMU::CHANNEL_A) + .value("CHANNEL_B", SMU::CHANNEL_B); - - class_<SPD1305>("SPD1305", init<char *, int>()) - .def("Connect", &SPD1305::Connect) - .def("setCurrent", &SPD1305::setCurrent) - .def("getCurrent", &SPD1305::getCurrent) - .def("Disconnect", &SPD1305::Disconnect); - + enum_<SMU::UNIT>("SMU_UNIT") + .value("VOLTAGE", SMU::VOLTAGE) + .value("CURRENT", SMU::CURRENT) + .value("RESISTANCE", SMU::RESISTANCE) + .value("POWER", SMU::POWER); class_<KEI2600>("KEI2600", init<char *, int>()) .def("Connect", &KEI2600::Connect) - .def("setCurrent", &KEI2600::Disconnect); + .def("setCurrent", &KEI2600::Disconnect) + .def("turnOn", &KEI2600::turnOn) + .def("turnOff", &KEI2600::turnOff) + .def("measure", &KEI2600::measure) + .def("setLevel", &KEI2600::setLevel) + .def("enableMeasureAutoRange", &KEI2600::enableMeasureAutoRange) + .def("disableMeasureAutoRange", &KEI2600::disableMeasureAutoRange) + .def("enableSourceAutoRange", &KEI2600::enableSourceAutoRange) + .def("disableSourceAutoRange", &KEI2600::disableSourceAutoRange) + .def("setSourceRange", &KEI2600::setSourceRange) + .def("selectLocalSense", &KEI2600::selectLocalSense) + .def("selectRemoteSense", &KEI2600::selectRemoteSense) + .def("GetDeviceIdentifier", &KEI2600::GetDeviceIdentifier) + ; + + + + class_<SPD1305>("SPD1305", init<char *, int>()) + .def("Connect", &SPD1305::Connect) + .def("setCurrent", &SPD1305::setCurrent) + .def("getCurrent", &SPD1305::getCurrent) + .def("Disconnect", &SPD1305::Disconnect); + } diff --git a/py_icl/py_icl_test.py b/py_icl/py_icl_test.py index 9b4038ba..e42453cb 100644 --- a/py_icl/py_icl_test.py +++ b/py_icl/py_icl_test.py @@ -14,8 +14,16 @@ def spd_test(): current == 0.1 spd.Disconnect() +def smu_test(): + smu = KEI2600("192.168.1.10", 2000) + errorCode = smu.Connect() + if errorCode != ERROR_CODE.NO_ERROR: + print(errorCode) + print(smu.GetDeviceIdentifier()) + errorCode = smu.turnOn(SMU_CHANNEL.CHANNEL_A) + if errorCode != ERROR_CODE.NO_ERROR: + print(errorCode) if __name__ == "__main__": - import doctest - doctest.testmod() + smu_test() diff --git a/src/Device.cpp b/src/Device.cpp index 94616a2a..2ef9385c 100644 --- a/src/Device.cpp +++ b/src/Device.cpp @@ -107,7 +107,7 @@ std::string Device::WhatAmI() { return "My name is: " + m_DeviceName; } -std::string Device::GetDeviceIdentifier() +const char* Device::GetDeviceIdentifier() { if(!IsOpen()) { @@ -118,7 +118,7 @@ std::string Device::GetDeviceIdentifier() if(!Exec("*IDN?", buffer)) return "Error while executing *IDN?"; - return std::regex_replace(buffer, std::regex("\n"), ""); + return std::regex_replace(buffer, std::regex("\n"), "").c_str(); } @@ -138,7 +138,7 @@ std::string Device::GetDeviceIdentifier() * @endcode * */ PIL_ERROR_CODE Device::Exec(std::string message, char *result, bool br, int size) { - if(!IsOpen()){ + if(!m_SocketHandle->IsOpen()){ PIL_SetLastErrorMsg(&m_ErrorHandle, PIL_INTERFACE_CLOSED, "Error interface is closed"); return PIL_INTERFACE_CLOSED; }