adds testing folder

This commit is contained in:
Patrick McDonagh
2018-08-08 09:39:52 -05:00
parent 9937550d01
commit d8380a8e64
13 changed files with 491 additions and 0 deletions

Submodule testing/POC-to-ModbusTCP added at ddff98d979

1
testing/Pycomm-Helper Submodule

Submodule testing/Pycomm-Helper added at d39467c9c4

1
testing/coils.csv Normal file
View File

@@ -0,0 +1 @@
1,False2,False3,False4,False5,False6,False7,False8,False9,False10,True11,True12,False13,True14,False15,True16,False17,False18,False
1 1 False2 False3 False4 False5 False6 False7 False8 False9 False10 True11 True12 False13 True14 False15 True16 False17 False18 False

19
testing/db_coils.csv Normal file
View File

@@ -0,0 +1,19 @@
1,_TOC_ACCEPTED,0,False
2,Autotune_Next_Start,0,False
3,Gas_Interference_Override_Enabled,0,False
4,Gauge_Off_Manual,0,False
5,Initialize,0,False
6,Input_Analog_1.Enabled,0,False
7,Input_Analog_2.Enabled,0,False
8,Input_Analog_3.Enabled,0,False
9,Input_Inclinometer_Calibrate,0,False
10,Input_Inclinometer.Enabled,1,True
11,Input_LoadCell.Enabled,1,True
12,Min_Fluid_Load_Shutdown_Enabled,0,False
13,Restart_After_Fault_Allowed,1,True
14,Update_Tapers,0,False
15,USE_WIRELESS_LOADCELL,1,True
16,Write_Mode_Data,0,False
17,Write_Setup_Data,0,False
18,Pump.Start,0,False
19,Pump.Stop,0,False
1 1 _TOC_ACCEPTED 0 False
2 2 Autotune_Next_Start 0 False
3 3 Gas_Interference_Override_Enabled 0 False
4 4 Gauge_Off_Manual 0 False
5 5 Initialize 0 False
6 6 Input_Analog_1.Enabled 0 False
7 7 Input_Analog_2.Enabled 0 False
8 8 Input_Analog_3.Enabled 0 False
9 9 Input_Inclinometer_Calibrate 0 False
10 10 Input_Inclinometer.Enabled 1 True
11 11 Input_LoadCell.Enabled 1 True
12 12 Min_Fluid_Load_Shutdown_Enabled 0 False
13 13 Restart_After_Fault_Allowed 1 True
14 14 Update_Tapers 0 False
15 15 USE_WIRELESS_LOADCELL 1 True
16 16 Write_Mode_Data 0 False
17 17 Write_Setup_Data 0 False
18 18 Pump.Start 0 False
19 19 Pump.Stop 0 False

View File

@@ -0,0 +1,2 @@
1,Inclinometer_Calibrating,0,False
2,Inclinometer_Stale,0,False
1 1 Inclinometer_Calibrating 0 False
2 2 Inclinometer_Stale 0 False

View File

