import os
import isystem.connect as ic
import export_trace_data
winidea_id = ''
def test_createInstance():
conn_mgr = ic.ConnectionMgr()
conn_mgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
print("Exporting entire trace data to XML from a current trace controller... ")
trace_ctrl = ic.CTraceController(conn_mgr, export_trace_data.EXAMPLE_TRD_FILE, "u")
trace_ctrl.waitUntilLoaded(1000)
trace_data = ic.CTraceData.createInstance(trace_ctrl, "test_createInstance.xml", 0, 0, False)
trace_ctrl.closeDiscard()
trace_data.closeParser()
file_path = os.path.join(os.getcwd(), "test_createInstance.xml")
print(f"\tDone: {file_path}")
xml_file_path, bin_file_path = export_trace_data.export_data(conn_mgr)
print(f"Reading existing trace data XML file: {xml_file_path}")
trace_data = ic.CTraceData.createInstance(xml_file_path)
trace_data.closeParser()
print(f"Reading existing trace data BIN file: {bin_file_path}")
fmt = ic.CTraceBinExportFormat()
fmt.setHeaderVersion(ic.CTraceBinExportFormat.EHeaderVer2)
trace_data = ic.CTraceData.createInstance(bin_file_path, fmt)
trace_data.closeParser()
if __name__ == "__main__":
test_createInstance()