import * as VScript from "http://172.16.0.12/bladerunner_sdk/vscript@2.5.2/deno/release/mod.ts";
import * as VAPI from "./mod.ts";
export const lift = {
  MicroEpoch: (
    _raw: [
      number,
      number,
      number | string,
      number,
      number,
      number,
      number,
      number,
      number,
      number,
      number,
      number,
      number,
      number,
      number,
      number,
      number,
      number,
    ],
    _socket: VScript.VSocket,
  ): MicroEpoch => {
    return {
      epoch_index: _raw[0],
      continuity_index: _raw[1],
      reference_time: VScript.VAPIHelpers.liftTimestamp(_raw[2], _socket),
      reference_counter: _raw[3],
      fpga_drift_to_clock: _raw[4],
      best_before: _raw[5],
      g23_98: VScript.VAPIHelpers.liftSeconds(_raw[6], _socket),
      g24: VScript.VAPIHelpers.liftSeconds(_raw[7], _socket),
      g25: VScript.VAPIHelpers.liftSeconds(_raw[8], _socket),
      g29_97: VScript.VAPIHelpers.liftSeconds(_raw[9], _socket),
      g30: VScript.VAPIHelpers.liftSeconds(_raw[10], _socket),
      g50: VScript.VAPIHelpers.liftSeconds(_raw[11], _socket),
      g59_94: VScript.VAPIHelpers.liftSeconds(_raw[12], _socket),
      g60: VScript.VAPIHelpers.liftSeconds(_raw[13], _socket),
      grtp_48k: VScript.VAPIHelpers.liftSeconds(_raw[14], _socket),
      grtp_90k: VScript.VAPIHelpers.liftSeconds(_raw[15], _socket),
      grtp_27m: VScript.VAPIHelpers.liftSeconds(_raw[16], _socket),
      grtp_96k: VScript.VAPIHelpers.liftSeconds(_raw[17], _socket),
    };
  },
  MicroEpochs: (
    _raw: [
      [
        number,
        number,
        number | string,
        number,
        number,
        number,
        number,
        number,
        number,
        number,
        number,
        number,
        number,
        number,
        number,
        number,
        number,
        number,
      ],
      [
        number,
        number,
        number | string,
        number,
        number,
        number,
        number,
        number,
        number,
        number,
        number,
        number,
        number,
        number,
        number,
        number,
        number,
        number,
      ],
      null | number,
      null | number,
    ],
    _socket: VScript.VSocket,
  ): MicroEpochs => {
    return {
      current: VAPI.PTPClock.lift.MicroEpoch(_raw[0], _socket),
      previous: VAPI.PTPClock.lift.MicroEpoch(_raw[1], _socket),
      delta_offset:
        _raw[2] === null
          ? null
          : VScript.VAPIHelpers.liftNanoseconds(_raw[2], _socket),
      delta_drift: _raw[3],
    };
  },
  AllStatisticsCounters: (
    _raw: [number, number, number, number, number, number],
    _socket: VScript.VSocket,
  ): AllStatisticsCounters => {
    return {
      missing_samples: _raw[0],
      bp_overall: _raw[1],
      bp_offset: _raw[2],
      bp_offset_errors: _raw[3],
      bp_drift: _raw[4],
      bp_drift_errors: _raw[5],
    };
  },
  AllParameters: (_raw: VScript.DataViews.Subtree<VScript.VSocket>) =>
    new AllParameters(_raw),
  AllParametersPllParsCalibrated: (
    _raw: VScript.DataViews.Subtree<VScript.VSocket>,
  ) => new AllParametersPllParsCalibrated(_raw),
  AllStatistics: (_raw: VScript.DataViews.Subtree<VScript.VSocket>) =>
    new AllStatistics(_raw),
} as const;
export const lower = {
  MicroEpoch: (
    _x: {
      epoch_index: VAPI.Time.MicroEpochIndex;

      /**
        Most clock control units continuously adjust their target's operating
        frequency until the time and/or frequency offset between source and
        target matches a user-defined value. These units require no data
        beyond frame rate, source type, frequency offset and offset.
        
        However, other clock operations implicitly guarantee synchronicity by
        rigidly linking their target's operating frequency to the source
        frequency. This implicit link may be broken when the timing source
        changes discontinuously. For example, an uncalibrated PTP clock may
        perform arbitrarily large offset and/or frequency jumps, yet after
        reachieving calibration will again report its offset to the internal
        PTP reference frame as 0.0 ± 0.0. To signal such 'timing shocks' to
        consumers, every timing source performing discontinuous changes in a
        way that breaks implicit synchronicity has to increase its
        continuity_index (with wraparound behaviour in the unlikely case of
        overflow).
      */
      continuity_index: VAPI.PTP.ContinuityIndex;
      reference_time: VAPI.Primitives.Timestamp;
      reference_counter: VAPI.Time.FreeRunningCounter;
      fpga_drift_to_clock: number;

      /**
        free-running counter value until which this micro epoch is considered
        reliable
      */
      best_before: VAPI.Time.FreeRunningCounter;

      /**
        grain-accurate (24Hz/1.001) offset to micro epoch
      */
      g23_98: VScript.Duration;

      /**
        grain-accurate (24Hz) offset to micro epoch
      */
      g24: VScript.Duration;

      /**
        grain-accurate (25Hz) offset to micro epoch
      */
      g25: VScript.Duration;

      /**
        grain-accurate (30Hz/1.001) offset to micro epoch
      */
      g29_97: VScript.Duration;

      /**
        grain-accurate (30Hz) offset to micro epoch
      */
      g30: VScript.Duration;

      /**
        grain-accurate (50Hz) offset to micro epoch
      */
      g50: VScript.Duration;

      /**
        grain-accurate (60Hz/1.001) offset to micro epoch
      */
      g59_94: VScript.Duration;

      /**
        grain-accurate (60Hz) offset to micro epoch
      */
      g60: VScript.Duration;

      /**
        grain-accurate (48kHz, 32bit RTP counter) media clock offset to micro
        epoch
      */
      grtp_48k: VScript.Duration;

      /**
        grain-accurate (90kHz, 32bit RTP counter) media clock offset to micro
        epoch
      */
      grtp_90k: VScript.Duration;

      /**
        grain-accurate (27MHz, 32bit RTP counter) media clock offset to micro
        epoch
      */
      grtp_27m: VScript.Duration;

      /**
        grain-accurate (96kHz, 32bit RTP counter) media clock offset to micro
        epoch
      */
      grtp_96k: VScript.Duration;
    },
    _socket: VScript.VSocket,
  ): [
    number,
    number,
    number | string,
    number,
    number,
    number,
    number,
    number,
    number,
    number,
    number,
    number,
    number,
    number,
    number,
    number,
    number,
    number,
  ] => [
    _x.epoch_index,
    _x.continuity_index,
    VScript.VAPIHelpers.lowerTimestamp(_x.reference_time, _socket),
    _x.reference_counter,
    _x.fpga_drift_to_clock,
    _x.best_before,
    VScript.VAPIHelpers.lowerSeconds(_x.g23_98, _socket),
    VScript.VAPIHelpers.lowerSeconds(_x.g24, _socket),
    VScript.VAPIHelpers.lowerSeconds(_x.g25, _socket),
    VScript.VAPIHelpers.lowerSeconds(_x.g29_97, _socket),
    VScript.VAPIHelpers.lowerSeconds(_x.g30, _socket),
    VScript.VAPIHelpers.lowerSeconds(_x.g50, _socket),
    VScript.VAPIHelpers.lowerSeconds(_x.g59_94, _socket),
    VScript.VAPIHelpers.lowerSeconds(_x.g60, _socket),
    VScript.VAPIHelpers.lowerSeconds(_x.grtp_48k, _socket),
    VScript.VAPIHelpers.lowerSeconds(_x.grtp_90k, _socket),
    VScript.VAPIHelpers.lowerSeconds(_x.grtp_27m, _socket),
    VScript.VAPIHelpers.lowerSeconds(_x.grtp_96k, _socket),
  ],
  MicroEpochs: (
    _x: {
      current: VAPI.PTPClock.MicroEpoch;
      previous: VAPI.PTPClock.MicroEpoch;
      delta_offset: null | VScript.Duration;
      delta_drift: null | number;
    },
    _socket: VScript.VSocket,
  ): [
    [
      number,
      number,
      number | string,
      number,
      number,
      number,
      number,
      number,
      number,
      number,
      number,
      number,
      number,
      number,
      number,
      number,
      number,
      number,
    ],
    [
      number,
      number,
      number | string,
      number,
      number,
      number,
      number,
      number,
      number,
      number,
      number,
      number,
      number,
      number,
      number,
      number,
      number,
      number,
    ],
    null | number,
    null | number,
  ] => [
    VAPI.PTPClock.lower.MicroEpoch(_x.current, _socket),
    VAPI.PTPClock.lower.MicroEpoch(_x.previous, _socket),
    _x.delta_offset === null
      ? null
      : VScript.VAPIHelpers.lowerNanoseconds(_x.delta_offset, _socket),
    _x.delta_drift,
  ],
  AllStatisticsCounters: (
    _x: {
      missing_samples: VAPI.Primitives.SaturatingCounter16;
      bp_overall: VAPI.Primitives.SaturatingSignedCounter16;
      bp_offset: VAPI.Primitives.SaturatingSignedCounter16;
      bp_offset_errors: VAPI.Primitives.SaturatingSignedCounter16;
      bp_drift: VAPI.Primitives.SaturatingSignedCounter16;
      bp_drift_errors: VAPI.Primitives.SaturatingSignedCounter16;
    },
    _socket: VScript.VSocket,
  ): [number, number, number, number, number, number] => [
    _x.missing_samples,
    _x.bp_overall,
    _x.bp_offset,
    _x.bp_offset_errors,
    _x.bp_drift,
    _x.bp_drift_errors,
  ],
  AllParameters: (_x: AllParameters) => _x.raw.kwl,
  AllParametersPllParsCalibrated: (_x: AllParametersPllParsCalibrated) =>
    _x.raw.kwl,
  AllStatistics: (_x: AllStatistics) => _x.raw.kwl,
} as const;
export interface MicroEpoch {
  epoch_index: VAPI.Time.MicroEpochIndex;