@@ -0,0 +1,91 @@
1,_dt,0.10000000149,0.10000000149,52429,15820
3,Casing_ID,4.89200019836,4.89200019836,35652,16540
5,Drive_Start_Speed,900.0,900.0,0,17505
7,Electricity_Cost,0.0799999982119,0.0799999982119,55050,15779
9,Estimated_Tubing_Movement,6.17285728455,6.17285728455,34828,16581
11,Fluid_Gradient,0.434196382761,0.434196382761,20221,16094
13,Friction,-80.1068344116,-80.1068344116,14003,49824
15,Gauge_Off_Time.Hour,7,7,7
16,Gauge_Off_Time.Min,30,30,30
17,Input_Analog_1_AIN.Cfg_PVEUMax,180.0,180.0,0,17204
19,Input_Analog_1_AIN.Cfg_PVEUMin,0.0,0.0,0,0
21,Input_Analog_2_AIN.Cfg_PVEUMax,100.0,100.0,0,17096
23,Input_Analog_2_AIN.Cfg_PVEUMin,0.0,0.0,0,0
25,Input_Analog_3_AIN.Cfg_PVEUMax,100.0,100.0,0,17096
27,Input_Analog_3_AIN.Cfg_PVEUMin,0.0,0.0,0,0
29,Input_Inclinometer_AIN.Cfg_PVEUMax,103.5,103.5,0,17103
31,Input_Inclinometer_AIN.Cfg_PVEUMin,-1.5,-1.5,0,49088
33,Input_LoadCell_AIN.Cfg_PVEUMax,50000.0,50000.0,20480,18243
35,Input_LoadCell_AIN.Cfg_PVEUMin,0.0,0.0,0,0
37,K_Factor,0.0,0.0,0,0
39,Min_Fluid_Load_Shutdown_Setpoint,40.0,40.0,0,16928
41,Input_Analog_1.Channel,0,0,0
42,Input_Analog_1.Type,6,6,6
43,Input_Analog_2.Channel,2,2,2
44,Input_Analog_2.Type,0,0,0
45,Input_Analog_3.Channel,3,3,3
46,Input_Analog_3.Type,0,0,0
47,Input_Inclinometer.Channel,1,1,1
48,Input_Inclinometer.Type,1,1,1
49,Input_LoadCell.Channel,0,0,0
50,Input_LoadCell.Type,6,6,6
51,Taper.Taper[1].Setup.Length,4735.0,4735.0,63488,17811
53,Taper.Taper[1].Setup.Diameter,1.22500002384,1.22500002384,52429,16284
55,Taper.Taper[1].Setup.Material,2,2,2
56,Taper.Taper[2].Setup.Length,3575.0,3575.0,28672,17759
58,Taper.Taper[2].Setup.Diameter,1.0,1.0,0,16256
60,Taper.Taper[2].Setup.Material,1,1,1
61,Taper.Taper[3].Setup.Length,125.0,125.0,0,17146
63,Taper.Taper[3].Setup.Diameter,1.5,1.5,0,16320
65,Taper.Taper[3].Setup.Material,1,1,1
66,Taper.Taper[4].Setup.Length,0.0,0.0,0,0
68,Taper.Taper[4].Setup.Diameter,1.5,1.5,0,16320
70,Taper.Taper[4].Setup.Material,1,1,1
71,Taper.Taper[5].Setup.Length,0.0,0.0,0,0
73,Taper.Taper[5].Setup.Diameter,1.5,1.5,0,16320
75,Taper.Taper[5].Setup.Material,1,1,1
76,Taper.Taper[6].Setup.Length,0.0,0.0,0,0
78,Taper.Taper[6].Setup.Diameter,1.5,1.5,0,16320
80,Taper.Taper[6].Setup.Material,1,1,1
81,Taper.Taper[7].Setup.Length,0.0,0.0,0,0
83,Taper.Taper[7].Setup.Diameter,0.0,0.0,0,0
85,Taper.Taper[7].Setup.Material,1,1,1
86,Taper.Taper[8].Setup.Length,0.0,0.0,0,0
88,Taper.Taper[8].Setup.Diameter,0.0,0.0,0,0
90,Taper.Taper[8].Setup.Material,1,1,1
91,Taper.Taper[9].Setup.Length,0.0,0.0,0,0
93,Taper.Taper[9].Setup.Diameter,0.0,0.0,0,0
95,Taper.Taper[9].Setup.Material,1,1,1
96,Taper.Taper[10].Setup.Length,0.0,0.0,0,0
98,Taper.Taper[10].Setup.Diameter,0.0,0.0,0,0
100,Taper.Taper[10].Setup.Material,1,1,1
101,UnitConfig.MotorNameplate.Volts,480.0,480.0,0,17392
103,UnitConfig.MotorNameplate.Amps,49.0,49.0,0,16964
105,UnitConfig.MotorNameplate.Hertz,60.0,60.0,0,17008
107,UnitConfig.MotorNameplate.Poles,6,6,6
108,UnitConfig.MotorNameplate.RPM,1135.0,1135.0,57344,17549
110,UnitConfig.MotorNameplate.ServiceFactor,1.14999997616,1.14999997616,13107,16275
112,UnitConfig.MotorNameplate.Horsepower,40.0,40.0,0,16928
114,UnitConfig.Pump_Diameter,2.0,2.0,0,16384
116,UnitConfig.Anchor_Depth,8513.0,8513.0,1024,17925
118,UnitConfig.Total_Stroke_Length,102.0,102.0,0,17100
120,UnitConfig.Motor_Sheave_Size,9.0,9.0,0,16656
122,UnitConfig.Gearbox_Sheave,40.0,40.0,0,16928
124,UnitConfig.Gearbox_Limit,100.0,100.0,0,17096
126,UnitConfig.Gearbox_Ratio,28.7000007629,28.7000007629,39322,16869
128,UnitConfig.Rating_Gearbox,320.0,320.0,0,17312
130,UnitConfig.Rating_Structural,256.0,256.0,0,17280
132,UnitConfig.Well_Type,0,0,0
133,UnitConfig.Total_Vertical_Depth,8435.0,8435.0,52224,17923
135,UnitConfig.Tubing_Size_ID,2.44099998474,2.44099998474,14680,16412
137,UnitConfig.Tubing_Size_OD,2.875,2.875,0,16440
139,UnitConfig.API_Oil,38.0,38.0,0,16920
141,UnitConfig.SG_Water,1.10000002384,1.10000002384,52429,16268
143,UnitConfig.Percent_Water,63.3333320618,63.3333320618,21845,17021
145,Pump.Speed_Setpoint_SPM,7.5,7.5,0,16624
147,Pump.Speed_Max,8.5,8.5,0,16648
149,Pump.Speed_Min,6.0,6.0,0,16576
151,Pump.POC_Percentage_Off,50.0,50.0,0,16968
153,Pump.Auto_Percentage_RampDown,70.0,70.0,0,17036
155,Pump.Auto_Percentage_RampUp,95.0,95.0,0,17086
157,Pump.Mode,4,4,4
1 1,_dt,0.10000000149,0.10000000149,52429,15820
2 3,Casing_ID,4.89200019836,4.89200019836,35652,16540
3 5,Drive_Start_Speed,900.0,900.0,0,17505
4 7,Electricity_Cost,0.0799999982119,0.0799999982119,55050,15779
5 9,Estimated_Tubing_Movement,6.17285728455,6.17285728455,34828,16581
6 11,Fluid_Gradient,0.434196382761,0.434196382761,20221,16094
7 13,Friction,-80.1068344116,-80.1068344116,14003,49824
8 15,Gauge_Off_Time.Hour,7,7,7
9 16,Gauge_Off_Time.Min,30,30,30
10 17,Input_Analog_1_AIN.Cfg_PVEUMax,180.0,180.0,0,17204
11 19,Input_Analog_1_AIN.Cfg_PVEUMin,0.0,0.0,0,0
12 21,Input_Analog_2_AIN.Cfg_PVEUMax,100.0,100.0,0,17096
13 23,Input_Analog_2_AIN.Cfg_PVEUMin,0.0,0.0,0,0
14 25,Input_Analog_3_AIN.Cfg_PVEUMax,100.0,100.0,0,17096
15 27,Input_Analog_3_AIN.Cfg_PVEUMin,0.0,0.0,0,0
16 29,Input_Inclinometer_AIN.Cfg_PVEUMax,103.5,103.5,0,17103
17 31,Input_Inclinometer_AIN.Cfg_PVEUMin,-1.5,-1.5,0,49088
18 33,Input_LoadCell_AIN.Cfg_PVEUMax,50000.0,50000.0,20480,18243
19 35,Input_LoadCell_AIN.Cfg_PVEUMin,0.0,0.0,0,0
20 37,K_Factor,0.0,0.0,0,0
21 39,Min_Fluid_Load_Shutdown_Setpoint,40.0,40.0,0,16928
22 41,Input_Analog_1.Channel,0,0,0
23 42,Input_Analog_1.Type,6,6,6
24 43,Input_Analog_2.Channel,2,2,2
25 44,Input_Analog_2.Type,0,0,0
26 45,Input_Analog_3.Channel,3,3,3
27 46,Input_Analog_3.Type,0,0,0
28 47,Input_Inclinometer.Channel,1,1,1
29 48,Input_Inclinometer.Type,1,1,1
30 49,Input_LoadCell.Channel,0,0,0
31 50,Input_LoadCell.Type,6,6,6
32 51,Taper.Taper[1].Setup.Length,4735.0,4735.0,63488,17811
33 53,Taper.Taper[1].Setup.Diameter,1.22500002384,1.22500002384,52429,16284
34 55,Taper.Taper[1].Setup.Material,2,2,2
35 56,Taper.Taper[2].Setup.Length,3575.0,3575.0,28672,17759
36 58,Taper.Taper[2].Setup.Diameter,1.0,1.0,0,16256
37 60,Taper.Taper[2].Setup.Material,1,1,1
38 61,Taper.Taper[3].Setup.Length,125.0,125.0,0,17146
39 63,Taper.Taper[3].Setup.Diameter,1.5,1.5,0,16320
40 65,Taper.Taper[3].Setup.Material,1,1,1
41 66,Taper.Taper[4].Setup.Length,0.0,0.0,0,0
42 68,Taper.Taper[4].Setup.Diameter,1.5,1.5,0,16320
43 70,Taper.Taper[4].Setup.Material,1,1,1
44 71,Taper.Taper[5].Setup.Length,0.0,0.0,0,0
45 73,Taper.Taper[5].Setup.Diameter,1.5,1.5,0,16320
46 75,Taper.Taper[5].Setup.Material,1,1,1
47 76,Taper.Taper[6].Setup.Length,0.0,0.0,0,0
48 78,Taper.Taper[6].Setup.Diameter,1.5,1.5,0,16320
49 80,Taper.Taper[6].Setup.Material,1,1,1
50 81,Taper.Taper[7].Setup.Length,0.0,0.0,0,0
51 83,Taper.Taper[7].Setup.Diameter,0.0,0.0,0,0
52 85,Taper.Taper[7].Setup.Material,1,1,1
53 86,Taper.Taper[8].Setup.Length,0.0,0.0,0,0
54 88,Taper.Taper[8].Setup.Diameter,0.0,0.0,0,0
55 90,Taper.Taper[8].Setup.Material,1,1,1
56 91,Taper.Taper[9].Setup.Length,0.0,0.0,0,0
57 93,Taper.Taper[9].Setup.Diameter,0.0,0.0,0,0
58 95,Taper.Taper[9].Setup.Material,1,1,1
59 96,Taper.Taper[10].Setup.Length,0.0,0.0,0,0
60 98,Taper.Taper[10].Setup.Diameter,0.0,0.0,0,0
61 100,Taper.Taper[10].Setup.Material,1,1,1
62 101,UnitConfig.MotorNameplate.Volts,480.0,480.0,0,17392
63 103,UnitConfig.MotorNameplate.Amps,49.0,49.0,0,16964
64 105,UnitConfig.MotorNameplate.Hertz,60.0,60.0,0,17008
65 107,UnitConfig.MotorNameplate.Poles,6,6,6
66 108,UnitConfig.MotorNameplate.RPM,1135.0,1135.0,57344,17549
67 110,UnitConfig.MotorNameplate.ServiceFactor,1.14999997616,1.14999997616,13107,16275
68 112,UnitConfig.MotorNameplate.Horsepower,40.0,40.0,0,16928
69 114,UnitConfig.Pump_Diameter,2.0,2.0,0,16384
70 116,UnitConfig.Anchor_Depth,8513.0,8513.0,1024,17925
71 118,UnitConfig.Total_Stroke_Length,102.0,102.0,0,17100
72 120,UnitConfig.Motor_Sheave_Size,9.0,9.0,0,16656
73 122,UnitConfig.Gearbox_Sheave,40.0,40.0,0,16928
74 124,UnitConfig.Gearbox_Limit,100.0,100.0,0,17096
75 126,UnitConfig.Gearbox_Ratio,28.7000007629,28.7000007629,39322,16869
76 128,UnitConfig.Rating_Gearbox,320.0,320.0,0,17312
77 130,UnitConfig.Rating_Structural,256.0,256.0,0,17280
78 132,UnitConfig.Well_Type,0,0,0
79 133,UnitConfig.Total_Vertical_Depth,8435.0,8435.0,52224,17923
80 135,UnitConfig.Tubing_Size_ID,2.44099998474,2.44099998474,14680,16412
81 137,UnitConfig.Tubing_Size_OD,2.875,2.875,0,16440
82 139,UnitConfig.API_Oil,38.0,38.0,0,16920
83 141,UnitConfig.SG_Water,1.10000002384,1.10000002384,52429,16268
84 143,UnitConfig.Percent_Water,63.3333320618,63.3333320618,21845,17021
85 145,Pump.Speed_Setpoint_SPM,7.5,7.5,0,16624
86 147,Pump.Speed_Max,8.5,8.5,0,16648
87 149,Pump.Speed_Min,6.0,6.0,0,16576
88 151,Pump.POC_Percentage_Off,50.0,50.0,0,16968
89 153,Pump.Auto_Percentage_RampDown,70.0,70.0,0,17036
90 155,Pump.Auto_Percentage_RampUp,95.0,95.0,0,17086
91 157,Pump.Mode,4,4,4

