diff --git a/output.txt b/output.txt new file mode 100644 index 0000000..b78d677 --- /dev/null +++ b/output.txt @@ -0,0 +1,521 @@ +{ +name: 'card_type', +class: 1, +tag: 'Card_Past[1].Card_Type', +data_type: 'STRING', +change_threshold: 0, +guarantee_sec: 3600, +map_function: 'card_type_map', +}, +{ +name: 'card_id', +class: 1, +tag: 'Card_Past[1].ID', +data_type: 'DINT', +change_threshold: 0.5, +guarantee_sec: 3600, +}, +{ +name: 'polished_rod_hp', +class: 2, +tag: 'Card_Past[1].Polished_Rod_HP', +data_type: 'REAL', +change_threshold: 1.0, +guarantee_sec: 3600, +}, +{ +name: 'drive_torque_mode', +class: 2, +tag: 'DriveTorqueMode', +data_type: 'BOOL', +change_threshold: 1.0, +guarantee_sec: 3600, +}, +{ +name: 'downhole_max_load', +class: 2, +tag: 'Card_Past[1].Downhole_Max_Load.Load', +data_type: 'REAL', +change_threshold: 400.0, +guarantee_sec: 3600, +}, +{ +name: 'downhole_gross_stroke', +class: 2, +tag: 'Card_Past[1].Downhole_GrossStroke', +data_type: 'REAL', +change_threshold: 2.0, +guarantee_sec: 3600, +}, +{ +name: 'spm', +class: 2, +tag: 'Card_Past[1].SPM', +data_type: 'REAL', +change_threshold: 0.5, +guarantee_sec: 3600, +}, +{ +name: 'fluid_gradient', +class: 2, +tag: 'Card_Past[1].Params.Fluid_Gradient', +data_type: 'REAL', +change_threshold: 0.002, +guarantee_sec: 3600, +}, +{ +name: 'tubing_head_pressure', +class: 2, +tag: 'Card_Past[1].Params.Tubing_Head_Pressure', +data_type: 'REAL', +change_threshold: 25.0, +guarantee_sec: 3600, +}, +{ +name: 'surface_min_load', +class: 2, +tag: 'Card_Past[1].Surface_Min.Load', +data_type: 'REAL', +change_threshold: 400.0, +guarantee_sec: 3600, +}, +{ +name: 'downhole_fluid_load', +class: 2, +tag: 'Card_Past[1].Downhole_FluidLoad', +data_type: 'REAL', +change_threshold: 400.0, +guarantee_sec: 3600, +}, +{ +name: 'downhole_max_position', +class: 2, +tag: 'Card_Past[1].Downhole_Max_Position.Position', +data_type: 'REAL', +change_threshold: 2.0, +guarantee_sec: 3600, +}, +{ +name: 'downhole_net_stroke', +class: 2, +tag: 'Card_Past[1].Downhole_NetStroke', +data_type: 'REAL', +change_threshold: 2.0, +guarantee_sec: 3600, +}, +{ +name: 'fillage_percent', +class: 2, +tag: 'Card_Past[1].Fillage_Percent', +data_type: 'REAL', +change_threshold: 5.0, +guarantee_sec: 3600, +}, +{ +name: 'pump_hp', +class: 2, +tag: 'Card_Past[1].Pump_HP', +data_type: 'REAL', +change_threshold: 1.0, +guarantee_sec: 3600, +}, +{ +name: 'surface_min_position', +class: 2, +tag: 'Card_Past[1].Surface_Min.Position', +data_type: 'REAL', +change_threshold: 1.0, +guarantee_sec: 3600, +}, +{ +name: 'pump_intake_pressure', +class: 2, +tag: 'Card_Past[1].Pump_Intake_Pressure', +data_type: 'REAL', +change_threshold: 200.0, +guarantee_sec: 3600, +}, +{ +name: 'surface_max_position', +class: 2, +tag: 'Card_Past[1].Surface_Max.Position', +data_type: 'REAL', +change_threshold: 1.0, +guarantee_sec: 3600, +}, +{ +name: 'tubing_movement', +class: 2, +tag: 'Card_Past[1].Tubing_Movement', +data_type: 'REAL', +change_threshold: 1.0, +guarantee_sec: 3600, +}, +{ +name: 'speed_reference', +class: 2, +tag: 'Pump_PF755.PSet_SpeedRef', +data_type: 'REAL', +change_threshold: 10.0, +guarantee_sec: 3600, +}, +{ +name: 'downhole_min_position', +class: 2, +tag: 'Card_Past[1].Downhole_Min_Position.Position', +data_type: 'REAL', +change_threshold: 2.0, +guarantee_sec: 3600, +}, +{ +name: 'surface_max_load', +class: 2, +tag: 'Card_Past[1].Surface_Max.Load', +data_type: 'REAL', +change_threshold: 400.0, +guarantee_sec: 3600, +}, +{ +name: 'stuffing_box_friction', +class: 2, +tag: 'Card_Past[1].Params.Stuffing_Box_Friction', +data_type: 'REAL', +change_threshold: 1.0, +guarantee_sec: 3600, +}, +{ +name: 'dt', +class: 2, +tag: 'Card_Past[1].Params.dt', +data_type: 'REAL', +change_threshold: 0.001, +guarantee_sec: 3600, +}, +{ +name: 'downhole_min_load', +class: 2, +tag: 'Card_Past[1].Downhole_Min_Load.Load', +data_type: 'REAL', +change_threshold: 400.0, +guarantee_sec: 3600, +}, +{ +name: 'torque_reference', +class: 2, +tag: 'PF755_Drive:O.TrqRefAStpt', +data_type: 'REAL', +change_threshold: 1.0, +guarantee_sec: 3600, +}, +{ +name: 'surface_stroke_length', +class: 2, +tag: 'Card_Past[1].Surface_StrokeLength', +data_type: 'REAL', +change_threshold: 1.0, +guarantee_sec: 3600, +}, +{ +name: 'downhole_adjusted_gross_stroke', +class: 2, +tag: 'Card_Past[1].Downhole_AdjustedGrossStroke', +data_type: 'REAL', +change_threshold: 2.0, +guarantee_sec: 3600, +}, +{ +name: 'fluid_level', +class: 2, +tag: 'Card_Past[1].Fluid_Above_Pump', +data_type: 'REAL', +change_threshold: 200.0, +guarantee_sec: 3600, +}, +{ +name: 'stroke_production', +class: 2, +tag: 'Stroke_Production', +data_type: 'REAL', +change_threshold: 0.005, +guarantee_sec: 3600, +}, +{ +name: 'electricity_cost', +class: 3, +tag: 'GAUGEOFF_Electricity_Cost', +data_type: 'REAL', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'percent_run', +class: 3, +tag: 'GAUGEOFF_Percent_Run', +data_type: 'REAL', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'average_spm', +class: 3, +tag: 'GAUGEOFF_Average_SPM', +data_type: 'REAL', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'hour', +class: 3, +tag: 'GAUGEOFF_DateTime.Hour', +data_type: 'DINT', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'min', +class: 3, +tag: 'GAUGEOFF_DateTime.Min', +data_type: 'DINT', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'kwh', +class: 3, +tag: 'GAUGEOFF_kWh', +data_type: 'REAL', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'lifting_cost', +class: 3, +tag: 'GAUGEOFF_Lifting_Cost', +data_type: 'REAL', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'polished_rod_hp', +class: 3, +tag: 'GAUGEOFF_Polished_Rod_HP', +data_type: 'REAL', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'month', +class: 3, +tag: 'GAUGEOFF_DateTime.Month', +data_type: 'DINT', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'inflow_rate', +class: 3, +tag: 'GAUGEOFF_Inflow_Rate', +data_type: 'REAL', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'fluid_level', +class: 3, +tag: 'GAUGEOFF_Fluid_Above_Pump', +data_type: 'REAL', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'sec', +class: 3, +tag: 'GAUGEOFF_DateTime.Sec', +data_type: 'DINT', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'full_card_production', +class: 3, +tag: 'GAUGEOFF_Full_Card_Production', +data_type: 'REAL', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'year', +class: 3, +tag: 'GAUGEOFF_DateTime.Year', +data_type: 'DINT', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'kwh_regen', +class: 3, +tag: 'GAUGEOFF_kWh_regen', +data_type: 'REAL', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'max_load', +class: 3, +tag: 'GAUGEOFF_Max_Load', +data_type: 'REAL', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'pump_intake_pressure', +class: 3, +tag: 'GAUGEOFF_pump_intake_pressure', +data_type: 'REAL', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'day', +class: 3, +tag: 'GAUGEOFF_DateTime.Day', +data_type: 'DINT', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'production_calculated', +class: 3, +tag: 'GAUGEOFF_Production_Calculated', +data_type: 'REAL', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'min_load', +class: 3, +tag: 'GAUGEOFF_Min_Load', +data_type: 'REAL', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'v_gas', +class: 4, +tag: 'Well_Test.Volume_Gas', +data_type: 'REAL', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'test_duration', +class: 4, +tag: 'Well_Test.Test_Duration', +data_type: 'REAL', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'v_oil', +class: 4, +tag: 'Well_Test.Volume_Oil', +data_type: 'REAL', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'k_factor', +class: 4, +tag: 'Well_Test.k_Factor', +data_type: 'REAL', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'p_v_water', +class: 4, +tag: 'Well_Test.Projected_Volume_Water', +data_type: 'REAL', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'month', +class: 4, +tag: 'Well_Test.DateTime_Complete.Month', +data_type: 'INT', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'sec', +class: 4, +tag: 'Well_Test.DateTime_Complete.Sec', +data_type: 'INT', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'v_water', +class: 4, +tag: 'Well_Test.Volume_Water', +data_type: 'REAL', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'year', +class: 4, +tag: 'Well_Test.DateTime_Complete.Year', +data_type: 'INT', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'p_v_oil', +class: 4, +tag: 'Well_Test.Projected_Volume_Oil', +data_type: 'REAL', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'day', +class: 4, +tag: 'Well_Test.DateTime_Complete.Day', +data_type: 'INT', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'sg_water', +class: 4, +tag: 'Well_Test.SG_Water', +data_type: 'REAL', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'api_oil', +class: 4, +tag: 'Well_Test.API_Oil', +data_type: 'REAL', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'hour', +class: 4, +tag: 'Well_Test.DateTime_Complete.Hour', +data_type: 'INT', +change_threshold: 0, +guarantee_sec: 0, +}, +{ +name: 'min', +class: 4, +tag: 'Well_Test.DateTime_Complete.Min', +data_type: 'INT', +change_threshold: 0, +guarantee_sec: 0, +}, diff --git a/seedGen.py b/seedGen.py new file mode 100644 index 0000000..4c2697e --- /dev/null +++ b/seedGen.py @@ -0,0 +1,43 @@ +import re +sqlreg = [] +regFind1 = "INSERT INTO (\w*) [(](\w*),\s(\w*),\s(\w*),\s(\w*),\s(\w*),\s(\w*),\s(\w*)[)] VALUES [(]'(\S*)',\s(\S*),\s'(\S*)',\s'(\S*)',\s(\S*),\s(\S*),\s'(\S*)'[)];" +regFind2 = "INSERT INTO (\w*) [(](\w*),\s(\w*),\s(\w*),\s(\w*),\s(\w*),\s(\w*)[)] VALUES [(]'(\S*)',\s(\S*),\s'(\S*)',\s'(\S*)',\s(\S*), (\S*)[)];" + +with open("/Users/patrickjmcd/Henry_Pump/poconsole/datalogger/tagSetup.sql", 'rb') as sqlFile: + sqlines = sqlFile.readlines() + +with open('output.txt', 'wb') as outFile: + for line in sqlines: + if len(line) > 10: + # outFile.write line.replace("\n", "") + t = re.search(regFind1, line.replace("\n", "")) + if t: + outFile.write("{\n") + outFile.write("name: '{}',\n".format(t.group(9))) + outFile.write("class: {},\n".format(t.group(10))) + outFile.write("tag: '{}',\n".format(t.group(11))) + outFile.write("data_type: '{}',\n".format(t.group(12))) + outFile.write("change_threshold: {},\n".format(t.group(13))) + outFile.write("guarantee_sec: {},\n".format(t.group(14))) + outFile.write("map_function: '{}',\n".format(t.group(15))) + outFile.write("},\n") + # sqlreg.append(t) + else: + t = re.search(regFind2, line.replace("\n", "")) + # try: + # i = 0 + # while True: + # outFile.write("{} - {}".format(i, t.group(i))) + # i = i + 1 + # except: + # pass + if t: + outFile.write("{\n") + outFile.write("name: '{}',\n".format(t.group(8))) + outFile.write("class: {},\n".format(t.group(9))) + outFile.write("tag: '{}',\n".format(t.group(10))) + outFile.write("data_type: '{}',\n".format(t.group(11))) + outFile.write("change_threshold: {},\n".format(t.group(12))) + outFile.write("guarantee_sec: {},\n".format(t.group(13))) + outFile.write("},\n") + # sqlreg.append(t)