// Copyright 2023-2024 ANSYS, Inc. Unauthorized use, distribution, or duplication is prohibited.
syntax = "proto3";

import "ansys/api/sherlock/v0/SherlockCommonService.proto";

option java_package = "sherlock.grpc";
option java_outer_classname = "SherlockLayerServiceProto";

/**
 * Request to list the valid mount point types.
 */
message GetMountPointTypesRequest {
}

/**
 * Represents a list of valid mount point types.
 */
message GetMountPointTypesResponse {
  ReturnCode returnCode 	= 1;	// Status code of response.
  repeated string type 		= 2;	// Mount Point Type.
}

/**
 * Request to list the valid mount point shape types.
 */
message GetMountPointShapeTypesRequest {
  string mountPointType		= 1;	// Mount Point Type. Supported values are: Mount Hole, Mount Pad, Standoff, and Support Pin.
}

/**
 * Represents a list of valid mount point shape types.
 */
message GetMountPointShapeTypesResponse {
  ReturnCode returnCode 	= 1;	// Status code of response.
  repeated string type 		= 2;	// Mount Point Shape Type.
}

/**
 * Request to list the valid mount point sides.
 */
message GetMountPointSidesRequest {
}

/**
 * Represents a list of valid mount point sides.
 */
message GetMountPointSidesResponse {
  ReturnCode returnCode		= 1;	// Status code of response.
  repeated string side		= 2;	// Mount Point side.
}

/**
 * Request to list the valid mount point units.
 */
message GetMountPointUnitsRequest {
}

/**
 * Represents a list of valid mount point units.
 */
message GetMountPointUnitsResponse {
  ReturnCode returnCode 	= 1;	// Status code of response.
  repeated string units		= 2;	// Mount Point units.
}

/**
 * Request to list the valid mount point boundaries.
 */
message GetMountPointBoundariesRequest {
}

/**
 * Represents a list of valid mount point boundaries.
 */
message GetMountPointBoundariesResponse {
  ReturnCode returnCode 	= 1;	// Status code of response.
  repeated string boundary	= 2;	// Mount Point boundary.
}

/**
 * Request to list the valid mount point chassis materials.
 */
message GetMountPointChassisMaterialsRequest {
}

/**
 * Represents a list of valid mount point chassis materials.
 */
message GetMountPointChassisMaterialsResponse {
  ReturnCode returnCode 			= 1;	// Status code of response.
  repeated string chassisMaterial	= 2;	// Mount Point chassis material.
}

/**
 * Request to delete all mount points in specific CCA of specific project.
 */
message DeleteAllMountPointsRequest {
  string project = 1;	// Sherlock project name.
  string ccaName = 2;	// The CCA name.
}

/**
 * Request to export all mount points and their properties into a CSV formatted file.
 */
message ExportAllMountPointsRequest {
  string project 	= 1;	// Sherlock project name.
  string ccaName 	= 2;	// The CCA name.
  string units 		= 3;	// Units used in exporting.
  string filePath 	= 4;	// The filepath of the CSV file to be exported.
}

/**
 * Request to export all ICT fixtures and their properties into a CSV formatted file.
 */
message ExportAllICTFixturesRequest {
  string project 	= 1;	// Sherlock project name.
  string ccaName 	= 2;	// The CCA name.
  string units 		= 3;	// Units used in exporting.
  string filePath 	= 4;	// The filepath of the CSV file to be exported.
}

/**
 * Request to list the valid mount point chassis materials.
 */
message GetMountPointsPropertiesRequest {
  string project				= 1;	// Sherlock project name.
  string ccaName				= 2;	// The CCA name.
  string mountPointIDs			= 3;	// A comma separated list of mount point id for a list of mount point, or a mount id for one part.
}

/**
 * Represents a list of valid mount point properties.
 */
message GetMountPointsPropertiesResponse {
  ReturnCode returnCode 		= 1;	// Status code of response.
  repeated MountPointProperties mountPointsProperties 	= 2;	// Mount point properties.
}

/**
 * Properties of mount point, the properties may varies from the mount point type and mount point shape.
 */	
