/*
// Do Not Remove this Comment:
//
// MESSAGES™ by XPLICIT COMPUTING, INC
// GOOGLE PROTOCOL BUFFER 3 DEFINITIONS
//
// Copyright 2020-2023 Xplicit Computing, Inc.
//
// Please see file README.md for usage and license info. README.md must be copied along
// with these *.proto as part of the license agreement. Direct questions or concerns to:
// info@xplicitcomputing.com
//
// SPDX-License-Identifier: BSD-3-Clause
// OSI-License-URL: https://opensource.org/licenses/BSD-3-Clause
*/ 



syntax = "proto3";

package Messages;

import "vector.proto";
import "spatial.proto";
import "meta.proto";


message Variables                                                                                       // compatible with xcompute *.cfg files via machinery defined in config.hpp/config.cpp
{
    //reserved
    repeated string int_names = 2;
    repeated int32 int_values = 3;
    repeated string int_descriptions = 4;
    //reserved
    repeated string bool_names = 6;
    repeated bool bool_values = 7;
    repeated string bool_descriptions = 8;
    //reserved
    repeated string double_names = 10;
    repeated double double_values = 11;
    repeated string double_descriptions = 12;
    //reserved
    repeated string string_names = 14;
    repeated string string_values = 15;
    repeated string string_descriptions = 16;
    //reserved
}


message Function                                                                                        // compatible with xcompute algorithm (operation/code that has not been bound yet)
{
    string name = 1;
    // argument object binding requirements:
    repeated string argument_types = 2;                                                                 // required types to operate (name of class or type)
    repeated string argument_descriptions = 3;                                                          // matching argument descriptions (used by UI)
    repeated string inputs = 4;                                                                         // PK's required for algorithm inputs (user inputs)
    repeated string outputs = 5;                                                                        // PK's required for algorithm outputs
    repeated string constants = 6;                                                                      // PK's for uniform values across all nodes
    repeated string to_be_defined = 7;                                                                  // PK's for to be set by user in UI (end-user inputs)
    repeated Vector64 data = 8;                                                                         // local data relevant to this algorithm (coefficients, etc)
    //reserved  
    bool cpu_capable = 10;
    bool gpu_capable = 11;
    bool include_as_preprocessor = 12;
    bool omit_from_main_loop = 13;
    bool include_as_postprocessor = 14;
    bool mutually_exclusive = 15;
    bool only_once = 16;
    bool push_front = 17;
    bool dont_flatten = 18;
    //reserved
}


message Command                                                                                         // compatible with xcompute instruction  (a function instance bound to arguments... data, regions, etc)
{
    Function function = 1;
    bool args_are_set = 2;
    bool is_ready = 3;
    uint64 exec_count = 4;
    uint64 simd_size = 5;
    uint64 version = 6;
    int64 id = 7;                                                                                      // unique runtime identifier (assigned and only valid within a server session)
    uint64 n_kernel = 8;
    float progress = 9;
    string msg = 10;
    //reserved  
    Record64 data = 12;
    repeated Command before = 13;                                                                       // optional, to be called from within bound function
    repeated Command after = 14;                                                                        // optional, to be called from within bound function
    uint32 region_type = 15;                                                                   // if assigned, used to identify specific zones for conditions, etc
    int32 region_id = 16;                                                                      // if assigned, used to identify specific zones for conditions, etc
}


message Script                                                                                          // compatible with xcompute solver
{
    string name = 1;
    string msg = 2;
    string source_code = 3;
    int64 uid = 4;                                                                                     // same as system uid, if assigned
    uint32 device = 5;
    uint32 status = 6;
    uint32 order = 7;
    float progress = 8;
    //reserved
    Variables variables = 10;
    //reserved  
    repeated Command Sequence = 12;
    //reserved
    Script before = 14;
    Script after = 15;
}

message Model                                                                                           // compatible with xcompute model/physics
{
    string name = 1;
    //reserved
    repeated string dofs = 3;
    repeated string algorithms = 4;                                                                     // ordered algorithms (by name)
    repeated string available_outputs = 5;                                                              // serialized property-keys
    repeated string extra_properties = 6;                                                               // some pk's are not recorded by default as an optimization. they can be added
    repeated string compatible_conditions = 7;                                                          // relevant algorithm/function names that are applied to one ore more regions or initialize
    //reserved
    repeated Model sub_models = 9;
    Record64 default_data = 10;                                                                         // default constants, unless otherwise specified (by region)
    repeated Rule rules = 11;                                                                           // how each PK can be calculated (by algorithm name)
    repeated Rule mutex_stack = 12;
    //reserved
    SparseMatrix markov_matrix = 15;
}


message Coupling
{
    string source_system = 1;                                                                           // s---
    string target_system = 2;                                                                           // ---t
    int64 source_uid = 3;                                                                              // uid is only valid within a given session
    int64 target_uid = 4;                                                                              // uid is only valid within a given session
    Zone source_region = 5;                                                                             // s---
    Zone target_region = 6;                                                                             // ---t
    //reserved
    uint32 sampling_mode = 9;                                                                           // enum(0:8): default, 1:1, nearest, distance, least-square, projected, view-factor, immersed
    string name = 10;
    repeated string dofs = 11;                                                                          // s---wo---w1---w2---t
    Representation representation = 12;
    bool enabled = 13;                                                                                  // s----Z Z----t
    bool forward = 14;                                                                                  // s---------->t
    bool reverse = 15;                                                                                  // s<----------t
    //reserved
}


message System                                                                                          // compatible with xcompute system
{
    Meta meta = 1;                                                                                      // name and other basic info, some of which is non-persistent 
    repeated Script script = 2;                                                                         // serialized solver defined by a sequence of instructions
    repeated double local_transform = 3;                                                              	// double16 (glm::dmat4) local transformation matrix
    repeated double local_rate = 4;                                                              		// double16 (glm::dmat4) local transformation matrix
    repeated double local_accel = 5;                                                              		// double16 (glm::dmat4) local transformation matrix
    repeated string children = 6;                                                                       // sub-system names (exact matches)
    repeated string referenced_files = 7;                                                               // external file references, such as *.xcg geometry (Messages::Topology)
    repeated File embedded_files = 8;                                                                   // files such as symbol and supporting documentation
    repeated string notes = 9;
    repeated Coupling couplings = 10;                                                                    // links and contacts between regions
    repeated Model models = 11;                                                                         // physical / mathematical models (groups of algorithms)
    Record64 physical_constants = 12;                                                                   // physics.data and system requirements
    repeated Command conditions = 13;                                                                   // special algorithm commands applied as constraints and conditions
}


