// Copyright 2021:
//   JaiaRobotics LLC
// File authors:
//   Toby Schneider <toby@gobysoft.org>
//
//
// This file is part of the JaiaBot Project Binaries
// ("The Jaia Binaries").
//
// The Jaia Binaries are free software: you can redistribute them and/or modify
// them under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// The Jaia Binaries are distributed in the hope that they will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with the Jaia Binaries.  If not, see <http://www.gnu.org/licenses/>.

syntax = "proto2";

import "goby/middleware/protobuf/app_config.proto";
import "goby/zeromq/protobuf/interprocess_config.proto";
import "goby/middleware/protobuf/udp_config.proto";
import "goby/middleware/protobuf/pty_config.proto";
import "goby/middleware/protobuf/serial_config.proto";
import "goby/middleware/protobuf/tcp_config.proto";
import "jaiabot/messages/link.proto";
import "jaiabot/messages/link_config.proto";
import "goby/acomms/protobuf/buffer.proto";

package jaiabot.config;

message HubManager
{
    // required parameters for ApplicationBase3 class
    optional goby.middleware.protobuf.AppConfig app = 1;
    // required parameters for connecting to 'gobyd'
    optional goby.zeromq.protobuf.InterProcessPortalConfig interprocess = 2;

    message ExpectedHubs
    {
        repeated int32 id = 1;
    }
    optional ExpectedHubs expected_hubs = 18;
    
    required jaiabot.protobuf.LinkAwareBufferConfig status_buffer = 11;
    required jaiabot.protobuf.LinkAwareBufferConfig task_packet_buffer = 12;
    required jaiabot.protobuf.LinkAwareBufferConfig engineering_status_buffer =
        13;
    required goby.acomms.protobuf.DynamicBufferConfig hub2hub_buffer = 19;

    optional int32 hub_id = 14 [default = 0];
    optional int32 fleet_id = 15 [default = 0];
    optional int32 health_report_timeout_seconds = 16 [default = 20];

    message VirtualFleetData
    {
        // used by VirtualHub to shut down system after idle (no commands
        // received) to avoid running up EC2 costs unexpectedly
        required int32 shutdown_after_last_command_seconds = 1 [default = 3600];
        // delay shutting down hub after this time since last BotStatus
        // message
        required int32 hub_shutdown_delay_seconds = 2 [default = 300];
    }
    optional VirtualFleetData vfleet = 20;

    // data offload
    required string data_offload_script = 30;
    optional string log_staging_dir = 31 [default = "/var/log/jaiabot/staging"];
    optional string log_offload_dir = 32
        [default = "/var/log/jaiabot/bot_offload"];
    optional int32 bot_start_ip = 33 [default = 100];
    optional string class_b_network = 34 [default = "10.23"];
    optional bool use_localhost_for_data_offload = 35 [default = false];
    optional string ctd_offload_script = 36;

    required string hub_gpsd_device = 40;  // gpsd device for hub itself

    message ContactGPS
    {
        required string gpsd_device = 1;
        required int32 contact = 2;
        optional bool use_cog = 3 [default = false];
    }
    repeated ContactGPS contact_gps =
        41;  // GPSD device feeds for contacts to
             // send to vehicles (e.g., to trail, to avoid, etc.)

    message BotToGPS
    {
        optional int32 bot_id = 1;
        oneof transport
        {
            goby.middleware.protobuf.UDPPointToPointConfig udp = 2;
            goby.middleware.protobuf.PTYConfig pty = 3;
            goby.middleware.protobuf.SerialConfig serial = 4;
            goby.middleware.protobuf.TCPClientConfig tcp_client = 5;
            goby.middleware.protobuf.TCPServerConfig tcp_server = 6;
        }
    }
    repeated BotToGPS bot_to_gps = 42;  // feed BotStatus as pseudo-GPS message
                                        // over various transport options

    optional int32 contact_blackout_seconds = 43
        [default = 2];  // don't send a contact update more often than this

    required uint32 subnet_mask = 50;
    repeated protobuf.Link link_to_subscribe_on =
        51;  // when subscribing to managed bots, use these links, otherwise
             // wait for bots to subscribe first
}