message MountPointProperties{
  string ID					= 1;	// Mount point ID.
  string type				= 2;	// Mount point type.
  string shape				= 3;	// Shape type.
  string units 				= 4;	// Mount point units.
  string x 					= 5;	// Center X.
  string y 					= 6;	// Center Y.
  string length 			= 7;	// Length.
  string width				= 8;	// Width.
  string diameter			= 9;	// Diameter.
  string nodes				= 10;	// # of nodes.
  string rotation			= 11;	// Rotation in degrees.
  string side 				= 12;	// Mount point side.
  string height 			= 13;	// Mount point height.
  string material 			= 14;	// Mount point material.
  string boundary			= 15;	// Boundary Pt(s).
  string constraints		= 16; 	// FEA constraints.
  string polygon			= 17;	// Coordinates of points.
  string state				= 18;	// Mount point state.
  string chassisMaterial 	= 19;	// Chassis material.
}

/**
 * Request to update mount points properties of a CCA from a CSV formatted file.
 */
message UpdateMountPointsByFileRequest {
  string project 										= 1;	// Sherlock project name.
  string ccaName 										= 2;	// The CCA name.
  string filePath 										= 3;	// The filepath of the CSV file containing the mount points properties.
}

/**
 * Request to update mount points properties of a CCA from a CSV formatted file.
 */
message UpdateMountPointsRequest {
  string project 										= 1;	// Sherlock project name.
  string ccaName 										= 2;	// The CCA name.
  repeated MountPointProperties mountPointsProperties 	= 3;	// Mount point properties.
}

/**
 * Contains the status of the update as well as all the update error messages.
 */
message UpdateMountPointsResponse {
  ReturnCode returnCode 		= 1;	// Status code of response.
  repeated string updateError	= 2;	// Mount Points update error messages.
}

/**
 * Request to delete all ICT fixtures in specific CCA of specific project.
 */
message DeleteAllICTFixturesRequest {
  string project = 1;	// Sherlock project name.
  string ccaName = 2;	// The CCA name.
}

/**
 * Request to delete all ICT fixtures in specific CCA of specific project.
 */
message DeleteAllTestPointsRequest {
  string project = 1;	// Sherlock project name.
  string ccaName = 2;	// The CCA name.
}

/**
 * Request to update ICT fixtures properties of a CCA from a CSV formatted file.
 */
message UpdateICTFixturesByFileRequest {
  string project 										= 1;	// Sherlock project name.
  string ccaName 										= 2;	// The CCA name.
  string filePath 										= 3;	// The filepath of the CSV file containing the ICT fixtures properties.
}

/**
 * Contains the status of the update as well as all the update error messages.
 */
message UpdateICTFixturesResponse {
  ReturnCode returnCode 		= 1;	// Status code of response.
  repeated string updateError	= 2;	// ICT fixtures update error messages.
}

/**
 * Request to export all test points and their properties into a CSV formatted file.
 */
message ExportAllTestPointsRequest {
  string project 		= 1;	// Sherlock project name.
  string ccaName 		= 2;	// The CCA name.
  string lengthUnits 	= 3;	// Length Units used in exporting.
  string displacementUnits = 4;	// Displacement Units used in exporting.
  string forceUnits 	= 5;	// Force Units used in exporting.
  string filePath 		= 6;	// The filepath of the CSV file to be exported.
}

/**
 * Request to update test points properties of a CCA from a CSV formatted file.
 */
message UpdateTestPointsByFileRequest {
  string project 										= 1;	// Sherlock project name.
  string ccaName 										= 2;	// The CCA name.
  string filePath 										= 3;	// The filepath of the CSV file containing the test points properties.
}

/**
 * Contains the status of the update as well as all the update error messages.
 */
message UpdateTestPointsResponse {
  ReturnCode returnCode 		= 1;	// Status code of response.
  repeated string updateError	= 2;	// Test Points update error messages.
}

message PolygonalShape {
    
  message Point {
    double x = 1;					// The x coordinate of the point.
    double y = 2;					// The y coordinate of the point.
  }
    
  repeated Point points = 1;		// The points used to define the polygonal shape, must be >= 3.
  optional double rotation = 2;		// The rotation of the shape in degrees.
}
  
