'AKS1.CR1X 'CR1000X Series 'Created by Short Cut (4.0) 'Modified by Joel Bailey '6/15/2018 ConstTable Const PAKBUS_INFO = 384 Const PB_MODL = "CS106" Const PB_SN = "N0710344" Const PB_UNITS = "mBar" Const PB_MULT = 0.24 Const PB_OFS = 500 Const PB__SE = 1 Const PB_EN__CP = 1 Const SR50_MODL = "SR50A" Const SR50_SN = "9207" Const SR50__CP = C1 EndConstTable 'Declare Variables and Units Public progSig As Long Public Battery Public PTemp_C Public SW12State As Boolean Public Pb Public FTPResult Public FTPResult2 'Single measured values. Public SR50AT_M(3) Alias SR50AT_M(1) = MDT : Units MDT = meters 'Distance from the SR50AT. Alias SR50AT_M(2) = MQ : Units MQ = unitless 'Quality number. Alias SR50AT_M(3) = MAir : Units MAir = °C 'Air temperature. 'Array to hold 11 SR50AT measurements composed of a distance and 'quality number, and air temperature. Public SR50AT(11,3) 'Sorted array of 11 SR50AT measurements composed of a distance and 'quality number, and temperature. Measurements are sorted by the 'distance value from smallest to largest. Public Result_SR50AT(11,3) Public TCDT : Units TCDT = meters 'Temperature corrected distance Public Q : Units Q = unitless 'Quality number Public AT : Units AT = °C 'Air temperature Public Inital_Dist : Units Inital_Dist = meters 'Distance to ground. Public Stage : Units Stage = meters 'water stage 'Controls SR50AT measurement. This flag can be manually controlled to 'run tests in the field or is automatically set 2 minutes before the 'hourly data storage interval. This is done so 11 measurements can 'be made and sorted before the values are stored. Public SR50ATCtrl As Boolean 'Set this flag to measure and store the initial distance from the 'SR50AT to the ground. Public SR50AT_MID As Boolean Dim n 'used as a counter Units Battery=Volts Units PTemp_C=Deg C Units Pb=mbar 'Define Data Tables DataTable(Hydro,True,-1) DataInterval(0,15,Min,10) Sample(1,progSig,uint2) Sample(1,AT,FP2) Average(1,AT,FP2,False) Sample(1,TCDT,FP2) Sample(1,Q,FP2) Sample(1,Stage,IEEE4) Average(1,stage,IEEE4,False) Average(1,Pb,FP2,False) Sample(1,Pb,FP2) EndTable DataTable(HrlyDiag,True,-1) DataInterval(0,60,Min,10) Sample(1,progSig,uint2) Sample(1,Battery,FP2) Average(1,Battery,FP2,False) Average(1,PTemp_C,FP2,False) EndTable 'Main Program BeginProg ' for camera communication SerialOpen(ComC5,115200,0,0,1000,0) ' for base: progSig = status.ProgSignature n=1 'Main Scan Scan(60,Sec,1,0) 'Default CR1000X Datalogger Battery Voltage measurement 'BattV' Battery(Battery) 'Default CR1000X Datalogger Wiring Panel Temperature measurement 'PTemp_C' PanelTemp(PTemp_C,15000) 'Automated Water stage measurement. Must occur two minutes before 'actual storage time to get 11 measurements completed. If TimeIntoInterval (13,15,Min) Then SR50ATCtrl = True EndIf 'Set this flag to true to get the initial distance from the SR50AT 'to the ground. If SR50AT_MID Then SR50ATCtrl = True 'Logic to make 11 water stage measurements, sort them, and store 'the corrected values. If SR50ATCtrl Then 'SR50AT Sonic Ranging Sensor (SDI-12 Output) measurements 'MDT, MQ, & MAir SDI12Recorder(SR50AT_M(),SR50__CP,"0","M3!",1,0) 'Load the array to be sorted. SR50AT(n,1) = SR50AT_M(1) SR50AT(n,2) = SR50AT_M(2) SR50AT(n,3) = SR50AT_M(3) n += 1 If n > 11 Then n = 1 SR50ATCtrl = False SortSpa (Result_SR50AT(1,1),11,SR50AT(1,1),2) TCDT = Result_SR50AT(6,1) Q = Result_SR50AT(6,2) AT = Result_SR50AT(6,3) If SR50AT_MID Then Inital_Dist = TCDT SR50AT_MID = False EndIf Stage = Inital_Dist - TCDT EndIf EndIf 'CS106 Barometric Pressure Sensor measurement 'Pb' If TimeIntoInterval(59,60,Min) Then PortSet(C3,1) If TimeIntoInterval(0,60,Min) Then VoltSE(Pb,1,mV5000,1,True,0,15000,0.240,500) PortSet(C3,0) EndIf 'SW12 Timed Control 'Turn ON SW12 between 0000 hours and 2359 hours If TimeIsBetween(56,30,60,Min) Then SW12State=True 'Turn OFF SW12 only if time runs out and ComRS232 is not active ElseIf (ComPortIsActive(ComRS232)=False) Then SW12State=False EndIf 'Always turn OFF SW12 if battery drops below 12.2 volts If Battery<12.2 Then SW12State=False 'Set SW12_1 to the state of 'SW12State' variable SW12(SW12_1,SW12State,0) 'Call Data Tables and Store Data CallTable Hydro CallTable HrlyDiag NextScan SlowSequence Do Delay(1,10,Sec) FTPResult=FTPClient ("snobold.ine.uaf.edu","ftpuser","AKS1bridge","Hydro","AKS1_Hydro.dat",9,0,60,Min,-1008) FTPResult2=FTPClient ("snobold.ine.uaf.edu","ftpuser","AKS1bridge","HrlyDiag","AKS1_HrlyDiag.dat",9,0,60,Min,-1008) Loop EndProg