  /**
    Most clock control units continuously adjust their target's operating
    frequency until the time and/or frequency offset between source and
    target matches a user-defined value. These units require no data beyond
    frame rate, source type, frequency offset and offset.
    
    However, other clock operations implicitly guarantee synchronicity by
    rigidly linking their target's operating frequency to the source
    frequency. This implicit link may be broken when the timing source
    changes discontinuously. For example, an uncalibrated PTP clock may
    perform arbitrarily large offset and/or frequency jumps, yet after
    reachieving calibration will again report its offset to the internal PTP
    reference frame as 0.0 ± 0.0. To signal such 'timing shocks' to
    consumers, every timing source performing discontinuous changes in a way
    that breaks implicit synchronicity has to increase its continuity_index
    (with wraparound behaviour in the unlikely case of overflow).
  */
  continuity_index: VAPI.PTP.ContinuityIndex;
  reference_time: VAPI.Primitives.Timestamp;
  reference_counter: VAPI.Time.FreeRunningCounter;
  fpga_drift_to_clock: number;

  /**
    free-running counter value until which this micro epoch is considered
    reliable
  */
  best_before: VAPI.Time.FreeRunningCounter;

  /**
    grain-accurate (24Hz/1.001) offset to micro epoch
  */
  g23_98: VScript.Duration;

