// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright 2024 Raritan Inc. All rights reserved.
//
// This file was generated by IdlC from Waveform.idl.

using System;
using System.Linq;
using LightJson;
using Com.Raritan.Idl;
using Com.Raritan.JsonRpc;
using Com.Raritan.Util;

#pragma warning disable 0108, 0219, 0414, 1591

namespace Com.Raritan.Idl.pdumodel {

  public class Waveform : ICloneable {
    public object Clone() {
      Waveform copy = new Waveform();
      copy.voltage = this.voltage;
      copy.current = this.current;
      copy.sampleRate = this.sampleRate;
      return copy;
    }

    public LightJson.JsonObject Encode() {
      LightJson.JsonObject json = new LightJson.JsonObject();
      json["voltage"] = new JsonArray(this.voltage.Select(
        _value => (JsonValue)(_value)));
      json["current"] = new JsonArray(this.current.Select(
        _value => (JsonValue)(_value)));
      json["sampleRate"] = this.sampleRate;
      return json;
    }

    public static Waveform Decode(LightJson.JsonObject json, Agent agent) {
      Waveform inst = new Waveform();
      inst.voltage = new System.Collections.Generic.List<double>(json["voltage"].AsJsonArray.Select(
        _value => (double)_value));
      inst.current = new System.Collections.Generic.List<double>(json["current"].AsJsonArray.Select(
        _value => (double)_value));
      inst.sampleRate = (int)json["sampleRate"];
      return inst;
    }

    public System.Collections.Generic.IEnumerable<double> voltage = new System.Collections.Generic.List<double>();
    public System.Collections.Generic.IEnumerable<double> current = new System.Collections.Generic.List<double>();
    public int sampleRate = 0;
  }
}
