# collect the data points # gamma ray try: gamma_ray = database_connection.slice("gammaray", last=1) print "Retrieved:", gamma_ray print gamma_ray[0].value gamma_ray_value_string = "%04.1f" % (pow(10.0, (gamma_ray[0].value * 2.0) / 10000.0) * 5.0) print gamma_ray_value_string gamma_ray_identifier = Identifier(record_identifier="08", item_identifier="21") gamma_ray_data_item = DataItem(identifier=gamma_ray_identifier, value=gamma_ray_value_string) mwd_data_record = DataRecord([gamma_ray_data_item]) trans.write(mwd_data_record) except KeyError, e: print e pass # azimuth try: azimuth = database_connection.slice("azimuth", last=1) print "Retrieved:", azimuth print azimuth[0].value azimuth_value_string = "%04.1f" % (azimuth[0].value * 360.0 / 10000.0) print azimuth_value_string azimuth_identifier = Identifier(record_identifier="07", item_identifier="15") azimuth_data_item = DataItem(identifier=azimuth_identifier, value=azimuth_value_string)
test_data_record3 = DataRecord([bit_depth_data_item,hole_depth_data_item,rop_data_item]) x = 0 count1 = 738.21 count2 = 1128.21 count3 = 143.21 try: while(1): #print '%04.1f' % x inclination_data_item.value = '%04.1i' % x azimuth_data_item.value = '%04.1i' % (2*x) gamma_ray_data_item.value = '%04.1i' % (3*x) bit_depth_data_item.value = '%05.2f' % (count1+x) hole_depth_data_item.value = '%05.2f' % (count2+x) rop_data_item.value = '%05.2f' % (count3+x) x += 1 print "Writing" trans.write(test_data_record) trans.write(test_data_record2) trans.write(test_data_record3) #print "Reading" #rec.read() time.sleep(1) except KeyboardInterrupt: pass
except socket.error: print "MWDCommander comm error." if new_depth is not None: try: depth_buffer.index(new_depth) except ValueError: depth_buffer.append(new_depth) #send it out the WITS port print "Sending depth update ", new_depth[0], " @ ", new_depth[1] hole_depth_data_item = DataItem(identifier=hole_depth_identifier, value='%04.1f' % new_depth[0]) bit_depth_data_item = DataItem(identifier=bit_depth_identifier, value='%04.1f' % new_depth[0]) depth_data_record = DataRecord([bit_depth_data_item]) trans.write(depth_data_record) new_rop = None try: new_rop = grok.latestROP() except socket.error: print "MWDCommander comm error." ### ROP ### if new_rop is not None: try: rop_buffer.index(new_rop) except ValueError: rop_buffer.append(new_rop) print "Sending rop update ", new_rop[0], " @ ", new_rop[1]