  /**
    grain-accurate (24Hz) offset to micro epoch
  */
  g24: VScript.Duration;

  /**
    grain-accurate (25Hz) offset to micro epoch
  */
  g25: VScript.Duration;

  /**
    grain-accurate (30Hz/1.001) offset to micro epoch
  */
  g29_97: VScript.Duration;

  /**
    grain-accurate (30Hz) offset to micro epoch
  */
  g30: VScript.Duration;

  /**
    grain-accurate (50Hz) offset to micro epoch
  */
  g50: VScript.Duration;

  /**
    grain-accurate (60Hz/1.001) offset to micro epoch
  */
  g59_94: VScript.Duration;

  /**
    grain-accurate (60Hz) offset to micro epoch
  */
  g60: VScript.Duration;

  /**
    grain-accurate (48kHz, 32bit RTP counter) media clock offset to micro
    epoch
  */
  grtp_48k: VScript.Duration;

  /**
    grain-accurate (90kHz, 32bit RTP counter) media clock offset to micro
    epoch
  */
  grtp_90k: VScript.Duration;

  /**
    grain-accurate (27MHz, 32bit RTP counter) media clock offset to micro
    epoch
  */
  grtp_27m: VScript.Duration;

  /**
    grain-accurate (96kHz, 32bit RTP counter) media clock offset to micro
    epoch
  */
  grtp_96k: VScript.Duration;
}
export interface MicroEpochs {
  current: VAPI.PTPClock.MicroEpoch;
  previous: VAPI.PTPClock.MicroEpoch;
  delta_offset: null | VScript.Duration;
  delta_drift: null | number;
}
/**
  when `mode` is set to `LockToInput`, the PTP clock will attempt to
  synchronize with the external time source designated by `input`. This is
  the default setting and typically the only option suitable for production
  use.
  
  When `mode` is set to `UseInternalOscillator`, the PTP clock will first
  reset its speed to the nominal clock rate generated by its internal
  oscillator, and in the following suspend all clock control operations.
  Likewise, `Disconnect` suspends all clock control operations but in
  contrast to `UseInternalOscillator` continues to run at the current value
  of `relative_clock_speed`
*/
export type Mode = "LockToInput" | "UseInternalOscillator" | "Disconnect";
export type State =
  | "FreeRun"
  | "Uncalibrated"
  | "Calibrated"
  | "CalibratedAndLocked";
