diff --git a/source/pcic/client.py b/source/pcic/client.py index 7ba7122..917ed52 100644 --- a/source/pcic/client.py +++ b/source/pcic/client.py @@ -1,21 +1,29 @@ from ..static.formats import error_codes, serialization_format +from o2x5xx import json, re, io import matplotlib.image as mpimg import binascii import socket import struct -import json -import re -import io +import o2x5xx class Client(object): def __init__(self, address, port): # open raw socket - self.pcicSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - self.pcicSocket.connect((address, port)) - self.recv_counter = 0 - self.debug = False - self.debugFull = False + sessionstatus = self.rpcdevice.getParameter("OperatingMode") + if sessionstatus == "0": + self.pcicSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + self.pcicSocket.connect((address, port)) + self.recv_counter = 0 + self.debug = False + self.debugFull = False + self.rpcdevice = o2x5xx.O2x5xxRPCDevice() + + elif sessionstatus == "1": + raise RuntimeError("Sensor is in Parametrization Mode. Please close the ifmVisionAssistant and retry.") + + else: + raise RuntimeError("Sensor is in simulation mode at the moment.") def __del__(self): self.close() @@ -35,7 +43,7 @@ def recv(self, number_bytes): data = data + data_part self.recv_counter += number_bytes return data - + def close(self): """ Close the socket session with the device.