message RectangularShape {
  optional double length = 1;		// The length of the rectangle.
  optional double width = 2;		// The width of the rectangle.
  optional double centerX = 3;		// The x coordinate of the center of the rectangle.
  optional double centerY = 4;		// The y coordinate of the center of the rectangle.
  optional double rotation = 5;		// The rotation of the rectangle in degrees.
}
  
message SlotShape {
  optional double length = 1;		// The length of the slot shape.
  optional double width = 2;		// The width of the slot shape.
  optional uint32 nodeCount = 3;	// The number of nodes.
  optional double centerX = 4;		// The x coordinate of the center of the slot shape.
  optional double centerY = 5;		// The x coordinate of the center of the slot shape.
  optional double rotation = 6;		// The rotation of the shape in degrees.
}
  
message CircularShape {
  optional double diameter = 1;		// The diameter of the circle.
  optional uint32 nodeCount = 2;	// The number of nodes.
  optional double centerX = 3;		// The x coordinate of the center of the circle.
  optional double centerY = 4;		// The x coordinate of the center of the circle.
  optional double rotation = 5;		// The rotation of the shape in degrees.
}
  
message PCBShape {
}

/**
 * Request to add a potting region.
 */
message AddPottingRegionRequest {  
  message PottingRegion {
    string ccaName = 1;							// The name of the CCA.
    optional string pottingID = 2;				// The potting ID, must be unique.
    optional string pottingSide = 3;			// The potting side, options are "TOP", "BOT", or "BOTTOM".
    optional string pottingMaterial = 4;		// The potting material.
    optional string pottingUnits = 5;			// The units to use for the potting region.
    optional double pottingThickness = 6;		// The potting thickness.
    optional double pottingStandoff = 7;		// The potting standoff.
  
    oneof Shape {
      PolygonalShape polygonalShape = 8;		// Used to add a region with a polygonal shape.
  	  RectangularShape rectangularShape = 9;	// Used to add a region with a rectangular shape.
  	  SlotShape slotShape = 10;					// Used to add a region with a slot shape.
  	  CircularShape circularShape = 11;			// Used to add a region with a circular shape.
  	  PCBShape pCBShape = 12;					// Used to add a region with a PCB shape.
    }
  }
  
  string project = 1;							// The name of the Sherlock project to add the potting regions to.
  repeated PottingRegion pottingRegions = 2;	// The potting regions to add.
}