/**
  counter values may be negative to indicate deviations beyond the holdover
  threshold
*/
export interface AllStatisticsCounters {
  missing_samples: VAPI.Primitives.SaturatingCounter16;
  bp_overall: VAPI.Primitives.SaturatingSignedCounter16;
  bp_offset: VAPI.Primitives.SaturatingSignedCounter16;
  bp_offset_errors: VAPI.Primitives.SaturatingSignedCounter16;
  bp_drift: VAPI.Primitives.SaturatingSignedCounter16;
  bp_drift_errors: VAPI.Primitives.SaturatingSignedCounter16;
}
/**
  If set to `Reset`, a calibration timeout will reset the clock controller's
  internal state and all estimates currently held by PTP agents. If set to
  `ResetAggressively`, agents will be reinitialized completely, clearing also
  their currently selected best masters and any other transient data they may
  hold
*/
export type AllParametersOnCalibrationTimeout = "Reset" | "ResetAggressively";
export class AllParameters
  implements VScript.Referenceable<"PTPClock::Data::All::Parameters">
{
  readonly type_identifier = "PTPClock::Data::All::Parameters" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}

  /**
    use this as the default UTC/TAI offset for time sources that don't supply
    this information on their own (i.e., PTP agents enslaved to a
    sufficiently well-informed Master). Following the PTP standard, this
    denotes the TAI-to-UTC offset and hence should always be positive.
  */
  get default_utc_offset_seconds(): VScript.rwKeyword<
    VScript.VSocket,
    number,
    number,
    number,
    number,
    VAPI.PTPClock.AllParameters
  > {
    return new VScript.rwKeyword<
      VScript.VSocket,
      number,
      number,
      number,
      number,
      VAPI.PTPClock.AllParameters
    >(
      this,
      "default_utc_offset_seconds" as VScript.SysName,
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      null,
    );
  }
  get locking_policy(): VScript.rwKeyword<
    VScript.VSocket,
    VAPI.Servos.LockingPolicy,
    VAPI.Servos.LockingPolicy,
    VAPI.Servos.LockingPolicy,
    VAPI.Servos.LockingPolicy,
    VAPI.PTPClock.AllParameters
  > {
    return new VScript.rwKeyword<
      VScript.VSocket,
      VAPI.Servos.LockingPolicy,
      VAPI.Servos.LockingPolicy,
      VAPI.Servos.LockingPolicy,
      VAPI.Servos.LockingPolicy,
      VAPI.PTPClock.AllParameters
    >(
      this,
      "locking_policy" as VScript.SysName,
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      null,
    );
  }
  get pll_pars_calibrated() {
    return VAPI.PTPClock.lift.AllParametersPllParsCalibrated(
      VScript.VAPIHelpers.subtree_child_checked(
        this.raw,
        2,
        "pll_pars_calibrated",
      ),
    );
  }
  get pll_pars_uncalibrated(): VScript.rwKeyword<
    VScript.VSocket,
    [number, number, number, number, number],
    [number, number, number, number, number],
    VAPI.Servos.PLLParameters,
    VAPI.Servos.PLLParameters,
    VAPI.PTPClock.AllParameters
  > {
    return new VScript.rwKeyword<
      VScript.VSocket,
      [number, number, number, number, number],
      [number, number, number, number, number],
      VAPI.Servos.PLLParameters,
      VAPI.Servos.PLLParameters,
      VAPI.PTPClock.AllParameters
    >(
      this,
      "pll_pars_uncalibrated" as VScript.SysName,
      {
        lift: VAPI.Servos.lift.PLLParameters,
        lower: VAPI.Servos.lower.PLLParameters,
      },
      {
        lift: VAPI.Servos.lift.PLLParameters,
        lower: VAPI.Servos.lower.PLLParameters,
      },
      null,
    );
  }
  get max_rel_acceleration(): VScript.rKeyword<
    VScript.VSocket,
    number,
    number,
    VAPI.PTPClock.AllParameters
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      number,
      number,
      VAPI.PTPClock.AllParameters
    >(this, "max_rel_acceleration" as VScript.SysName, {
      lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
      lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
    });
  }
  get max_allowed_offset(): VScript.rwKeyword<
    VScript.VSocket,
    number,
    number,
    VScript.Duration,
    VScript.Duration,
    VAPI.PTPClock.AllParameters
  > {
    return new VScript.rwKeyword<
      VScript.VSocket,
      number,
      number,
      VScript.Duration,
      VScript.Duration,
      VAPI.PTPClock.AllParameters
    >(
      this,
      "max_allowed_offset" as VScript.SysName,
      {
        lift: VScript.VAPIHelpers.liftSeconds,
        lower: VScript.VAPIHelpers.lowerSeconds,
      },
      {
        lift: VScript.VAPIHelpers.liftSeconds,
        lower: VScript.VAPIHelpers.lowerSeconds,
      },
      null,
    );
  }

  /**
    ignore incoming messages for this long after irregular clock adjustments
    and hard resets
  */
  get timeout_after_reset(): VScript.rwKeyword<
    VScript.VSocket,
    number,
    number,
    VScript.Duration,
    VScript.Duration,
    VAPI.PTPClock.AllParameters
  > {
    return new VScript.rwKeyword<
      VScript.VSocket,
      number,
      number,
      VScript.Duration,
      VScript.Duration,
      VAPI.PTPClock.AllParameters
    >(
      this,
      "timeout_after_reset" as VScript.SysName,
      {
        lift: VScript.VAPIHelpers.liftSeconds,
        lower: VScript.VAPIHelpers.lowerSeconds,
      },
      {
        lift: VScript.VAPIHelpers.liftSeconds,
        lower: VScript.VAPIHelpers.lowerSeconds,
      },
      null,
    );
  }
  get capture_threshold(): VScript.rwKeyword<
    VScript.VSocket,
    number,
    number,
    VScript.Duration,
    VScript.Duration,
    VAPI.PTPClock.AllParameters
  > {
    return new VScript.rwKeyword<
      VScript.VSocket,
      number,
      number,
      VScript.Duration,
      VScript.Duration,
      VAPI.PTPClock.AllParameters
    >(
      this,
      "capture_threshold" as VScript.SysName,
      {
        lift: VScript.VAPIHelpers.liftSeconds,
        lower: VScript.VAPIHelpers.lowerSeconds,
      },
      {
        lift: VScript.VAPIHelpers.liftSeconds,
        lower: VScript.VAPIHelpers.lowerSeconds,
      },
      null,
    );
  }
  get convergence_threshold(): VScript.rwKeyword<
    VScript.VSocket,
    number,
    number,
    VScript.Duration,
    VScript.Duration,
    VAPI.PTPClock.AllParameters
  > {
    return new VScript.rwKeyword<
      VScript.VSocket,
      number,
      number,
      VScript.Duration,
      VScript.Duration,
      VAPI.PTPClock.AllParameters
    >(
      this,
      "convergence_threshold" as VScript.SysName,
      {
        lift: VScript.VAPIHelpers.liftSeconds,
        lower: VScript.VAPIHelpers.lowerSeconds,
      },
      {
        lift: VScript.VAPIHelpers.liftSeconds,
        lower: VScript.VAPIHelpers.lowerSeconds,
      },
      null,
    );
  }

  /**
    Don't perform jumps unless (i) `|input.offset.value| <
    capture_threshold`, or (ii) `|input.offset.error| <
    relative_accuracy_threshold * |input.offset.value|`. Set to exactly zero
    to disable condition (ii).
  */
  get relative_accuracy_threshold(): VScript.rwKeyword<
    VScript.VSocket,
    number,
    number,
    number,
    number,
    VAPI.PTPClock.AllParameters
  > {
    return new VScript.rwKeyword<
      VScript.VSocket,
      number,
      number,
      number,
      number,
      VAPI.PTPClock.AllParameters
    >(
      this,
      "relative_accuracy_threshold" as VScript.SysName,
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      null,
    );
  }
  get capture_drift_threshold(): VScript.rwKeyword<
    VScript.VSocket,
    number,
    number,
    number,
    number,
    VAPI.PTPClock.AllParameters
  > {
    return new VScript.rwKeyword<
      VScript.VSocket,
      number,
      number,
      number,
      number,
      VAPI.PTPClock.AllParameters
    >(
      this,
      "capture_drift_threshold" as VScript.SysName,
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      null,
    );
  }
  get convergence_drift_threshold(): VScript.rwKeyword<
    VScript.VSocket,
    number,
    number,
    number,
    number,
    VAPI.PTPClock.AllParameters
  > {
    return new VScript.rwKeyword<
      VScript.VSocket,
      number,
      number,
      number,
      number,
      VAPI.PTPClock.AllParameters
    >(
      this,
      "convergence_drift_threshold" as VScript.SysName,
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      null,
    );
  }

  /**
    Don't perform jumps unless (i) `|input.drift.value| <
    capture_drift_threshold`, or (ii) `|input.drift.error| <
    relative_drift_accuracy_threshold * |input.drift.value|`. Set to exactly
    zero to disable condition (ii).
  */
  get relative_drift_accuracy_threshold(): VScript.rwKeyword<
    VScript.VSocket,
    number,
    number,
    number,
    number,
    VAPI.PTPClock.AllParameters
  > {
    return new VScript.rwKeyword<
      VScript.VSocket,
      number,
      number,
      number,
      number,
      VAPI.PTPClock.AllParameters
    >(
      this,
      "relative_drift_accuracy_threshold" as VScript.SysName,
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      null,
    );
  }
  get promotion_threshold(): VScript.rwKeyword<
    VScript.VSocket,
    number,
    number,
    number,
    number,
    VAPI.PTPClock.AllParameters
  > {
    return new VScript.rwKeyword<
      VScript.VSocket,
      number,
      number,
      number,
      number,
      VAPI.PTPClock.AllParameters
    >(
      this,
      "promotion_threshold" as VScript.SysName,
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      null,
    );
  }
  get demotion_threshold(): VScript.rwKeyword<
    VScript.VSocket,
    number,
    number,
    number,
    number,
    VAPI.PTPClock.AllParameters
  > {
    return new VScript.rwKeyword<
      VScript.VSocket,
      number,
      number,
      number,
      number,
      VAPI.PTPClock.AllParameters
    >(
      this,
      "demotion_threshold" as VScript.SysName,
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      null,
    );
  }

  /**
    Determines how long the PTP clock may remain uncalibrated before it
    resets itself
  */
  get calibration_timeout(): VScript.rwKeyword<
    VScript.VSocket,
    number,
    number,
    VScript.Duration,
    VScript.Duration,
    VAPI.PTPClock.AllParameters
  > {
    return new VScript.rwKeyword<
      VScript.VSocket,
      number,
      number,
      VScript.Duration,
      VScript.Duration,
      VAPI.PTPClock.AllParameters
    >(
      this,
      "calibration_timeout" as VScript.SysName,
      {
        lift: VScript.VAPIHelpers.liftNanoseconds,
        lower: VScript.VAPIHelpers.lowerNanoseconds,
      },
      {
        lift: VScript.VAPIHelpers.liftNanoseconds,
        lower: VScript.VAPIHelpers.lowerNanoseconds,
      },
      null,
    );
  }

  /**
    If set to `Reset`, a calibration timeout will reset the clock
    controller's internal state and all estimates currently held by PTP
    agents. If set to `ResetAggressively`, agents will be reinitialized
    completely, clearing also their currently selected best masters and any
    other transient data they may hold
  */
  get on_calibration_timeout(): VScript.rwKeyword<
    VScript.VSocket,
    VAPI.PTPClock.AllParametersOnCalibrationTimeout,
    VAPI.PTPClock.AllParametersOnCalibrationTimeout,
    VAPI.PTPClock.AllParametersOnCalibrationTimeout,
    VAPI.PTPClock.AllParametersOnCalibrationTimeout,
    VAPI.PTPClock.AllParameters
  > {
    return new VScript.rwKeyword<
      VScript.VSocket,
      VAPI.PTPClock.AllParametersOnCalibrationTimeout,
      VAPI.PTPClock.AllParametersOnCalibrationTimeout,
      VAPI.PTPClock.AllParametersOnCalibrationTimeout,
      VAPI.PTPClock.AllParametersOnCalibrationTimeout,
      VAPI.PTPClock.AllParameters
    >(
      this,
      "on_calibration_timeout" as VScript.SysName,
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      null,
    );
  }

  /**
    use this to override `output.characteristics.offset_type`; may be useful
    to, e.g., redistribute BlackBurst-derived local time as (absolute) PTP
    time
  */
  get offset_type_override(): VScript.rwKeyword<
    VScript.VSocket,
    null | VAPI.Time.OffsetType,
    null | VAPI.Time.OffsetType,
    null | VAPI.Time.OffsetType,
    null | VAPI.Time.OffsetType,
    VAPI.PTPClock.AllParameters
  > {
    return new VScript.rwKeyword<
      VScript.VSocket,
      null | VAPI.Time.OffsetType,
      null | VAPI.Time.OffsetType,
      null | VAPI.Time.OffsetType,
      null | VAPI.Time.OffsetType,
      VAPI.PTPClock.AllParameters
    >(
      this,
      "offset_type_override" as VScript.SysName,
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      {
        lift: (x: any /* FIXME */, _: VScript.VSocket) => x,
        lower: (x: any /* FIXME */, _: VScript.VSocket) => x,
      },
      null,
    );
  }

  /**
    after discontinuous clock changes, the PTPClock will automatically
    discard newly incoming messages for a short while to avoid locking onto
    obsolete data. In some scenarios (such as redundant analogref-derived
    master setups), it may make sense to further increase this timeout to
    higher constant values; in case of doubt, best leave this setting at its
    default value of 0ns.
  */
  get minimum_timeout_after_jump(): VScript.rwKeyword<
    VScript.VSocket,
    number,
    number,
    VScript.Duration,
    VScript.Duration,
    VAPI.PTPClock.AllParameters
  > {
    return new VScript.rwKeyword<
      VScript.VSocket,
      number,
      number,
      VScript.Duration,
      VScript.Duration,
      VAPI.PTPClock.AllParameters
    >(
      this,
      "minimum_timeout_after_jump" as VScript.SysName,
      {
        lift: VScript.VAPIHelpers.liftNanoseconds,
        lower: VScript.VAPIHelpers.lowerNanoseconds,
      },
      {
        lift: VScript.VAPIHelpers.liftNanoseconds,
        lower: VScript.VAPIHelpers.lowerNanoseconds,
      },
      null,
    );
  }
}
export class AllParametersPllParsCalibrated
  implements
    VScript.Referenceable<"PTPClock::Data::All::Parameters::PllParsCalibrated">
{
  readonly type_identifier =
    "PTPClock::Data::All::Parameters::PllParsCalibrated" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}
  get inner_corridor(): VScript.rwKeyword<
    VScript.VSocket,
    [number, number, number, number, number],
    [number, number, number, number, number],
    VAPI.Servos.PLLParameters,
    VAPI.Servos.PLLParameters,
    VAPI.PTPClock.AllParametersPllParsCalibrated
  > {
    return new VScript.rwKeyword<
      VScript.VSocket,
      [number, number, number, number, number],
      [number, number, number, number, number],
      VAPI.Servos.PLLParameters,
      VAPI.Servos.PLLParameters,
      VAPI.PTPClock.AllParametersPllParsCalibrated
    >(
      this,
      "inner_corridor" as VScript.SysName,
      {
        lift: VAPI.Servos.lift.PLLParameters,
        lower: VAPI.Servos.lower.PLLParameters,
      },
      {
        lift: VAPI.Servos.lift.PLLParameters,
        lower: VAPI.Servos.lower.PLLParameters,
      },
      null,
    );
  }
  get outer(): VScript.rwKeyword<
    VScript.VSocket,
    [number, number, number, number, number],
    [number, number, number, number, number],
    VAPI.Servos.PLLParameters,
    VAPI.Servos.PLLParameters,
    VAPI.PTPClock.AllParametersPllParsCalibrated
  > {
    return new VScript.rwKeyword<
      VScript.VSocket,
      [number, number, number, number, number],
      [number, number, number, number, number],
      VAPI.Servos.PLLParameters,
      VAPI.Servos.PLLParameters,
      VAPI.PTPClock.AllParametersPllParsCalibrated
    >(
      this,
      "outer" as VScript.SysName,
      {
        lift: VAPI.Servos.lift.PLLParameters,
        lower: VAPI.Servos.lower.PLLParameters,
      },
      {
        lift: VAPI.Servos.lift.PLLParameters,
        lower: VAPI.Servos.lower.PLLParameters,
      },
      null,
    );
  }
}
export class AllStatistics
  implements VScript.Referenceable<"PTPClock::Data::All::Statistics">
{
  readonly type_identifier = "PTPClock::Data::All::Statistics" as const;
  constructor(readonly raw: VScript.DataViews.Subtree<VScript.VSocket>) {}

  /**
    counter values may be negative to indicate deviations beyond the holdover
    threshold
  */
  get counters(): VScript.rKeyword<
    VScript.VSocket,
    [number, number, number, number, number, number],
    VAPI.PTPClock.AllStatisticsCounters,
    VAPI.PTPClock.AllStatistics
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      [number, number, number, number, number, number],
      VAPI.PTPClock.AllStatisticsCounters,
      VAPI.PTPClock.AllStatistics
    >(this, "counters" as VScript.SysName, {
      lift: VAPI.PTPClock.lift.AllStatisticsCounters,
      lower: VAPI.PTPClock.lower.AllStatisticsCounters,
    });
  }
  get attempting_calibration_for(): VScript.rKeyword<
    VScript.VSocket,
    null | number,
    null | VScript.Duration,
    VAPI.PTPClock.AllStatistics
  > {
    return new VScript.rKeyword<
      VScript.VSocket,
      null | number,
      null | VScript.Duration,
      VAPI.PTPClock.AllStatistics
    >(this, "attempting_calibration_for" as VScript.SysName, {
      lift: VScript.VAPIHelpers.liftOrLowerNullable(
        VScript.VAPIHelpers.liftNanoseconds,
      ),
      lower: VScript.VAPIHelpers.liftOrLowerNullable(
        VScript.VAPIHelpers.lowerNanoseconds,
      ),
    });
  }
}
export const Enums = {
  State: [
    "FreeRun",
    "Uncalibrated",
    "Calibrated",
    "CalibratedAndLocked",
  ] as State[],
  Mode: ["LockToInput", "UseInternalOscillator", "Disconnect"] as Mode[],
} as const;
