var nodeId = 1;
var index = 0x1000;
var subindex = 0x1;
var dataType = 7;
var result = 0;
var resultField;

// load UI file
if (util.loadUIFile("example3.ui", "myWin") === true) {
	// find result line edit
	var resultField = myWin.findChild("lineEdit");
	// find button and assign function
    var readButton = myWin.findChild("btnRead");
    readButton.clicked.connect(readValue);
	    
} else {
    util.print("Error: Cannot load UI file");
}

function readValue() {
	// get node id from combobox
	nodeId = Number(myWin.findChild("cbNode").currentText);
	// get index from index line edit
	index = Number(myWin.findChild("edtIndex").text);
	// get subindex from subindex line edit
	subindex = Number(myWin.findChild("edtSub").text);
	// set node id to sdo client
	sdo.setNodeId(nodeId);
	// read value
	result = sdo.read(index, subindex, dataType);
	// set value to result line edit
	resultField.setText("0x" + result.toString(16).toUpperCase());
}
