syntax = "proto3";

option csharp_namespace = "DNV.Sesam.Core.API.Fatigue.Grpc";

package fatigue;

// The Fatigue service definition.
service FatigueService {
  // Start a fatigue analysis.
  rpc Run (FatigueAnalysisInput) returns (WorkStatusInfo);

  // Get work status for a given work.
  rpc GetWorkStatus(WorkStatusRequest) returns(WorkStatusInfo);

  // Open a stream with WorkStatus responses for a given work.
  rpc GetWorkStatusStream(WorkStatusRequest) returns(stream WorkStatusInfo);
}

// Execution options
message ExecutionOptions {
	// Working directory (Optional).
	string WorkingDirectory = 1;

	// The degree of parallelism (the number of parallel tasks to run) (Optional).
	int32 DegreeOfParallelism = 2;

	// If true, verbose logging will be performed (Optional, default is false).
	bool VerboseLogging = 3;
}

// The Fatigue Analysis Input request message.
message FatigueAnalysisInput {
  // Execution options.
  ExecutionOptions Options = 1;

  // The root folder for input files. Relative input file paths should
  // be relative to this path. If not specified, the WorkingDirectory will be 
  // used as input root directory (Optional).
  string InputRootDirectory = 2;

  // The sestra input file.
  string SestraInputFile = 3;

  // The model (T.FEM) file.
  string ModelFile = 4;

  // The load file.
  string LoadFile = 5;

  // The screening command (JNL) file.
  string ScreeningCommandFile = 6;

  // The hot spot command (JNL) file.
  string HotSpotCommandFile = 7;

  // The screening capacity model (JSON) file.
  string ScreeningModelFile = 8;

  // The hot spot capacity model (JSON) file.
  string HotSpotModelFile = 9;
    
  // The path to the file containing SN curves (Optional).
  string SnCurvesPath = 10;

  // The path to the file containing user-defined SN curves (Optional).
  string UserDefinedSnCurvesPath = 11;

  // If true, a screening check should be run
  bool RunScreeningCheck = 12;

  // If true, a hotspot check should be run.
  bool RunHotSpotCheck = 13;
}

// Progress message
message TaskProgress  {
	// The id of the task that the progress is related to.
	string TaskId = 1;

	// # items completed.
	int32 Completed = 2;

	// Remaining # items.
	int32 Remaining = 3;
}

// Request for work status
message WorkStatusRequest {
	// Work identifier
	string WorkId = 1;
}

// The response message containing the work status.
message WorkStatusInfo {
  // Work identifier
  string WorkId = 1;

  // Work status message.
  string Message = 2;

  // Work status code.
  int32 StatusCode = 3;

  // Total work progress as a fraction between 0 (no work done) and 1 (completed).
  double TotalProgress = 4;

  // The work progress.
  repeated TaskProgress TaskProgress = 5;
}
