-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_arrington.py
executable file
·84 lines (64 loc) · 2.23 KB
/
test_arrington.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env python3
# use either host socket or dll with viewpointclient
VPXDLL = r"C:/Windows/System32/VPX_InterApp_64.dll"
# 20210811 remove host to default to VPXDLL
#HOST = "10.48.88.120"
import os
import sys
from time import sleep
import re
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + "/lncdtask")
from lncdtask.externalcom import Arrington
from lncdtask.arrington_socket import ArringtonSocket
# can take a dll or ip address
if len(sys.argv) > 1:
if re.search('dll', sys.argv[1], re.IGNORECASE):
VPXDLL = sys.argv[1]
HOST = ""
print("setting dll to {VPXDLL}")
else:
HOST = sys.argv[1]
VPXDLL = ""
print("setting host to {HOST}")
# test out
try:
if 'HOST' in vars() and HOST:
print("connecting ...")
tracker = ArringtonSocket(HOST)
elif 'VPXDLL' in vars() and VPXDLL:
if not os.path.exists(VPXDLL):
raise Exception(f"VPXDLL doesn't exist! '{VPXDLL}'")
else:
print(f"using {VPXDLL}")
# 20210811 from Arrington, need to reincode string
# vpx.VPX_SendCommand(str(cmd).encode('ascii'))
#print("# DLL directly")
#from ctypes import cdll, CDLL
#cdll.LoadLibrary(VPXDLL)
#vpx = CDLL(VPXDLL)
#print(f"status: {vpx.VPX_GetStatus(1)}")
#print("'say' command to ET")
#res = vpx.VPX_SendCommand('say "python is connected"')
#print(f" res: {res}")
print("creating tracker object with dll")
tracker = Arrington(VPXDLL, verbose=True)
print("using vpx directly via tracker package")
tracker.vpx.VPX_SendCommand(str('say "python is connected via wrapper"').encode('ascii'))
else:
raise Exception(f"define HOST or VPXDLL in {__file__} or specify as 1st arg on cli")
print("# USING lncdtask ET WRAPPER")
print("opening new file")
tracker.new("test_file")
print("start recording")
tracker.start()
print("send event and waiting 1 second...")
tracker.event("test event")
sleep(1)
print("again and wait 1 second...")
tracker.event("different event")
sleep(1)
print("done")
tracker.stop()
except Exception as e:
print(f"ERROR: {e}")
input("Press enter to quit\n")