Skip to content

Commit

Permalink
automatedTests: datalogger test
Browse files Browse the repository at this point in the history
test for datalogger log and load data

Signed-off-by: Ionut Muthi <[email protected]>
  • Loading branch information
IonutMuthi committed Jul 9, 2024
1 parent 618f61b commit ef4706c
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 0 deletions.
88 changes: 88 additions & 0 deletions plugins/datalogger/JS/dataLoggerAutomatedTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/* log data test */
export function logData(tool, filePath, selectedMonitors) {
datalogger.enableMonitorOfTool(tool, selectedMonitors[0])
datalogger.enableMonitorOfTool(tool, selectedMonitors[1])
datalogger.clearData()
msleep(500)
datalogger.setRunning(true)
msleep(1000)
datalogger.logAtPathForTool(tool, filePath)
datalogger.continuousLogAtPathForTool(tool, filePath)
msleep(5000)
datalogger.disableMonitorOfTool(tool, selectedMonitors[0])
datalogger.disableMonitorOfTool(tool, selectedMonitors[1])
datalogger.setRunning(false)
datalogger.stopContinuousLogForTool(tool)

printToConsole("Data logged for tool : " + tool + " at :" + filePath)
}

/* load data test */
export function loadData(tool, filePath, selectedMonitors) {

datalogger.importDataFromPathForTool(tool, filePath)
msleep(500)
datalogger.enableMonitorOfTool(tool, "Import: test.csv:" + selectedMonitors[0])
datalogger.enableMonitorOfTool(tool, "Import: test.csv:" + selectedMonitors[1])

printToConsole("Data loaded for tool : " + tool + " from :" + filePath)
}

export function getMonitors(tool){
var monitors = datalogger.showAvailableMonitors()
printToConsole("Monitors list: " + monitors)
var monitorList = monitors.split(/\n/)
var voltage0Monitor = monitorList[2]
printToConsole("Monitor1 : " + voltage0Monitor)
var voltage1Monitor = monitorList[3]
printToConsole("Monitor2 : " + voltage1Monitor)
var selectedMonitors = []
selectedMonitors[0] = voltage0Monitor
selectedMonitors[1] = voltage1Monitor

return selectedMonitors
}

export function createTool(deviceID){
var newTool = datalogger.createTool()
if (newTool !== "") {
scopy.switchTool(deviceID, newTool)
printToConsole("New tool created: " + newTool)
} else {
printToConsole("ERROR: Tool creation failed")
exit(1)
}
return "DataLogger 1"
}


export function dataLogAndLoadTest(){
//TODO REPLACE WITH VAR
const filePath = "./test.csv"

printToConsole("FILE IS " + filePath)

//CONNECT TO EMU
var deviceID = scopy.addDevice("", "ip:127.0.0.0")
scopy.connectDevice(deviceID)

//TEST DATA LOGGER
printToConsole(datalogger.showAvailableMonitors())

//CREATE NEW TOOL
var tool = createTool(deviceID)
if (tool !== "") {
//GET 2 CHANNELS OF THE TOOL
var selectedMonitors = getMonitors(tool)
printToConsole("Monitors : " + selectedMonitors)
//LOG DATA ON THE TOOL CHANNELS
logData(tool, filePath, selectedMonitors)
msleep(2000)
//LOAD DATA FOR THE TOOL CHANNELS
loadData(tool, filePath, selectedMonitors)
msleep(2000)
}

exit(0);
}

5 changes: 5 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ add_test(NAME "ConnectionJSTest" COMMAND bash ${CMAKE_SOURCE_DIR}/JS/test.sh "${
add_test(NAME "SwitchToolJSTest" COMMAND bash ${CMAKE_SOURCE_DIR}/JS/test.sh "${CMAKE_SOURCE_DIR}/resources/emuXml/" "${CMAKE_SOURCE_DIR}/JS/scopyDefaultTests.js" "switchToolTest")


# PLUGIN SPECIFIC TESTS

# DATALOGGER SPECIFIC TESTS
add_test(NAME "DataLoggerJSTest" COMMAND bash ${CMAKE_SOURCE_DIR}/JS/test.sh "${CMAKE_SOURCE_DIR}/resources/emuXml/" "${CMAKE_SOURCE_DIR}/plugins/datalogger/JS/dataLoggerAutomatedTest.js" "dataLogAndLoadTest")

0 comments on commit ef4706c

Please sign in to comment.