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

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

/**
 * Status response of a message. A value of 0 indicates a successful request. 
 */
message ReturnCode {
  int32 value = 1;		// Status code of response. A value of 0 indicates success.
  string message = 2;	// Message indicating the status of response including any error.
}

/**
 * Request to exit the gRPC connection.
 */
message ExitRequest {
   bool closeSherlockClient = 1;	// If set to true, exits the Sherlock client if it is opened. Otherwise, just closes the gRPC connection.
}

/**
 * Request to check if the gRPC connection is open.
 */
message HealthCheckRequest {
}

/**
 * Represents whether the gRPC connection is open.
 */
message HealthCheckResponse {
  enum ServingStatus {
    UNKNOWN = 0;		// Indicates an unknown connection status.
    SERVING = 1;		// Indicates the connection is up and server is listening.
    NOT_SERVING = 2;	// Indicates connection with server is closed.
  }
  ServingStatus status = 1;
  int32 port = 2;		// Listening port number on server.
}

/**
 * Check if the Sherlock client is still loading.
 */
message IsSherlockClientLoadingRequest {
}

/**
  * Request for a list of valid units of the provided unit type.
  */
message ListUnitsRequest {
  enum UnitType {
    UNKNOWN = 0;				// Indicates an unknown unit type.
    ACCEL_DENSITY = 1;			// Units used for acceleration density.
    ACCELERATION = 2;			// Units used for acceleration.
    AREA = 3;					// Units used for area.
    BANDWIDTH = 4;				// Units used for bandwidth.
    CAPACITANCE = 5;			// Units used for electrical capacitance.
    CTE = 6;					// Units used for material CTE.
    CURRENT = 7;				// Units used for electrical current.
    DENSITY = 8;				// Units used for density.
    DISP_DENSITY = 9;			// Units used for displacement density.
    FORCE = 10;					// Units used for force.
    FREQUENCY = 11;				// Units used for frequency.
    INDUCTANCE = 12;			// Units used for inductance.
    LENGTH = 13;				// Units used for length.
    POWER = 14;					// Units used for electrical power.
    RESISTANCE = 15;			// Units used for electrical resistance.
    SIZE = 16;					// Units used for size.
    SPECIFIC_HEAT = 17;			// Units used for specific heat.
    STRAIN = 18;				// Units used for strain.
    STRESS = 19;				// Units used for stress.
    TEMPERATURE = 20;			// Units used for temperature.
    THERMAL_CONDUCTIVITY = 21;	// Units used for thermal conductivity.
    THERMAL_RESISTANCE = 22;	// Units used for thermal resistance.
    TIME = 23;					// Units used for time.
    VELOCITY = 24;				// Units used for velocity.
    VELOCITY_DENSITY = 25;		// Units used for velocity density.
    VOLTAGE = 26;				// Units used for electrical voltage.
    VOLUME = 27;				// Units used for volume.
    WEIGHT = 28;				// Units used for weight.
  }
  UnitType unitType = 1;	// Unit type to request valid units of.
}

/**
  * Represents a list of valid units for the provided unit type.
  */
message ListUnitsResponse {
  ReturnCode returnCode 	= 1;	// Status code of response.
  repeated string units		= 2;	// List of valid units for the requested type.
}

/**
  * Request for a list of valid solder materials.
  */
message GetSoldersRequest {
}

/**
  * Represents a list of valid solder materials.
  */
message GetSoldersResponse {
	repeated string solderName = 1; // List of valid solder materials.
}

/**
 * Represents a common measurement with a value and a unit.
 */
 message Measurement {
  double value = 1;
  string units = 2;
}

/**
 * Types of delimiters that can be used for exporting tables
 */
 enum TableDelimiter {
  COMMA = 0;
  SPACE = 1;
  TAB = 2;
  SEMICOLON = 3;
 }

service SherlockCommonService {

  // Returns health status of gRPC server.
  rpc check(HealthCheckRequest) returns (HealthCheckResponse);
  
  // Signals for gRPC connection to shutdown.
  rpc exit(ExitRequest) returns (ReturnCode);
  
  // Check if the Sherlock client is still loading.
  rpc isSherlockClientLoading(IsSherlockClientLoadingRequest) returns (ReturnCode);
  
  // Returns a list of valid units of the provided unit type.
  rpc listUnits(ListUnitsRequest) returns (ListUnitsResponse);
  
  // Returns a list of valid solder materials.
  rpc getSolders(GetSoldersRequest) returns (GetSoldersResponse);
}
