import isystem.connect as ic
winidea_id = ''
def test_modify():
connMgr = ic.ConnectionMgr()
connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
dataCtrl = ic.CDataController(connMgr)
print(f"Modify variable 'g_int' to value '1'...")
dataCtrl.modify(ic.IConnectDebug.fRealTime, "g_int", "1", False)
print(f"Modify variable 'g_int' to value '2', with read-back...")
value = dataCtrl.modify(ic.IConnectDebug.fRealTime, "g_int", "2", True)
print(f"\tRead-back value: {value}")
print(f"Optionally, modify variable 'g_int' to value '3' by variable type...")
sType = ic.SType()
sType.m_byType = ic.SType.tUnsigned
sType.m_byBitSize = 32
cVal = ic.CValueType(sType, 3)
dataCtrl.modify(ic.IConnectDebug.fRealTime, "g_int", cVal)
print(f"`modify() is also capable of handling expressions...")
dataCtrl.modify(ic.IConnectDebug.fRealTime,
ic.IConnectDebug.efAllowTernaryOperator,
"g_int",
"(g_int == g_char) ? 4 : 5")
value = dataCtrl.evaluate(ic.IConnectDebug.fRealTime, "g_int").getInt()
print(f"\t`(g_int == g_char)` = {value} (4 == True, 5 == False)")
if __name__ == "__main__":
test_modify()