message ModelingRegion {
	enum ModelingMode {
		Enabled = 0;		// Use the modeling region.
  		Disabled = 1;		// Ignore the modeling region.
  		Excluded = 2;		// Don't generate any elements for the region.
  	}
	enum ElementOrder {
		First_Order = 0;		// First order (Linear) 3D elements should be created for the PCB in the modeling region.
		Second_Order = 1;	// Second order (Quadratic) 3D elements should be created for the PCB in the modeling region.
		Solid_Shell = 2;		// Used for relatively flat elements, like those found in a PCB layer to reduce modeling generation time.
	}
	message PCBModelingProperties {
		enum ExportModelType {
			Default = 0;		// Region type is based on the Mesh Type property defined in the PCB Modeling tab in the FEA Model Export dialog.
			Sherlock = 1;		// Use mesh elements generated by Sherlock to model the region.
			Sweep = 2;			// Use mesh elements generated by the FEA tool to model the region.
			None = 3;			// Define only geometric volumes for the region, without generating mesh elements.
		}
		ExportModelType exportModelType = 1; 	// The type of model to be generated for a given modeling region.
		ElementOrder elemOrder = 2;				// The type of 3D elements to be created for the PCB in the modeling region.
		double maxMeshSize = 3;					// The maximum size of the mesh to be used in the region.
		string maxMeshSizeUnits = 4;			// Units for the maximum mesh size.
		bool quadsPreferred = 5;				// If true, then the meshing engine should attempt to generate quad-shaped elements when creating the mesh.
	}
	message TraceModelingProperties {
		enum TraceModelingType {
			Default = 0;	// Trace modeling type is based on the Trace Modeling property defined in the Trace Modeling tab in the FEA Model Export dialog.
			Enabled = 1;	// Trace modeling is enabled for this region.
			Disabled = 2;	// Trace modeling is disabled for this region.
		}
		TraceModelingType traceModelType = 1;		// Specifies if trace modeling should be performed inside of the region.
		optional ElementOrder elemOrder = 2;		// The type of 3D elements to be created for traces in the region when trace modeling is enabled.
		optional double traceMeshSize = 3;			// The maximum mesh size to be used in the region when trace modeling is enabled.
		optional string traceMeshSizeUnits = 4;		// Units for the maximum mesh size when trace modeling is enabled.
	}
	optional string ccaName = 1;							// Name of the CCA.
	optional string regionId = 2;							// Unique modeling region ID.
	optional string regionUnits = 3;						// Modeling region units.
	optional ModelingMode modelMode = 4; 					// Mode that specified how the region is used.
	oneof Shape {
	      PolygonalShape polygonalShape = 5;				// Defined by N points that form a convex polygon.
	  	  RectangularShape rectangularShape = 6;			// Defined by 4 points that form a rectangle.
	  	  SlotShape slotShape = 7;							// Defined by 8 points that form a rectangle with rounded ends.
	  	  CircularShape circularShape = 8;					// Defined by N points that form a circle.
	}
	optional PCBModelingProperties pcbModelProps = 9;   	// Mesh properties for the modeling region.
	optional TraceModelingProperties traceModelProps = 10;	// Trace modeling properties for the region.	
	optional string regionIdReplacement = 11;				// Represents a unique region id that will replace the existing regionId value during 
															// a modeling region update if a value exists.
}

/** 
 * Request to add one or more modeling regions to a specific project.
 */
 message AddModelingRegionRequest {
	string project = 1;								// The name of the Sherlock project to add the modeling regions to.
	repeated ModelingRegion modelingRegions = 2;	// List of modeling regions to add to the project.
}

/** 
 * Request to update one or more modeling regions for a specific project.
 */
 message UpdateModelingRegionRequest {
	string project = 1;								// The name of the Sherlock project.
	repeated ModelingRegion modelingRegions = 2;	// List of modeling regions to update in the project.  The regionId for 
													// each modeling region must already exist in the project.
}

/** 
 * Request to delete one or more modeling regions for a specific project.
 */
 message DeleteModelingRegionRequest {
	message DeleteModelingRegionInfo {
		string ccaName = 1;	 	// Name of the CCA.
		string regionId = 2;	// Unique region ID of the modeling region to delete.
	}
	string project = 1;									    // The name of the Sherlock project.
	repeated DeleteModelingRegionInfo deleteRegions = 2;	// List of modeling regions to delete in the project.  
}

/**
 * Request to copy one or more modeling regions in a specific project.
 */
 message CopyModelingRegionRequest {
	message CopyModelingRegionInfo {
		string ccaName = 1;	 		// Name of the CCA.
		string regionId = 2;		// Region ID of the existing modeling region to copy.
		string regionIdCopy = 3;    // Region ID of the modeling region copy. Must be unique.
		double centerX = 4;			// The center x coordinate of the modeling region copy -- used for location placement in the Layer Viewer. 
		double centerY = 5;			// The center y coordinate of the modeling region copy -- used for location placement in the Layer Viewer.
	}
	string project = 1;									    // The name of the Sherlock project.
	repeated CopyModelingRegionInfo copyRegions = 2;		// List of modeling regions to copy along with their corresponding "copy to" parameters.	
}

