mkgrier5 Posted June 15, 2011 Share Posted June 15, 2011 I have this sequence running to receive my WITS data. global string datain global data while (1) try datain = device.WITS.ReadUntil(10) data = strtodouble(mid(datain,4,10)) switch Case (left(datain,4) == "0110") && (WITS_Depth(0) == 1) Global Depth = data Case (left(datain,4) == "0108") && (WITS_Bit_Depth(0) == 1) Global Bit_Depth = data Case (left(datain,4) == "0113") && (WITS_ROP(0) == 1) Global ROP = data Case (left(datain,4) == "0115") && (WITS_Hook_Load(0) == 1) Global Hook_Load = data Case (left(datain,4) == "0117") && (WITS_WOB(0) == 1) Global WOB = data Case (left(datain,4) == "0120") && (WITS_RPM(0) == 1) Global RPM = data Case (left(datain,4) == "0121") && (WITS_Pump_Pressure(0) == 1) Global Pump_Pressure = data Case (left(datain,4) == "0123") && (WITS_Pump_1(0) == 1) Global Pump_1 = data Case (left(datain,4) == "0124") && (WITS_Pump_2(0) == 1) Global Pump_2 = data endcase catch() delay(0.1) endcatch endwhile The job I'm about to start wants us to WITS everything and I'm not sure how to run my sequences just receving the WITS. For example Depth is reading at 1000, the next data point I receive is 1000.2, but I want to run a sequence when Depth increments a foot. Any ideas? Link to comment Share on other sites More sharing options...
AzeoTech Posted June 16, 2011 Share Posted June 16, 2011 So are you saying that your WITS data is coming in faster than you want it? You want to toss all WITS data except when its an even foot? Link to comment Share on other sites More sharing options...
mkgrier5 Posted June 16, 2011 Author Share Posted June 16, 2011 The data is coming in fine, but instead of it coming in to a channel and being able to "run" things from the event, I now just have a variable that is changing from the incoming WITS, and I'm not sure how to "run" things from just that. Link to comment Share on other sites More sharing options...
AzeoTech Posted June 16, 2011 Share Posted June 16, 2011 I'd just use channels instead. Create a new channel for each variable. Device Type: Test, I/O Type A/D, Timing = 0. Then in your script above, change the variable declaration to addvalue(). So, assuming you named your channels the same as the variables, the script would go from: Global Pump_2 = data to: Pump_2.AddValue(data) Note that once you make the script change, you either need to type ClearGlobals() in the command alert window, or restart DAQFactory to clear out the variables your script created, otherwise they'll take priority over the channels with the same name. Link to comment Share on other sites More sharing options...
mkgrier5 Posted June 25, 2011 Author Share Posted June 25, 2011 Changed my sequence and tried adding the value to a channel. global string datain global data while (1) try datain = device.WITS.ReadUntil(10) data = strtodouble(mid(datain,4,10)) switch Case (left(datain,4) == "0110") WITS_Depth.AddValue(data) Case (left(datain,4) == "0108") WITS_Bit_Depth.AddValue(data) Case (left(datain,4) == "0113") WITS_ROP.AddValue(data) Case (left(datain,4) == "0115") WITS_Hook_Load.AddValue(data) Case (left(datain,4) == "0117") WITS_Weight_On_Bit.AddValue(data) Case (left(datain,4) == "0120") WITS_RPM.AddValue(data) Case (left(datain,4) == "0121") WITS_Pump_Pressure.AddValue(data) Case (left(datain,4) == "0123") WITS_Pump_1.AddValue(data) Case (left(datain,4) == "0124") WITS_Pump_2.AddValue(data) endcase catch() delay(1) device.WITS.write("&&" + chr(13) + chr(10)) device.WITS.write("0140" + format("%04.1f",Gas(0)) + chr(13) + chr(10)) device.WITS.write("0139" + format("%04.1f",Lag_Depth(0)) + chr(13) + chr(10)) device.WITS.write("!!" + chr(13) + chr(10)) delay(1) endcatch endwhile I can't get the Channels to add or display anything. Please Help. Thank you. AML.ctl Link to comment Share on other sites More sharing options...
mkgrier5 Posted June 27, 2011 Author Share Posted June 27, 2011 Ok, figured that part out. I had to remove the "_", in my channel names. Now I have another problem, I want ro read the WITS every 10 seconds, but only want the WITSDepth to write to my channel when it's an even foot. Thank you for all of your help. Link to comment Share on other sites More sharing options...
AzeoTech Posted June 27, 2011 Share Posted June 27, 2011 There are lots of ways to check if something is an integer. For example: if (floor(x) == x) Link to comment Share on other sites More sharing options...
BeeHay Posted June 30, 2011 Share Posted June 30, 2011 Hello again mkgrier5! Looks like you need to "format" you incoming depth number... WITSDepth = left(mid(datain,4,5)) This will give you a depth with 5 decimal places - 1000.5 WITSDepth = left(mid(datain,4,4)) This will give you a depth with 4 decimal places - 1000 I like to use the left(mid(datain,4,5)) for WITSBitDepth... Using the left(mid(datain,4,4)) for Depth LESS THAN 1000ft will still cause the decimal to increment - ie 900.1 -> 900.2 -> 900.3, you'll have to make an if statement in your WITS in sequence to fix that.... You can also make an export loop to fire on every foot - private depthvar = WITSDepth[0] while(1) waitfor(depthvar < WITSDepth[0], 1) beginexport(MyExport) //export and update calcs for every foot here //sorry for messy code!! endwhile HTH and please corret me if I'm wrong AzeoTech!! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.