syntax = "proto2";
import "machinetalk/protobuf/nanopb.proto";

// see README.msgid
// msgid base: 200

package machinetalk;

enum ApplicationType {
    QT5_QML    = 1;
    GLADEVCP   = 2;
    JAVASCRIPT = 3;
}

enum FileContent {
    CLEARTEXT  = 1;
    ZLIB       = 2;
};

message File {

    option (nanopb_msgopt).msgid = 200; // see README.msgid

    required string       name          = 1; // flat for now
    required FileContent  encoding      = 2;
    optional bytes        blob          = 3;
}

message Application {

    option (nanopb_msgopt).msgid = 201;

    required string       name          = 1; // unique key
    optional string       description   = 2; // comment
    optional ApplicationType type       = 3;
    optional string       weburi        = 4; // for type == JAVASCRIPT

    repeated File         file          = 5;
    // config params go here
}

message StdoutLine {

    option (nanopb_msgopt).msgid = 202;

    required int32  index = 1;
    optional string line  = 2;
}

message MachineInfo {

    option (nanopb_msgopt).msgid = 203;

    optional string     type            = 1; // type of the machine, e.g. FDM, CNC, ...
    optional string     manufacturer    = 2; // manufacturer of the machine
    optional string     model           = 3; // machine model
    optional string     variant         = 4; // variant of the machine
}

// message for mklauncher
message Launcher {

    option (nanopb_msgopt).msgid = 204;

    required int32        index          = 1;  // index is necessary to access repeated
    optional string       name           = 2;  // visible name
    optional string       description    = 3;  // description of the config
    optional File         image          = 4;  // image representing the configuration
    optional MachineInfo  info           = 5;  // information about the machine

    optional bool         running        = 6;  // indicates whether the config is running or not
    optional bool         terminating    = 7;  // indicates if a terminations signal was sent to the process
    optional string       command        = 8;  // configuration start command
    optional bool         shell          = 9;  // if the configuration command is executed in a shell
    repeated StdoutLine   output         = 10; // stdout output of the command
    optional int32        returncode     = 11; // return code of the command
    optional string       workdir        = 12; // working dir of the command
    optional uint32       priority       = 13; // priority for sorting, smaller means lower priority
    optional uint32       importance     = 14; // importance set by the user, smaller means less important
}