service SherlockLayerService {
  // Add one or more modeling regions with the specified shapes and properties.
  rpc addModelingRegion(AddModelingRegionRequest) returns (ReturnCode);

  // Add a potting region with the specified shape and properties.
  rpc addPottingRegion(AddPottingRegionRequest) returns (ReturnCode);

  // Delete all ICT fixtures in specific CCA of specific project.
  rpc deleteAllICTFixtures(DeleteAllICTFixturesRequest) returns (ReturnCode);

  // Delete all mount points in specific CCA of specific project.
  rpc deleteAllMountPoints(DeleteAllMountPointsRequest) returns (ReturnCode);
  
  // Delete all test points in specific CCA of specific project.
  rpc deleteAllTestPoints(DeleteAllTestPointsRequest) returns (ReturnCode);

  // Delete one or more existing modeling regions.
  rpc deleteModelingRegion(DeleteModelingRegionRequest) returns (ReturnCode);

  // Copy one or more existing modeling regions.
  rpc copyModelingRegion(CopyModelingRegionRequest) returns (ReturnCode);
  
  // Export all mount points and their properties into a CSV formatted file.
  rpc exportAllMountPoints(ExportAllMountPointsRequest) returns (ReturnCode);
  
  // Export all ICT fixtures and their properties into a CSV formatted file.
  rpc exportAllICTFixtures(ExportAllICTFixturesRequest) returns (ReturnCode);

  // Export all test points and their properties into a CSV formatted file.
  rpc exportAllTestPoints(ExportAllTestPointsRequest) returns (ReturnCode);

  // Get a list of valid mount point boundaries.
  rpc getMountPointBoundaries(GetMountPointBoundariesRequest) returns (GetMountPointBoundariesResponse);

  // Get a list of valid mount point chassis materials.
  rpc getMountPointChassisMaterials(GetMountPointChassisMaterialsRequest) returns (GetMountPointChassisMaterialsResponse);
  
  // Get a list of valid mount point properties.
  rpc getMountPointsProperties(GetMountPointsPropertiesRequest) returns (GetMountPointsPropertiesResponse);

  // Get a list of valid mount point shape type values.
  rpc getMountPointShapeTypes(GetMountPointShapeTypesRequest) returns (GetMountPointShapeTypesResponse);
  
  // Get a list of valid mount point sides.
  rpc getMountPointSides(GetMountPointSidesRequest) returns (GetMountPointSidesResponse);

  // Get a list of valid mount point type values.
  rpc getMountPointTypes(GetMountPointTypesRequest) returns (GetMountPointTypesResponse);

  // Get a list of valid mount point units.
  rpc getMountPointUnits(GetMountPointUnitsRequest) returns (GetMountPointUnitsResponse);
  
  // Update the ICT fixtures properties of a CCA from a CSV formatted file. This API could be used to add new ICT fixtures or update existing ones depending on the file contents.
  // If the ID specified already exists, then the properties for that ICT fixture will be updated.
  // If the ID specified does not already exist, or if the field is empty, then a new ICT fixture will be added with the specified properties.
  // The file format should be the same as the one produced from CCA -> Export ICT Fixtures.
  rpc updateICTFixturesByFile(UpdateICTFixturesByFileRequest) returns (UpdateICTFixturesResponse);

  // Update mount points with specified properties.
  rpc updateMountPoints(UpdateMountPointsRequest) returns (UpdateMountPointsResponse);

  // Update one or more modeling regions with the specified shapes and properties.
  rpc updateModelingRegion(UpdateModelingRegionRequest) returns (ReturnCode);

  // Update the mount points properties of a CCA from a CSV formatted file. This API could be used to add new mount points or update existing ones depending on the file contents.
  // If the ID specified already exists, then the properties for that mount point will be updated.
  // If the ID specified does not already exist, or if the field is empty, then a new mount point will be added with the specified properties.
  // The file format should be the same as the one produced from CCA -> Export Mount Points.
  rpc updateMountPointsByFile(UpdateMountPointsByFileRequest) returns (UpdateMountPointsResponse);
  
  // Update the test points properties of a CCA from a CSV formatted file. This API could be used to add new test points or update existing ones depending on the file contents.
  // If the ID specified already exists, then the properties for that test point will be updated.
  // If the ID specified does not already exist, or if the field is empty, then a new test point will be added with the specified properties.
  // The file format should be the same as the one produced from CCA -> Export Test Points.
  rpc updateTestPointsByFile(UpdateTestPointsByFileRequest) returns (UpdateTestPointsResponse);

}
