• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2022 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #include <chrono>
18 #include <optional>
19 #include <string>
20 
21 #include "common.pb.h"
22 #include "rust/cxx.h"
23 
24 namespace netsim::scene_controller {
25 
26 const unsigned int HTTP_STATUS_OK = 200;
27 const unsigned int HTTP_STATUS_BAD_REQUEST = 400;
28 
29 unsigned int PatchDevice(const std::string &request, std::string &response,
30                          std::string &error_message);
31 
32 unsigned int GetDevices(const std::string &request, std::string &response,
33                         std::string &error_message);
34 
35 bool GetDevicesBytes(rust::Vec<::rust::u8> &vec);
36 
37 int GetFacadeId(int chip_id);
38 
39 void RemoveChip(uint32_t device_id, uint32_t chip_id);
40 
41 /// The C++ definition of AddChip response interface for CXX.
42 class AddChipResult {
43  public:
44   uint32_t device_id;
45   uint32_t chip_id;
46   uint32_t facade_id;
47 
get_device_id()48   uint32_t get_device_id() const { return device_id; }
get_chip_id()49   uint32_t get_chip_id() const { return chip_id; }
get_facade_id()50   uint32_t get_facade_id() const { return facade_id; }
51 
AddChipResult(uint32_t device_id,uint32_t chip_id,uint32_t facade_id)52   AddChipResult(uint32_t device_id, uint32_t chip_id, uint32_t facade_id)
53       : device_id(device_id), chip_id(chip_id), facade_id(facade_id){};
54 };
55 
56 std::unique_ptr<AddChipResult> AddChipCxx(const std::string &guid,
57                                           const std::string &device_name,
58                                           uint32_t chip_kind,
59                                           const std::string &chip_name,
60                                           const std::string &manufacturer,
61                                           const std::string &product_name);
62 
63 std::tuple<uint32_t, uint32_t, uint32_t> AddChip(
64     const std::string &guid, const std::string &device_name,
65     common::ChipKind chip_kind, const std::string &chip_name = "",
66     const std::string &manufacturer = "", const std::string &product_name = "");
67 
68 float GetDistance(uint32_t, uint32_t);
69 
70 std::optional<std::chrono::seconds> GetShutdownTime();
71 
72 }  // namespace netsim::scene_controller
73