This commit is contained in:
Patrick McDonagh
2016-05-20 10:58:46 -05:00

View File

@@ -31,11 +31,6 @@ plc_ip = '192.168.1.20'
def readTag(addr, tag):
logging.basicConfig(
filename="ClxDriver.log",
format="%(levelname)-10s %(asctime)s %(message)s",
level=logging.DEBUG
)
c = ClxDriver()
if c.open(addr):
@@ -148,11 +143,11 @@ channels = {
'surface_stroke_length': Channel('surface_stroke_length', 'Card_Past[1].Surface_StrokeLength', 'float', 1.0, 3600),
'tubing_movement': Channel('tubing_movement', 'Card_Past[1].Tubing_Movement', 'float', 1.0, 3600),
'SPM': Channel('SPM', 'Card_Past[1].SPM', 'float', 0.5, 3600),
'drive_torque_mode': Channel('drive_torque_mode', 'DriveTorqueMode', 'boolean', 0, 3600),
# 'drive_torque_mode': Channel('drive_torque_mode', 'DriveTorqueMode', 'boolean', 0, 3600),
'dt': Channel('dt', 'Card_Past[1].Params.dt', 'float', 0.001, 3600),
'speed_reference': Channel('speed_reference', 'Pump_PF755.PSet_SpeedRef', 'float', 5.0, 3600),
# 'speed_reference': Channel('speed_reference', 'Pump_PF755.PSet_SpeedRef', 'float', 5.0, 3600),
'stuffing_box_friction': Channel('stuffing_box_friction', 'Card_Past[1].Params.Stuffing_Box_Friction', 'float', 1.0, 3600),
'torque_reference': Channel('torque_reference', 'PF755_Drive:O.TrqRefAStpt', 'float', 1.0, 3600),
# 'torque_reference': Channel('torque_reference', 'PF755_Drive:O.TrqRefAStpt', 'float', 1.0, 3600),
'tubing_head_pressure': Channel('tubing_head_pressure', 'Card_Past[1].Params.Tubing_Head_Pressure', 'float', 5.0, 3600),
}
@@ -194,8 +189,14 @@ class Card():
self.num_points = int(readTag(plc_ip, "Card_Past[1].Num_Points")[0])
print("reading {} from card ID {}".format(self.num_points, self.card_id))
for i in range(0, self.num_points):
self.sc.append([round(float(readTag(plc_ip, 'Card_Past[1].Surface_Position[{}]'.format(i))[0]), 3), round(float(readTag(plc_ip, 'Card_Past[1].Surface_Load[{}]'.format(i))[0]), 3)])
self.dc.append([round(float(readTag(plc_ip, 'Card_Past[1].Downhole_Position[{}]'.format(i))[0]), 3), round(float(readTag(plc_ip, 'Card_Past[1].Downhole_Load[{}]'.format(i))[0]), 3)])
surf_pos = round(float(readTag(plc_ip, 'Card_Past[1].Surface_Position[{}]'.format(i))[0]), 3)
surf_lod = round(float(readTag(plc_ip, 'Card_Past[1].Surface_Load[{}]'.format(i))[0]), 3)
down_pos = round(float(readTag(plc_ip, 'Card_Past[1].Downhole_Position[{}]'.format(i))[0]), 3)
down_lod = round(float(readTag(plc_ip, 'Card_Past[1].Downhole_Load[{}]'.format(i))[0]), 3)
if not (surf_pos == 0.0) and not (surf_lod == 0.0):
self.sc.append([surf_pos, surf_lod])
if not (down_pos == 0.0) and not (down_lod == 0.0):
self.dc.append([, ])
def stringify(self):
''' returns a list of two strings [surface card, downhole card]'''
@@ -204,8 +205,8 @@ class Card():
for i in range(0, self.num_points):
sc_str = sc_str + "[{},{}],".format(self.sc[i][0], self.sc[i][1])
dc_str = dc_str + "[{},{}],".format(self.dc[i][0], self.dc[i][1])
sc_str = sc_str[:-1] + "]"
dc_str = dc_str[:-1] + "]"
sc_str = sc_str + "[{},{}]]".format(self.sc[0][0], self.sc[0][1])
dc_str = dc_str + "[{},{}]]".format(self.dc[0][0], self.dc[0][1])
return[sc_str, dc_str]