View File

@@ -0,0 +1,131 @@
1,_Firmware_Rev,2837,2837,2837
2,_Program_Firmware,0,0,0
3,Card_Past[1].Card_Type,0,0,0
4,Card_Past[1].Downhole_AdjustedGrossStroke,38.7296638489,38.7296638489,60205,16922
6,Card_Past[1].Downhole_FluidLoad,9301.94726562,9301.94726562,22474,17937
8,Card_Past[1].Downhole_GrossStroke,38.5721244812,38.5721244812,18907,16922
10,Card_Past[1].Downhole_Max_Load.Load,-4504.80761719,-4504.80761719,50806,50572
12,Card_Past[1].Downhole_Max_Position.Position,87.9638290405,87.9638290405,60795,17071
14,Card_Past[1].Downhole_Min_Load.Load,-13726.6484375,-13726.6484375,31384,50774
16,Card_Past[1].Downhole_Min_Position.Position,49.0251274109,49.0251274109,6587,16964
18,Card_Past[1].Downhole_NetStroke,16.4754943848,16.4754943848,52688,16771
20,Card_Past[1].Fillage_Percent,41.8596954346,41.8596954346,28756,16935
22,Card_Past[1].Fluid_Above_Pump,1672.27990723,1672.27990723,2293,17617
24,Card_Past[1].Fluid_Moved,0.00533483037725,0.00533483037725,53197,15278
26,Card_Past[1].ID,3836,3836,3836
27,Card_Past[1].Num_Points,80,80,80
28,Card_Past[1].Polished_Rod_HP,3.17588162422,3.17588162422,16805,16459
30,Card_Past[1].Pump_HP,2.14305853844,2.14305853844,10207,16393
32,Card_Past[1].Pump_Intake_Pressure,691.807373047,691.807373047,62380,17452
34,Card_Past[1].SPM,7.50029563904,7.50029563904,620,16624
36,Card_Past[1].Surface_Max.Load,22371.9980469,22371.9980469,51199,18094
38,Card_Past[1].Surface_Max.Position,102.644172668,102.644172668,18897,17101
40,Card_Past[1].Surface_Min.Load,14531.0,14531.0,3072,18019
42,Card_Past[1].Surface_Min.Position,1.48628771305,1.48628771305,16045,16318
44,Card_Past[1].Surface_StrokeLength,101.15788269,101.15788269,20694,17098
46,Card_Past[1].Tubing_Movement,-0.15805606544,-0.15805606544,55667,48673
48,Card_Past[2].Card_Type,0,0,0
49,Card_Past[2].Downhole_AdjustedGrossStroke,39.3632926941,39.3632926941,29699,16925
51,Card_Past[2].Downhole_FluidLoad,9332.53808594,9332.53808594,53799,17937
53,Card_Past[2].Downhole_GrossStroke,39.2052383423,39.2052383423,53802,16924
55,Card_Past[2].Downhole_Max_Load.Load,-4479.39453125,-4479.39453125,64296,50571
57,Card_Past[2].Downhole_Max_Position.Position,88.0684204102,88.0684204102,8968,17072
59,Card_Past[2].Downhole_Min_Load.Load,-13731.8261719,-13731.8261719,36686,50774
61,Card_Past[2].Downhole_Min_Position.Position,48.8631820679,48.8631820679,29670,16963
63,Card_Past[2].Downhole_NetStroke,16.8652839661,16.8652839661,60442,16774
65,Card_Past[2].Fillage_Percent,43.5486869812,43.5486869812,12763,16942
67,Card_Past[2].Fluid_Above_Pump,1680.51281738,1680.51281738,4201,17618
69,Card_Past[2].Fluid_Moved,0.00546104554087,0.00546104554087,62098,15282
71,Card_Past[2].ID,3837,3837,3837
72,Card_Past[2].Num_Points,81,81,81
73,Card_Past[2].Polished_Rod_HP,3.17837429047,3.17837429047,27260,16459
75,Card_Past[2].Pump_HP,2.1452255249,2.1452255249,19296,16393
77,Card_Past[2].Pump_Intake_Pressure,727.613037109,727.613037109,59196,17461
79,Card_Past[2].SPM,7.50042104721,7.50042104721,883,16624
81,Card_Past[2].Surface_Max.Load,22424.0,22424.0,12288,18095
83,Card_Past[2].Surface_Max.Position,102.704589844,102.704589844,26816,17101
85,Card_Past[2].Surface_Min.Load,14383.0,14383.0,48128,18016
87,Card_Past[2].Surface_Min.Position,1.2810652256,1.2810652256,63986,16291
89,Card_Past[2].Surface_StrokeLength,101.423522949,101.423522949,55512,17098
91,Card_Past[2].Tubing_Movement,-0.156150981784,-0.156150981784,58891,48671
93,Card_Past[3].Card_Type,0,0,0
94,Card_Past[3].Downhole_AdjustedGrossStroke,39.3632926941,39.3632926941,29699,16925
96,Card_Past[3].Downhole_FluidLoad,9220.05175781,9220.05175781,4149,17936
98,Card_Past[3].Downhole_GrossStroke,40.2297286987,40.2297286987,60222,16928
100,Card_Past[3].Downhole_Max_Load.Load,-4577.02197266,-4577.02197266,2093,50575
102,Card_Past[3].Downhole_Max_Position.Position,89.1081848145,89.1081848145,14180,17074
104,Card_Past[3].Downhole_Min_Load.Load,-13716.9667969,-13716.9667969,21470,50774
106,Card_Past[3].Downhole_Min_Position.Position,48.8784561157,48.8784561157,33674,16963
108,Card_Past[3].Downhole_NetStroke,17.2314224243,17.2314224243,55796,16777
110,Card_Past[3].Fillage_Percent,43.1121520996,43.1121520996,29400,16940
112,Card_Past[3].Fluid_Above_Pump,1593.30529785,1593.30529785,10693,17607
114,Card_Past[3].Fluid_Moved,0.00557960290462,0.00557960290462,54554,15286
116,Card_Past[3].ID,3839,3839,3839
117,Card_Past[3].Num_Points,80,80,80
118,Card_Past[3].Polished_Rod_HP,3.17968058586,3.17968058586,32739,16459
120,Card_Past[3].Pump_HP,2.15009284019,2.15009284019,39711,16393
122,Card_Past[3].Pump_Intake_Pressure,723.106201172,723.106201172,50892,17460
124,Card_Past[3].SPM,7.40651130676,7.40651130676,548,16621
126,Card_Past[3].Surface_Max.Load,22458.0,22458.0,29696,18095
128,Card_Past[3].Surface_Max.Position,102.66192627,102.66192627,21224,17101
130,Card_Past[3].Surface_Min.Load,14247.0,14247.0,39936,18014
132,Card_Past[3].Surface_Min.Position,0.897685110569,0.897685110569,52913,16229
134,Card_Past[3].Surface_StrokeLength,101.76424408,101.76424408,34635,17099
136,Card_Past[3].Tubing_Movement,-0.15639077127,-0.15639077127,9447,48672
138,Card_Past[4].Card_Type,0,0,0
139,Card_Past[4].Downhole_AdjustedGrossStroke,39.8216743469,39.8216743469,18789,16927
141,Card_Past[4].Downhole_FluidLoad,9234.20996094,9234.20996094,18647,17936
143,Card_Past[4].Downhole_GrossStroke,39.6652832031,39.6652832031,43328,16926
145,Card_Past[4].Downhole_Max_Load.Load,-4547.15625,-4547.15625,6464,50574
147,Card_Past[4].Downhole_Max_Position.Position,88.1874694824,88.1874694824,24572,17072
149,Card_Past[4].Downhole_Min_Load.Load,-13701.2597656,-13701.2597656,5386,50774
151,Card_Past[4].Downhole_Min_Position.Position,48.5221862793,48.5221862793,5816,16962
153,Card_Past[4].Downhole_NetStroke,17.5000534058,17.5000534058,28,16780
155,Card_Past[4].Fillage_Percent,47.4513893127,47.4513893127,52793,16957
157,Card_Past[4].Fluid_Above_Pump,1675.76940918,1675.76940918,30879,17617
159,Card_Past[4].Fluid_Moved,0.0056665870361,0.0056665870361,44743,15289
161,Card_Past[4].ID,3839,3839,3839
162,Card_Past[4].Num_Points,81,81,81
163,Card_Past[4].Polished_Rod_HP,3.17927145958,3.17927145958,31023,16459
165,Card_Past[4].Pump_HP,2.15389442444,2.15389442444,55656,16393
167,Card_Past[4].Pump_Intake_Pressure,697.395263672,697.395263672,22860,17454
169,Card_Past[4].SPM,7.50100326538,7.50100326538,2104,16624
171,Card_Past[4].Surface_Max.Load,22477.0,22477.0,39424,18095
173,Card_Past[4].Surface_Max.Position,102.643119812,102.643119812,18759,17101
175,Card_Past[4].Surface_Min.Load,14120.0,14120.0,40960,18012
177,Card_Past[4].Surface_Min.Position,0.760877609253,0.760877609253,51424,16194
179,Card_Past[4].Surface_StrokeLength,101.882240295,101.882240295,50101,17099
181,Card_Past[4].Tubing_Movement,-0.157758742571,-0.157758742571,35714,48673
183,Drive_Speed_Reference_SP,915.0,915.0,49152,17508
185,Drive_Torque_Percent,19.7000007629,19.7000007629,39322,16797
187,GAUGEOFF_Average_SPM,7.50694417953,7.50694417953,14563,16624
189,GAUGEOFF_Downhole_GrossStroke,49.4552688599,49.4552688599,53810,16965
191,GAUGEOFF_Downhole_NetStroke,20.4940032959,20.4940032959,62392,16803
193,GAUGEOFF_Electricity_Cost,14.1668748856,14.1668748856,43909,16738
195,GAUGEOFF_Fluid_Above_Pump,2115.18945312,2115.18945312,13064,17668
197,GAUGEOFF_Inflow_Rate,81.6242752075,81.6242752075,16289,17059
199,GAUGEOFF_kWh,177.0859375,177.0859375,5632,17201
201,GAUGEOFF_kWh_Regen,12.42578125,12.42578125,53248,16710
203,GAUGEOFF_Lifting_Cost,-0.00627574836835,-0.00627574836835,42187,48077
205,GAUGEOFF_Max_Load,22175.9042969,22175.9042969,16335,18093
207,GAUGEOFF_Min_Load,14811.7773438,14811.7773438,28444,18023
209,GAUGEOFF_Percent_Run,100.0,100.0,0,17096
211,GAUGEOFF_Polished_Rod_HP,3.17030906677,3.17030906677,58968,16458
213,GAUGEOFF_Pump_Intake_Pressure,918.411437988,918.411437988,39509,17509
215,GAUGEOFF_Surface_StrokeLength,101.617286682,101.617286682,15373,17099
219,GAUGEOFF_Tubing_Movement,-0.145999446511,-0.145999446511,32993,48661
221,Gearbox_Loading,47.773109436,47.773109436,6058,16959
223,Gearbox_Torque,231068.046875,231068.046875,42755,18529
225,Input_Analog_1_AIN.Val,418.787994385,418.787994385,25821,17361
227,Input_Analog_2_AIN.Val,0.0,0.0,0,0
229,Input_Analog_3_AIN.Val,0.0,0.0,0,0
231,Instantaneous_SPM,0.603709518909,0.603709518909,36021,16154
233,kWh_Today,102091.265625,102091.265625,26018,18375
235,Max_Theoretical_Fluid_Load,11505.9150391,11505.9150391,51113,17971
237,Motor_Torque,198.465591431,198.465591431,30513,17222
239,Pump.Run_Status,1,1,1
240,Pump.Speed_Actual_SPM,7.50140094757,7.50140094757,2938,16624
242,Pump_Intake_Pressure,675.003662109,675.003662109,49212,17448
244,TODAY_Production_Calculated,2.61908006668,2.61908006668,40706,16423
246,TODAY_Production_Projected,59.9281005859,59.9281005859,46688,17007
248,TODAY_Percent_Run,100.0,100.0,0,17096
1 1,_Firmware_Rev,2837,2837,2837
2 2,_Program_Firmware,0,0,0
3 3,Card_Past[1].Card_Type,0,0,0
4 4,Card_Past[1].Downhole_AdjustedGrossStroke,38.7296638489,38.7296638489,60205,16922
5 6,Card_Past[1].Downhole_FluidLoad,9301.94726562,9301.94726562,22474,17937
6 8,Card_Past[1].Downhole_GrossStroke,38.5721244812,38.5721244812,18907,16922
7 10,Card_Past[1].Downhole_Max_Load.Load,-4504.80761719,-4504.80761719,50806,50572
8 12,Card_Past[1].Downhole_Max_Position.Position,87.9638290405,87.9638290405,60795,17071
9 14,Card_Past[1].Downhole_Min_Load.Load,-13726.6484375,-13726.6484375,31384,50774
10 16,Card_Past[1].Downhole_Min_Position.Position,49.0251274109,49.0251274109,6587,16964
11 18,Card_Past[1].Downhole_NetStroke,16.4754943848,16.4754943848,52688,16771
12 20,Card_Past[1].Fillage_Percent,41.8596954346,41.8596954346,28756,16935
13 22,Card_Past[1].Fluid_Above_Pump,1672.27990723,1672.27990723,2293,17617
14 24,Card_Past[1].Fluid_Moved,0.00533483037725,0.00533483037725,53197,15278
15 26,Card_Past[1].ID,3836,3836,3836
16 27,Card_Past[1].Num_Points,80,80,80
17 28,Card_Past[1].Polished_Rod_HP,3.17588162422,3.17588162422,16805,16459
18 30,Card_Past[1].Pump_HP,2.14305853844,2.14305853844,10207,16393
19 32,Card_Past[1].Pump_Intake_Pressure,691.807373047,691.807373047,62380,17452
20 34,Card_Past[1].SPM,7.50029563904,7.50029563904,620,16624
21 36,Card_Past[1].Surface_Max.Load,22371.9980469,22371.9980469,51199,18094
22 38,Card_Past[1].Surface_Max.Position,102.644172668,102.644172668,18897,17101
23 40,Card_Past[1].Surface_Min.Load,14531.0,14531.0,3072,18019
24 42,Card_Past[1].Surface_Min.Position,1.48628771305,1.48628771305,16045,16318
25 44,Card_Past[1].Surface_StrokeLength,101.15788269,101.15788269,20694,17098
26 46,Card_Past[1].Tubing_Movement,-0.15805606544,-0.15805606544,55667,48673
27 48,Card_Past[2].Card_Type,0,0,0
28 49,Card_Past[2].Downhole_AdjustedGrossStroke,39.3632926941,39.3632926941,29699,16925
29 51,Card_Past[2].Downhole_FluidLoad,9332.53808594,9332.53808594,53799,17937
30 53,Card_Past[2].Downhole_GrossStroke,39.2052383423,39.2052383423,53802,16924
31 55,Card_Past[2].Downhole_Max_Load.Load,-4479.39453125,-4479.39453125,64296,50571
32 57,Card_Past[2].Downhole_Max_Position.Position,88.0684204102,88.0684204102,8968,17072
33 59,Card_Past[2].Downhole_Min_Load.Load,-13731.8261719,-13731.8261719,36686,50774
34 61,Card_Past[2].Downhole_Min_Position.Position,48.8631820679,48.8631820679,29670,16963
35 63,Card_Past[2].Downhole_NetStroke,16.8652839661,16.8652839661,60442,16774
36 65,Card_Past[2].Fillage_Percent,43.5486869812,43.5486869812,12763,16942
37 67,Card_Past[2].Fluid_Above_Pump,1680.51281738,1680.51281738,4201,17618
38 69,Card_Past[2].Fluid_Moved,0.00546104554087,0.00546104554087,62098,15282
39 71,Card_Past[2].ID,3837,3837,3837
40 72,Card_Past[2].Num_Points,81,81,81
41 73,Card_Past[2].Polished_Rod_HP,3.17837429047,3.17837429047,27260,16459
42 75,Card_Past[2].Pump_HP,2.1452255249,2.1452255249,19296,16393
43 77,Card_Past[2].Pump_Intake_Pressure,727.613037109,727.613037109,59196,17461
44 79,Card_Past[2].SPM,7.50042104721,7.50042104721,883,16624
45 81,Card_Past[2].Surface_Max.Load,22424.0,22424.0,12288,18095
46 83,Card_Past[2].Surface_Max.Position,102.704589844,102.704589844,26816,17101
47 85,Card_Past[2].Surface_Min.Load,14383.0,14383.0,48128,18016
48 87,Card_Past[2].Surface_Min.Position,1.2810652256,1.2810652256,63986,16291
49 89,Card_Past[2].Surface_StrokeLength,101.423522949,101.423522949,55512,17098
50 91,Card_Past[2].Tubing_Movement,-0.156150981784,-0.156150981784,58891,48671
51 93,Card_Past[3].Card_Type,0,0,0
52 94,Card_Past[3].Downhole_AdjustedGrossStroke,39.3632926941,39.3632926941,29699,16925
53 96,Card_Past[3].Downhole_FluidLoad,9220.05175781,9220.05175781,4149,17936
54 98,Card_Past[3].Downhole_GrossStroke,40.2297286987,40.2297286987,60222,16928
55 100,Card_Past[3].Downhole_Max_Load.Load,-4577.02197266,-4577.02197266,2093,50575
56 102,Card_Past[3].Downhole_Max_Position.Position,89.1081848145,89.1081848145,14180,17074
57 104,Card_Past[3].Downhole_Min_Load.Load,-13716.9667969,-13716.9667969,21470,50774
58 106,Card_Past[3].Downhole_Min_Position.Position,48.8784561157,48.8784561157,33674,16963
59 108,Card_Past[3].Downhole_NetStroke,17.2314224243,17.2314224243,55796,16777
60 110,Card_Past[3].Fillage_Percent,43.1121520996,43.1121520996,29400,16940
61 112,Card_Past[3].Fluid_Above_Pump,1593.30529785,1593.30529785,10693,17607
62 114,Card_Past[3].Fluid_Moved,0.00557960290462,0.00557960290462,54554,15286
63 116,Card_Past[3].ID,3839,3839,3839
64 117,Card_Past[3].Num_Points,80,80,80
65 118,Card_Past[3].Polished_Rod_HP,3.17968058586,3.17968058586,32739,16459
66 120,Card_Past[3].Pump_HP,2.15009284019,2.15009284019,39711,16393
67 122,Card_Past[3].Pump_Intake_Pressure,723.106201172,723.106201172,50892,17460
68 124,Card_Past[3].SPM,7.40651130676,7.40651130676,548,16621
69 126,Card_Past[3].Surface_Max.Load,22458.0,22458.0,29696,18095
70 128,Card_Past[3].Surface_Max.Position,102.66192627,102.66192627,21224,17101
71 130,Card_Past[3].Surface_Min.Load,14247.0,14247.0,39936,18014
72 132,Card_Past[3].Surface_Min.Position,0.897685110569,0.897685110569,52913,16229
73 134,Card_Past[3].Surface_StrokeLength,101.76424408,101.76424408,34635,17099
74 136,Card_Past[3].Tubing_Movement,-0.15639077127,-0.15639077127,9447,48672
75 138,Card_Past[4].Card_Type,0,0,0
76 139,Card_Past[4].Downhole_AdjustedGrossStroke,39.8216743469,39.8216743469,18789,16927
77 141,Card_Past[4].Downhole_FluidLoad,9234.20996094,9234.20996094,18647,17936
78 143,Card_Past[4].Downhole_GrossStroke,39.6652832031,39.6652832031,43328,16926
79 145,Card_Past[4].Downhole_Max_Load.Load,-4547.15625,-4547.15625,6464,50574
80 147,Card_Past[4].Downhole_Max_Position.Position,88.1874694824,88.1874694824,24572,17072
81 149,Card_Past[4].Downhole_Min_Load.Load,-13701.2597656,-13701.2597656,5386,50774
82 151,Card_Past[4].Downhole_Min_Position.Position,48.5221862793,48.5221862793,5816,16962
83 153,Card_Past[4].Downhole_NetStroke,17.5000534058,17.5000534058,28,16780
84 155,Card_Past[4].Fillage_Percent,47.4513893127,47.4513893127,52793,16957
85 157,Card_Past[4].Fluid_Above_Pump,1675.76940918,1675.76940918,30879,17617
86 159,Card_Past[4].Fluid_Moved,0.0056665870361,0.0056665870361,44743,15289
87 161,Card_Past[4].ID,3839,3839,3839
88 162,Card_Past[4].Num_Points,81,81,81
89 163,Card_Past[4].Polished_Rod_HP,3.17927145958,3.17927145958,31023,16459
90 165,Card_Past[4].Pump_HP,2.15389442444,2.15389442444,55656,16393
91 167,Card_Past[4].Pump_Intake_Pressure,697.395263672,697.395263672,22860,17454
92 169,Card_Past[4].SPM,7.50100326538,7.50100326538,2104,16624
93 171,Card_Past[4].Surface_Max.Load,22477.0,22477.0,39424,18095
94 173,Card_Past[4].Surface_Max.Position,102.643119812,102.643119812,18759,17101
95 175,Card_Past[4].Surface_Min.Load,14120.0,14120.0,40960,18012
96 177,Card_Past[4].Surface_Min.Position,0.760877609253,0.760877609253,51424,16194
97 179,Card_Past[4].Surface_StrokeLength,101.882240295,101.882240295,50101,17099
98 181,Card_Past[4].Tubing_Movement,-0.157758742571,-0.157758742571,35714,48673
99 183,Drive_Speed_Reference_SP,915.0,915.0,49152,17508
100 185,Drive_Torque_Percent,19.7000007629,19.7000007629,39322,16797
101 187,GAUGEOFF_Average_SPM,7.50694417953,7.50694417953,14563,16624
102 189,GAUGEOFF_Downhole_GrossStroke,49.4552688599,49.4552688599,53810,16965
103 191,GAUGEOFF_Downhole_NetStroke,20.4940032959,20.4940032959,62392,16803
104 193,GAUGEOFF_Electricity_Cost,14.1668748856,14.1668748856,43909,16738
105 195,GAUGEOFF_Fluid_Above_Pump,2115.18945312,2115.18945312,13064,17668
106 197,GAUGEOFF_Inflow_Rate,81.6242752075,81.6242752075,16289,17059
107 199,GAUGEOFF_kWh,177.0859375,177.0859375,5632,17201
108 201,GAUGEOFF_kWh_Regen,12.42578125,12.42578125,53248,16710
109 203,GAUGEOFF_Lifting_Cost,-0.00627574836835,-0.00627574836835,42187,48077
110 205,GAUGEOFF_Max_Load,22175.9042969,22175.9042969,16335,18093
111 207,GAUGEOFF_Min_Load,14811.7773438,14811.7773438,28444,18023
112 209,GAUGEOFF_Percent_Run,100.0,100.0,0,17096
113 211,GAUGEOFF_Polished_Rod_HP,3.17030906677,3.17030906677,58968,16458
114 213,GAUGEOFF_Pump_Intake_Pressure,918.411437988,918.411437988,39509,17509
115 215,GAUGEOFF_Surface_StrokeLength,101.617286682,101.617286682,15373,17099
116 219,GAUGEOFF_Tubing_Movement,-0.145999446511,-0.145999446511,32993,48661
117 221,Gearbox_Loading,47.773109436,47.773109436,6058,16959
118 223,Gearbox_Torque,231068.046875,231068.046875,42755,18529
119 225,Input_Analog_1_AIN.Val,418.787994385,418.787994385,25821,17361
120 227,Input_Analog_2_AIN.Val,0.0,0.0,0,0
121 229,Input_Analog_3_AIN.Val,0.0,0.0,0,0
122 231,Instantaneous_SPM,0.603709518909,0.603709518909,36021,16154
123 233,kWh_Today,102091.265625,102091.265625,26018,18375
124 235,Max_Theoretical_Fluid_Load,11505.9150391,11505.9150391,51113,17971
125 237,Motor_Torque,198.465591431,198.465591431,30513,17222
126 239,Pump.Run_Status,1,1,1
127 240,Pump.Speed_Actual_SPM,7.50140094757,7.50140094757,2938,16624
128 242,Pump_Intake_Pressure,675.003662109,675.003662109,49212,17448
129 244,TODAY_Production_Calculated,2.61908006668,2.61908006668,40706,16423
130 246,TODAY_Production_Projected,59.9281005859,59.9281005859,46688,17007
131 248,TODAY_Percent_Run,100.0,100.0,0,17096

