Skip to content

Insert/Sample.tl

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#   Copyright (c) 2024 MBARI
#   MBARI Proprietary Information. Confidential. All Rights Reserved
#   Unauthorized copying or distribution of this file via any medium is strictly
#   prohibited.
#
#   WARNING - This file contains information whose export is restricted by the
#   Export Administration Act of 1979 (Title 50, U.S.C., App. 2401 et seq.), as
#   amended. Violations of these export laws are subject to severe civil and/or
#   criminal penalties.

aggregate Sample {
  """
  Take a water sample
  """

  arguments {
    CANONSamplerRotateOnly = 0 bool

    UseCANONSampler = Science:CANONSampler.loadAtStartup
      """
      Whether to use CANON Sampler to sample.
      """

    UseESP = Science:ESPComponent.loadAtStartup
      """
      Whether to use ESP to sample.
      """

    ESPCartridgeType = NaN count
      """
      Specifies ESP cartridge type code. Initialized to NaN.
      """

    CANONSamplerTriggerTimeout = 3 minute
      """
      How long to wait for a CANON Sampler sample to start.
      """

    CANONSamplerTimeout = Science:CANONSampler.sampleTimeout
      """
      How long to wait for a CANON Sampler sample to complete.
      """
  }

  output {
    DepthLogged = 0.0 meter

    TempLogged = 0.0 celsius

    ChlLogged = 0.0 microgram_per_liter
  }

  run when ( called )

  aggregate TriggerESP {
    run in sequence

    break if (
      not ( UseESP )
      or isNaN ( ESPCartridgeType )
    )

    assign in sequence DepthLogged = Universal:depth

    assign in sequence TempLogged = Universal:sea_water_temperature

    assign in sequence ChlLogged = Universal:mass_concentration_of_chlorophyll_in_sea_water

    syslog important "Trigger ESP sampling. DepthLogged, TempLogged, ChlLogged = "
         + DepthLogged~meter + ", " + TempLogged~celsius + ", " + ChlLogged~microgram_per_liter + "."

    behavior Science:ESPCartridgeSelect {
      run in sequence

      timeout duration=P1M

      set cartridgeType = ESPCartridgeType
    }

    readDatum {
      Science:ESPComponent.sampling
    }

    syslog important "Wait for ESP sampling to complete."

    readDatum {
      Science:ESPComponent.sample_number
    }
  }

  aggregate TriggerCANON {
    run in sequence

    break if ( not ( UseCANONSampler ) )

    assign in sequence DepthLogged = Universal:depth

    assign in sequence TempLogged = Universal:sea_water_temperature

    assign in sequence ChlLogged = Universal:mass_concentration_of_chlorophyll_in_sea_water

    syslog important "Trigger CANON sampling. DepthLogged, TempLogged, ChlLogged = "
         + DepthLogged~meter + ", " + TempLogged~celsius + ", " + ChlLogged~microgram_per_liter + "."

    assign in parallel Science:CANONSampler.sampleTimeout = CANONSamplerTimeout

    assign in parallel Science:CANONSampler.rotateOnly = CANONSamplerRotateOnly

    readDatum id="TriggerCANONSampler" {
      timeout duration=CANONSamplerTriggerTimeout {
        syslog important "Timed out triggering CANONSampler. Stopping mission."

        behavior Guidance:Execute {
          run in sequence

          set command = "stop"
        }
      }

      Science:CANONSampler.sampling
    }

    readDatum {
      timeout duration=CANONSamplerTimeout {
        syslog important "Timed out sampling with CANONSampler. Stopping mission."

        behavior Guidance:Execute {
          run in sequence

          set command = "stop"
        }
      }

      Science:CANONSampler.sample_number
    }
  }
}