Skip to content

Commit

Permalink
Add all commands to SMU wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianFrank committed Aug 1, 2022
1 parent f46ac51 commit cab3074
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 14 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion include/Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
40 changes: 32 additions & 8 deletions py_icl/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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);

}
12 changes: 10 additions & 2 deletions py_icl/py_icl_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

6 changes: 3 additions & 3 deletions src/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ std::string Device::WhatAmI() {
return "My name is: " + m_DeviceName;
}

std::string Device::GetDeviceIdentifier()
const char* Device::GetDeviceIdentifier()
{
if(!IsOpen())
{
Expand All @@ -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();
}


Expand All @@ -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;
}
Expand Down

0 comments on commit cab3074

Please sign in to comment.