View File

@@ -0,0 +1 @@
1,False
1 1 False

Binary file not shown.

View File

@@ -0,0 +1 @@
{"options":{},"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"tag_data.tag_vals"}]}

View File

@@ -0,0 +1 @@
1,524292,158203,356524,165405,06,175057,550508,157799,3482810,1658111,2022112,1609413,1400314,4982415,716,3017,018,1720419,020,021,022,1709623,024,025,026,1709627,028,029,030,1710331,032,4908833,2048034,1824335,036,037,038,039,040,1692841,042,643,244,045,346,047,148,149,050,651,6348852,1781153,5242954,1628455,256,2867257,1775958,059,1625660,161,062,1714663,064,1632065,166,067,068,069,1632070,171,072,073,074,1632075,176,077,078,079,1632080,181,082,083,084,085,186,087,088,089,090,191,092,093,094,095,196,097,098,099,0100,1101,0102,17392103,0104,16964105,0106,17008107,6108,57344109,17549110,13107111,16275112,0113,16928114,0115,16384116,1024117,17925118,0119,17100120,0121,16656122,0123,16928124,0125,17096126,39322127,16869128,0129,17312130,0131,17280132,0133,52224134,17923135,14680136,16412137,0138,16440139,0140,16920141,52429142,16268143,21845144,17021145,0146,16624147,0148,16648149,0150,16576151,0152,16968153,0154,17036155,0156,17086157,4
1 1 524292 158203 356524 165405 06 175057 550508 157799 3482810 1658111 2022112 1609413 1400314 4982415 716 3017 018 1720419 020 021 022 1709623 024 025 026 1709627 028 029 030 1710331 032 4908833 2048034 1824335 036 037 038 039 040 1692841 042 643 244 045 346 047 148 149 050 651 6348852 1781153 5242954 1628455 256 2867257 1775958 059 1625660 161 062 1714663 064 1632065 166 067 068 069 1632070 171 072 073 074 1632075 176 077 078 079 1632080 181 082 083 084 085 186 087 088 089 090 191 092 093 094 095 196 097 098 099 0100 1101 0102 17392103 0104 16964105 0106 17008107 6108 57344109 17549110 13107111 16275112 0113 16928114 0115 16384116 1024117 17925118 0119 17100120 0121 16656122 0123 16928124 0125 17096126 39322127 16869128 0129 17312130 0131 17280132 0133 52224134 17923135 14680136 16412137 0138 16440139 0140 16920141 52429142 16268143 21845144 17021145 0146 16624147 0148 16648149 0150 16576151 0152 16968153 0154 17036155 0156 17086157 4

File diff suppressed because one or more lines are too long

241
testing/test.py Normal file
View File

@@ -0,0 +1,241 @@
#!/usr/bin/env python
# ---------------------------------------------------------------------------#
# import the various server implementations
# ---------------------------------------------------------------------------#
from pymodbus.client.sync import ModbusTcpClient as ModbusClient
# ---------------------------------------------------------------------------#
# import python packages
# ---------------------------------------------------------------------------#
from pymongo import MongoClient
import pytest
import struct
# ---------------------------------------------------------------------------#
# configure the client logging
# ---------------------------------------------------------------------------#
import logging
logging.basicConfig()
log = logging.getLogger()
log.setLevel(logging.INFO)
# ---------------------------------------------------------------------------#
# Modbus Client Setup
# ---------------------------------------------------------------------------#
modbus_client = ModbusClient('localhost', port=502)
# ---------------------------------------------------------------------------#
# Mongo DB Setup
# ---------------------------------------------------------------------------#
mongo_client = MongoClient()
mongo_db = mongo_client.tag_data
mongo_tags = mongo_db.tag_vals
def close_enough(a, b):
return abs(a - b) < 0.001
def float_to_bytes(float_val):
'''
Converts a float to little-endian bytes
'''
packed_string = struct.pack('f', float_val)
unpacked_list = list(struct.unpack('HH', packed_string))
return unpacked_list
def integer_to_byte(integer_val):
'''
Converts an integer to its byte
'''
packed_string = struct.pack('h', integer_val)
unpacked = list(struct.unpack('H', packed_string))
return unpacked
def lebyte_to_float(word_list):
'''
Converts list of little-endian bytes to float
'''
packed_string = struct.pack("HH", *word_list)
unpacked_float = struct.unpack("f", packed_string)[0]
return unpacked_float
def lebyte_to_integer(word_list):
'''
Converts list(size = 1) of little-endian bytes to Integer
'''
try:
packed_string = struct.pack("H", *word_list)
unpacked_int = struct.unpack("h", packed_string)[0]
except Exception as e:
print("Unable to convert {} to integer".format(word_list))
return False
return unpacked_int
def read_holding_registers(num_registers):
with open('holding_registers.csv', 'wb') as csvfile:
modbus_client.connect()
for i in range(0, num_registers - 1):
reg = modbus_client.read_holding_registers(i, 1).registers
csvfile.write("{},{}\n".format(i + 1, reg[0]))
print("{},{}".format(i + 1, reg[0]))
def read_input_registers(num_registers):
with open('input_registers.csv', 'wb') as csvfile:
modbus_client.connect()
for i in range(0, num_registers - 1):
reg = modbus_client.read_input_registers(i, 1).registers
csvfile.write("{},{}\n".format(i + 1, reg[0]))
print("{},{}".format(i + 1, reg[0]))
def read_coils(num_registers):
with open('coils.csv', 'wb') as csvfile:
modbus_client.connect()
for i in range(0, num_registers - 1):
reg = modbus_client.read_coils(i, 1).bits
csvfile.write("{},{}\n".format(i + 1, reg[0]))
print("{},{}".format(i + 1, reg[0]))
def read_discrete_inputs(num_registers):
with open('discrete_inputs.csv', 'wb') as csvfile:
modbus_client.connect()
for i in range(0, num_registers - 1):
reg = modbus_client.read_discrete_inputs(i, 1).bits
csvfile.write("{},{}\n".format(i + 1, reg[0]))
print("{},{}".format(i + 1, reg[0]))
def db_read_holding_registers():
tag_in_db = mongo_tags.find({"register_type": 'hr'})
with open('db_holding_registers.csv', 'wb') as csvfile:
for db_tag in tag_in_db:
try:
database_value = db_tag['val']
except KeyError:
print("No value in DB for {}".format(db_tag['tag_name']))
reg = []
reg_string = ""
try:
if db_tag['tag_type'][-3:] == 'INT':
reg = modbus_client.read_holding_registers(db_tag['register_number'] - 1, 1).registers
elif db_tag['tag_type'] == 'REAL':
reg = modbus_client.read_holding_registers(db_tag['register_number'] - 1, 2).registers
# print(reg)
except AttributeError:
print("Could not get register {} for {}".format(db_tag['register_number'], db_tag['tag_name']))
continue
if reg:
if len(reg) == 2:
# r = reg.reverse()
modbus_value = lebyte_to_float(reg)
reg_string = "{},{}".format(reg[0], reg[1])
else:
modbus_value = lebyte_to_integer(reg)
reg_string = "{}".format(reg[0])
print("{},{},{},{},{}".format(db_tag['register_number'], db_tag['tag_name'], database_value, modbus_value, reg_string))
csvfile.write("{},{},{},{},{}\n".format(db_tag['register_number'], db_tag['tag_name'], database_value, modbus_value, reg_string))
modbus_client.close()
def db_read_input_registers():
tag_in_db = mongo_tags.find({"register_type": 'ir'})
with open('db_input_registers.csv', 'wb') as csvfile:
for db_tag in tag_in_db:
try:
database_value = db_tag['val']
except KeyError:
print("No value in DB for {}".format(db_tag['tag_name']))
continue
reg = []
try:
if db_tag['tag_type'][-3:] == 'INT':
reg = modbus_client.read_input_registers(db_tag['register_number'] - 1, 1).registers
elif db_tag['tag_type'] == 'REAL':
reg = modbus_client.read_input_registers(db_tag['register_number'] - 1, 2).registers
# print(reg)
except AttributeError:
print("Could not get register {} for {}".format(db_tag['register_number'], db_tag['tag_name']))
continue
if reg:
if len(reg) == 2:
# r = reg.reverse()
modbus_value = lebyte_to_float(reg)
reg_string = "{},{}".format(reg[0], reg[1])
else:
modbus_value = lebyte_to_integer(reg)
reg_string = "{}".format(reg[0])
print("{},{},{},{},{}".format(db_tag['register_number'], db_tag['tag_name'], database_value, modbus_value, reg_string))
csvfile.write("{},{},{},{},{}\n".format(db_tag['register_number'], db_tag['tag_name'], database_value, modbus_value, reg_string))
modbus_client.close()
def db_read_coils():
modbus_client.connect()
tag_in_db = mongo_tags.find({"register_type": 'co'})
with open('db_coils.csv', 'wb') as csvfile:
for db_tag in tag_in_db:
try:
database_value = db_tag['val']
except KeyError:
print("No value in DB for {}".format(db_tag['tag_name']))
continue
try:
reg = modbus_client.read_coils(db_tag['register_number'] - 1, 1).bits
print("{},{},{},{}".format(db_tag['register_number'], db_tag['tag_name'], database_value, reg[0]))
csvfile.write("{},{},{},{}\n".format(db_tag['register_number'], db_tag['tag_name'], database_value, reg[0]))
except AttributeError:
print("Could not get register {} for {}".format(db_tag['register_number'], db_tag['tag_name']))
continue
def db_read_discrete_inputs():
modbus_client.connect()
tag_in_db = mongo_tags.find({"register_type": 'di'})
with open('db_discrete_inputs.csv', 'wb') as csvfile:
for db_tag in tag_in_db:
try:
database_value = db_tag['val']
except KeyError:
print("No value in DB for {}".format(db_tag['tag_name']))
continue
try:
reg = modbus_client.read_discrete_inputs(db_tag['register_number'] - 1, 1).bits
print("{},{},{},{}".format(db_tag['register_number'], db_tag['tag_name'], database_value, reg[0]))
csvfile.write("{},{},{},{}\n".format(db_tag['register_number'], db_tag['tag_name'], database_value, reg[0]))
except AttributeError:
print("Could not get register {} for {}".format(db_tag['register_number'], db_tag['tag_name']))
continue
if __name__ == '__main__':
print("Holding Registers")
# read_holding_registers(158)
db_read_holding_registers()
print("Input Registers")
# read_input_registers(22753)
db_read_input_registers()
print("Coils")
# read_coils(19)
db_read_coils()
print("Discrete Inputs")
# read_discrete_inputs(2)
db_read_discrete_inputs()