Python Client  0.0.0.0
Python wrapper for Corelink DLL
corelink_stream_data.py
Go to the documentation of this file.
1 """
2  @file corelink_stream_data.py
3  Handles the information associated with data streams in the client.
4 """
5 import ctypes
6 import corelink_const
7 
8 class StreamData:
9  """
10  StreamData
11  """
12  # pylint: disable=too-many-instance-attributes
13  # Eight is reasonable in this case.
14  def __init__(self,*arg):
15  if len(arg)==1:
16  rhs = arg[0]
17  self.update(rhs.stream_id,
18  rhs.state,
19  rhs.mtu,
20  rhs.user,
21  rhs.workspace,
22  rhs.meta,
23  rhs.stream_ref,
24  rhs.types)
25  elif len(arg)==8:
26  self.update(arg[0],arg[1],arg[2],arg[3],arg[4],arg[5],arg[6],arg[7])
27  def update(self,*arg):
28  """
29  update the parameters
30  """
31  self.state = arg[1]
32  self.mtu = arg[2]
33  self.stream_ref = arg[6]
34  self.stream_id = arg[0]
35  self.user = arg[3]
36  self.workspace = arg[4]
37  self.meta = arg[5]
38  self.types = arg[7]
39  @staticmethod
41  """
42  List client streams
43  """
44  corelink_const.LIB.getClientStreams.restype = ctypes.POINTER(ctypes.c_char)
45  data = corelink_const.LIB.getClientStreams()
46  # print(bytes(data[4:10]))
47  int_size = ctypes.sizeof(ctypes.c_int)
48  length = int.from_bytes(data[0:int_size],"little")
49  # print(length)
50  stream_ids = []
51  for i in range(length):
52  data_casted = int.from_bytes(data[(i+1)*int_size:(i+1)*int_size + int_size],"little")
53  stream_ids.append(data_casted)
54  corelink_const.LIB.freeData(data)
55  data_casted = None
56  return stream_ids
57 
58  @staticmethod
59  def is_receiver(stream_id):
60  """
61  is_receiver
62  """
63  corelink_const.LIB.isRecvStream.argtypes = [ctypes.c_int]
64  corelink_const.LIB.isRecvStream.restype = ctypes.c_bool
65  ans = corelink_const.LIB.isRecvStream(stream_id)
66  return ans