// Proto file representing the LCCollection class

syntax = "proto3";

package ansys.api.edb.v1;

import "ansys/api/edb/v1/edb_messages.proto";
import "ansys/api/edb/v1/layer.proto";

enum LayerCollectionMode {
  LAMINATE = 0;
  OVERLAPPING = 1;
  MULTIZONE = 2;
}

enum DielectricMergingMethod {
  WEIGHTED_AVERAGE = 0;
  KRASZEWSKI = 1;
  WEIGHTED_CAPACITANCE = 2;
}

service LayerCollectionService {
  // Creates an empty LayerCollection
  rpc Create (LayerCollectionModeMessage) returns (EDBObjMessage) {}

  // Clone an existing LayerCollection
  rpc Clone (EDBObjMessage) returns (EDBObjMessage) {}

  // Get the LayerCollection mode
  rpc GetMode (EDBObjMessage) returns (LayerCollectionModeMessage) {}

  // Set the LayerCollection mode
  rpc SetMode (SetLayerCollectionModeMessage) returns (google.protobuf.Empty) {}

  // Adds the provided layers to the LayerCollection
  rpc AddLayers (AddLayersMessage) returns (google.protobuf.Empty) {}

  // Import a LayerCollection from a control file
  rpc ImportFromControlFile (ImportFromControlFileMessage) returns (google.protobuf.Empty) {}

  // Add a new layer to the LayerCollection
  rpc AddLayer (AddLayerMessage) returns (EDBObjMessage) {}

  // Check whether there is layer overlapping or gap for laminate stackup.
  // Check whether there is dielectric layer overlapping or gap for overlapping stackup.
  rpc IsValid (EDBObjMessage) returns (google.protobuf.BoolValue) {}

  // Finds a layer with the given name in the layer collection
  rpc FindByName (FindLayerByNameMessage) returns (EDBObjMessage) {}
  
  // Get top bottom stackup layers of specific type
  rpc GetTopBottomStackupLayers (GetTopBottomStackupLayersMessage) returns (TopBottomStackupLayersMessage) {}

  // Get a list of layers in the LayerCollection filtered by the given layer filter
  rpc GetLayers (GetLayersMessage) returns (EDBObjCollectionMessage) {}
  rpc StreamLayers (GetLayersMessage) returns (stream EDBObjCollectionMessage) {}

  // Get the layer's product property corresponding to the given product and attribute ids
  rpc GetProductProperty (GetProductPropertyMessage) returns (google.protobuf.StringValue) {}

  // Set the layer's product property corresponding to the given product and attribute ids
  rpc SetProductProperty (SetProductPropertyMessage) returns (google.protobuf.Empty) {}

  // Get a list of property ids associated with the layer for the given product
  rpc GetProductPropertyIds (GetProductPropertyIdsMessage) returns (ProductPropertyIdsMessage) {}

  // Merges the dielectric layers in a range of layers into one large dielectric layer that spans the elevation range of all merged dielectric layers
  rpc MergeDielectrics (MergeDielectricsMessage) returns (EDBObjMessage) {}

  // Retrieves a list of all zones in the LayerCollection
  rpc GetZoneIds (EDBObjMessage) returns (ZonesMessage) {}

  // Retrieves the name corresponding to the specified zone
  rpc GetZoneName (LayerCollectionZoneMessage) returns (google.protobuf.StringValue) {}

  // Set the name corresponding to the specified zone
  rpc SetZoneName (SetZoneNameMessage) returns (google.protobuf.Empty) {}

  // Inserts a new zone
  rpc InsertZone (InsertZoneMessage) returns (google.protobuf.Int64Value) {}

  // Removes a zone
  rpc RemoveZone (LayerCollectionZoneMessage) returns (google.protobuf.Empty) {}

  // Simplifies dielectric layers by splitting them at the boundaries of signal layers and merging them
  rpc SimplifyDielectricsForPhi (SimplifyDielectricsForPhiMessage) returns (EDBObjCollectionMessage) {}

  // Sets the zone to the layer and updates the layer in the collection
  rpc AddZoneToLayer (AddZoneToLayerMessage) returns (google.protobuf.Empty) {}
}

message LayerCollectionModeMessage {
  LayerCollectionMode mode = 1;
}

message SetLayerCollectionModeMessage {
  EDBObjMessage layer_collection = 1;
  LayerCollectionMode mode = 2;
}

message AddLayerAboveBelowMessage {
  string above_below_layer_name = 1;
  bool add_above = 2;
}

message AddLayerMessage {
  EDBObjMessage layer_collection = 1;
  EDBObjMessage layer = 2;
  oneof op_params {
    AddLayerAboveBelowMessage above_below_msg = 3;
	bool add_top = 4;
  }
}

message ImportFromControlFileMessage {
  EDBObjMessage layer_collection = 1;
  string control_file_path = 2;
  oneof optional_schema_path {
    string schema_path = 3;
  }
}

// Message for AddLayers
message AddLayersMessage {
  EDBObjMessage layer_collection = 1;
  repeated EDBObjMessage layers = 2;
}

// Message for FindByName
message FindLayerByNameMessage {
  EDBObjMessage layer_collection = 1;
  string name = 2;
}

message GetTopBottomStackupLayersMessage {
  EDBObjMessage layer_collection = 1;
  int64 layer_type_set = 2;
}

message TopBottomStackupLayersMessage {
  EDBObjMessage top_layer = 1;
  double top_layer_elevation = 2;
  EDBObjMessage bottom_layer = 3;
  double bottom_layer_elevation = 4;
}

message GetLayersMessage {
  EDBObjMessage layer_collection = 1;
  int64 layer_filter = 2;
}

message MergeDielectricsMessage {
  EDBObjMessage layer_collection = 1;
  EDBObjMessage layout = 2;
  string start_layer_name = 3;
  string end_layer_name = 4;
  DielectricMergingMethod merging_method = 5;
  string merged_layer_name = 6;
  string merged_mat_name = 7;
}

message LayerCollectionZoneMessage {
  EDBObjMessage layer_collection = 1;
  int64 zone = 2;
}

message SetZoneNameMessage {
  EDBObjMessage layer_collection = 1;
  int64 zone = 2;
  string zone_name = 3;
}

message InsertZoneMessage {
  EDBObjMessage layer_collection = 1;
  int64 copy_zone = 2;
}

message SimplifyDielectricsForPhiMessage {
  EDBObjMessage layer_collection = 1;
  EDBObjMessage database = 2;
  double layer_thickness_thresh = 3;
  DielectricMergingMethod merging_method = 4;
}

message AddZoneToLayerMessage {
  EDBObjMessage layer_collection = 1;
  EDBObjMessage layer = 2;
  int64 zone = 3;
  bool in_zone = 4;
}