// Copyright 2023-2025 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, -1 indicates error.
  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; // Enum representing connection status.
  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.
}


/**
 * Represents solder information given to the client.
 */
message SolderInfo {
  string activationEnergy = 1;            // Activation energy.
  string ccCalibrationFactor = 2;         // CC Calibration factor.
  string correctionFactors = 3;           // Correction factors.
  string createdBy = 4;                   // Who created this solder.
  string criticalDwellTime = 5;           // Critical dwell time.
  string criticalDwellTimeUnits = 6;      // Critical dwell time units.
  string criticalMaxTemp = 7;             // Critical max temperature.
  string criticalMaxTempUnits = 8;        // Critical max temperature units.
  string criticalStrain = 9;              // Critical strain.
  string cte = 10;                         // CTE.
  string cteUnits = 11;                    // CTE units.
  string density = 12;                    // Solder density.
  string densityUnits = 13;               // Solder density units.
  string elasticModulus = 14;             // Elastic Modulus, may be a single value or a curve.
  string elasticModulusUnits = 15;        // Elastic Modulus units.
  string feaPower = 16;                   // FEA power.
  string leadedCalibrationFactor = 17;    // Leaded calibration factor.
  string materialFatigueCoefficient = 18; // Fatigue coefficient.
  string materialFatigueExponent = 19;    // Fatigue exponent.
  string modifiedBy = 20;                 // Who last modified this solder.
  string poissonRatio = 21;               // Poisson ratio.
  string secantModulus = 22;              // Secant modulus.
  string secantModulusUnits = 23;         // Secant modulus units.
  string secantFatigueCoefficient = 24;   // Secant fatigue coefficient.
  string secantFatigueExponent = 25;      // Secant fatigue exponent.
  string shockStrain = 26;                // Shock strain.
  string solderName = 27;                 // Name of solder.
  string solderType = 28;                 // Type of solder.
  string strainEnergyCoefficient = 29;    // Strain energy coefficient.
  string thermalConductivity = 30;        // Solder thermal conductivity.
  string thermalConductivityUnits = 31;   // Solder thermal conductivity units.
  string thermalShockFactorBGA = 32;      // Thermal shock factor for BGA.
  string thermalShockFactorCC = 33;       // Thermal shock factor for CC.
  string thermalShockFactorDEFAULT = 34;  // Thermal shock factor default.
  string thermalShockFactorLCCC = 35;     // Thermal shock factor for LCCC.
  string thermalShockFactorLeaded = 36;   // Thermal shock factor for Leaded.
  string thermalShockFactorQFN = 37;      // Thermal shock factor for QFN.
  string thermalShockFactorThruHole = 38; // Thermal shock factor for Through hole.
  string userNotes = 39;                  // Notes written by the user.
  string weibullBetaBGA = 40;             // Weibull for BGA.
  string weibullBetaCBGA = 41;            // Weibull fpr CBGA.
  string weibullBetaCC = 42;              // Weibull for CC.
  string weibullBetaLCCC = 43;            // Weibull for LCCC.
  string weibullBetaLeaded = 44;          // Weibull for Leaded.
  string weibullBetaQFN = 45;             // Weibull for QFN.
  string weibullBetaThruHole = 46;        // Weibull for through hole.
  string cgaCalibrationFactor = 47;       // CGA calibration factor.
  string bgaCalibrationFactor = 48;    	  // BGA calibration factor.
}

/**
  * Represents a list of valid solder materials.
  */
message SolderInfoResponse {
  repeated SolderInfo solders = 1; // Solder information.
}

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

}

/**
  * Request for a list of valid solder materials.
  */
message GetSoldersRequest {
  option deprecated = true;  // Signifies this message is being deprecated for SolderInfoRequest as of 25R2.
}

/**
  * Represents a list of valid solder materials.
  */
message GetSoldersResponse {
  option deprecated = true;       // Signifies this message is being deprecated for SolderResponse.
	repeated string solderName = 1; // List of valid solder materials.
}

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

/**
 * Types of delimiters that can be used for exporting tables.
 */
 enum TableDelimiter {
  COMMA = 0;  		// Represents ',' delimiter.
  SPACE = 1;  		// Represents ' ' delimiter.
  TAB = 2;	  		// Represents tab key delimiter.
  SEMICOLON = 3;	// Represents ';' delimiter.
}

/**
 * Determines how parts in the parts list are matched against parts 
 * in the AVL or Part Library.
 */
enum MatchingMode {
  Both	= 0;		// Matches both part number and manufacturer.
  Part	= 1;		// Matches part number only.
}

/**
 * Request to receive Sherlock version and configuration data.
 */
message SherlockInfoRequest {
}

/*
 * Represents Sherlock version and configuration data.
 */
message SherlockInfoResponse {
  string releaseVersion = 1;    // The current version of Sherlock, formatted as: YYYY R# (Ex. "2025 R1").
  string defaultProjectDir = 2; // The project directory currently used by Sherlock.
  bool isSingleProjectMode = 3; // When true, indicates that Sherlock is in single-project mode. When false, indicates that Sherlock is in multi-project mode.
}


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. This is deprecated as of 25R2.
  rpc getSolders(GetSoldersRequest) returns (GetSoldersResponse) {
    option deprecated = true;
  }

  // Returns a list of valid solder material information.
  rpc getSolderInfo(SolderInfoRequest) returns (SolderInfoResponse);

  // Returns meta data about Sherlock.
  rpc getSherlockInfo(SherlockInfoRequest) returns (SherlockInfoResponse);
}
