Пример #1
0
 public void Release()
 {
     if (instance != null)
     {
         GalileoFunctions.ReleaseInstance(instance);
     }
 }
Пример #2
0
 public void Dispose()
 {
     if (instance != null)
     {
         GalileoFunctions.Dispose(instance);
     }
 }
Пример #3
0
        public GALILEO_RETURN_CODE ConnectIOT(string targetID, int timeout, string password, Action <GALILEO_RETURN_CODE, String> onConnect = null, Action <GALILEO_RETURN_CODE, String> onDisconnect = null)
        {
            byte[]               targetIDBytes  = Encoding.ASCII.GetBytes(targetID);
            byte[]               passwordBytes  = Encoding.ASCII.GetBytes(password);
            OnConnectDelegate    onConnectCB    = null;
            OnDisconnectDelegate onDisconnectCB = null;

            if (onConnect != null)
            {
                onConnectCB = (status, id, length) =>
                {
                    byte[] result = new byte[length];
                    Marshal.Copy(id, result, 0, (int)length);
                    onConnect?.Invoke(status, Encoding.ASCII.GetString(result, 0, (int)length));
                };
            }
            if (onDisconnect != null)
            {
                onDisconnectCB = (status, id, length) =>
                {
                    byte[] result = new byte[length];
                    Marshal.Copy(id, result, 0, (int)length);
                    onDisconnect?.Invoke(status, Encoding.ASCII.GetString(result, 0, (int)length));
                };
            }
            return(GalileoFunctions.ConnectIOT(instance, targetIDBytes, targetIDBytes.Length, timeout, passwordBytes, passwordBytes.Length, onConnectCB, onDisconnectCB));
        }
Пример #4
0
 public void SetCurrentStatusCallback(Action <GalileoStatus> statusCB = null)
 {
     onStatusUpdateCB = (status, statusJson, length) => {
         byte[] result = new byte[length];
         Marshal.Copy(statusJson, result, 0, (int)length);
         var statusStr = Encoding.ASCII.GetString(result, 0, (int)length);
         statusCB?.Invoke(JsonConvert.DeserializeObject <GalileoStatus>(statusStr));
     };
     GalileoFunctions.SetCurrentStatusCallback(instance, onStatusUpdateCB);
 }
Пример #5
0
 public void SetGoalReachedCallback(Action <int, GalileoStatus> goalCB)
 {
     onGoalReachedCB = (goalid, statusJson, length) => {
         byte[] result = new byte[length];
         Marshal.Copy(statusJson, result, 0, (int)length);
         var statusStr = Encoding.ASCII.GetString(result, 0, (int)length);
         goalCB?.Invoke(goalid, JsonConvert.DeserializeObject <GalileoStatus>(statusStr));
     };
     GalileoFunctions.SetGoalReachedCallback(instance, onGoalReachedCB);
 }
Пример #6
0
        public ServerInfo GetCurrentServer()
        {
            byte[] currentServer = new byte[1024 * 1024];
            long   length        = 0;

            GalileoFunctions.GetCurrentServer(instance, currentServer, ref length);
            string currentServerJsonString = Encoding.UTF8.GetString(currentServer, 0, (int)length);

            return(JsonConvert.DeserializeObject <ServerInfo>(currentServerJsonString));
        }
Пример #7
0
        public GalileoStatus GetCurrentStatus()
        {
            byte[] currentStatus = new byte[1024 * 1024];
            long   length        = 0;

            if (GalileoFunctions.GetCurrentStatus(instance, currentStatus, ref length) != GALILEO_RETURN_CODE.OK)
            {
                return(null);
            }
            string currentStatusJsonString = Encoding.UTF8.GetString(currentStatus, 0, (int)length);

            return(JsonConvert.DeserializeObject <GalileoStatus>(currentStatusJsonString));
        }
Пример #8
0
        public List <ServerInfo> GetServersOnline()
        {
            byte[] servers = new byte[1024 * 1024];
            long   length  = 0;

            GalileoFunctions.GetServersOnline(instance, servers, ref length);
            string serversJsonString = Encoding.UTF8.GetString(servers, 0, (int)length);

            if (serversJsonString == "null")
            {
                return(new List <ServerInfo>());
            }
            JArray            serversJson = JArray.Parse(serversJsonString);
            List <ServerInfo> serversObj  = new List <ServerInfo>();;

            foreach (var server in serversJson)
            {
                serversObj.Add(server.ToObject <ServerInfo>());
            }
            return(serversObj);
        }
Пример #9
0
        public GALILEO_RETURN_CODE SendGalileoBridgeRequest(string method, string url, string body, ref HttpBridgeResponse response, int timeout = 10 * 1000)
        {
            var methodBytes = Encoding.UTF8.GetBytes(method);
            var urlBytes    = Encoding.UTF8.GetBytes(url);
            var bodyBytes   = Encoding.UTF8.GetBytes(body);

            byte[] responseBytes = new byte[1024 * 1024];
            long   length        = 0;
            var    status        = GalileoFunctions.SendGalileoBridgeRequest(instance, methodBytes, methodBytes.Length,
                                                                             urlBytes, urlBytes.Length,
                                                                             bodyBytes, bodyBytes.Length,
                                                                             responseBytes, ref length, timeout);

            if (status != GALILEO_RETURN_CODE.OK)
            {
                return(status);
            }
            string responseStr = Encoding.UTF8.GetString(responseBytes, 0, (int)length);

            response = JsonConvert.DeserializeObject <HttpBridgeResponse>(responseStr);
            return(status);
        }
Пример #10
0
 public GALILEO_RETURN_CODE Connect(String targetID, bool autoConnect, int timeout, Action <GALILEO_RETURN_CODE, String> onConnect = null, Action <GALILEO_RETURN_CODE, String> onDisconnect = null)
 {
     byte[] targetIDBytes = Encoding.ASCII.GetBytes(targetID);
     if (onConnect != null)
     {
         onConnectCB = (status, id, length) =>
         {
             byte[] result = new byte[length];
             Marshal.Copy(id, result, 0, (int)length);
             onConnect?.Invoke(status, Encoding.ASCII.GetString(result, 0, (int)length));
         };
     }
     if (onDisconnect != null)
     {
         onDisconnectCB = (status, id, length) =>
         {
             byte[] result = new byte[length];
             Marshal.Copy(id, result, 0, (int)length);
             onDisconnect?.Invoke(status, Encoding.ASCII.GetString(result, 0, (int)length));
         };
     }
     return(GalileoFunctions.Connect(instance, Encoding.ASCII.GetBytes(targetID), targetIDBytes.Length, autoConnect, timeout, onConnectCB, onDisconnectCB));
 }
Пример #11
0
 public GALILEO_RETURN_CODE StartLoop()
 {
     return(GalileoFunctions.StartLoop(instance));
 }
Пример #12
0
        public GALILEO_RETURN_CODE CheckServerOnline(string targetID)
        {
            var targetIDBytes = Encoding.UTF8.GetBytes(targetID);

            return(GalileoFunctions.CheckServerOnline(instance, targetIDBytes, targetIDBytes.Length));
        }
Пример #13
0
 public bool IsConnecting()
 {
     return(GalileoFunctions.IsConnecting(instance));
 }
Пример #14
0
 public GALILEO_RETURN_CODE SendRawAudio(byte[] data)
 {
     return(GalileoFunctions.SendRawAudio(instance, data, data.Length));
 }
Пример #15
0
 public GALILEO_RETURN_CODE EnableGreeting(bool flag)
 {
     return(GalileoFunctions.EnableGreeting(instance, flag));
 }
Пример #16
0
 public GALILEO_RETURN_CODE StartChargeLocal()
 {
     return(GalileoFunctions.StartChargeLocal(instance));
 }
Пример #17
0
        public GALILEO_RETURN_CODE SendAudio(string audio)
        {
            var audioBytes = Encoding.UTF8.GetBytes(audio);

            return(GalileoFunctions.SendAudio(instance, audioBytes, audioBytes.Length));
        }
Пример #18
0
 public GALILEO_RETURN_CODE Shutdown()
 {
     return(GalileoFunctions.Shutdown(instance));
 }
Пример #19
0
 public GALILEO_RETURN_CODE SetSpeed(float vLinear, float xAngle)
 {
     return(GalileoFunctions.SetSpeed(instance, vLinear, xAngle));
 }
Пример #20
0
 public GALILEO_RETURN_CODE StopMapping()
 {
     return(GalileoFunctions.StopMapping(instance));
 }
Пример #21
0
 public GALILEO_RETURN_CODE SetLoopWaitTime(byte time)
 {
     return(GalileoFunctions.SetLoopWaitTime(instance, time));
 }
Пример #22
0
 public GALILEO_RETURN_CODE GetGoalNum(ref byte goalNum)
 {
     return(GalileoFunctions.GetGoalNum(instance, ref goalNum));
 }
Пример #23
0
 public GALILEO_RETURN_CODE MoveTo(float x, float y, ref byte goalNum)
 {
     return(GalileoFunctions.MoveTo(instance, x, y, ref goalNum));
 }
Пример #24
0
 public GALILEO_RETURN_CODE StopCharge()
 {
     return(GalileoFunctions.StopCharge(instance));
 }
Пример #25
0
 public GALILEO_RETURN_CODE StartCharge(float x, float y)
 {
     return(GalileoFunctions.StartCharge(instance, x, y));
 }
Пример #26
0
 public GALILEO_RETURN_CODE SaveChargeBasePosition()
 {
     return(GalileoFunctions.SaveChargeBasePosition(instance));
 }
Пример #27
0
 public GALILEO_RETURN_CODE SetAngle(byte sign, byte angle)
 {
     return(GalileoFunctions.SetAngle(instance, sign, angle));
 }
Пример #28
0
 public void WaitForGoal(byte goalIndex)
 {
     GalileoFunctions.WaitForGoal(instance, goalIndex);
 }
Пример #29
0
 public void Disconnect()
 {
     GalileoFunctions.Disconnect(instance);
 }
Пример #30
0
 public GALILEO_RETURN_CODE UpdateMap()
 {
     return(GalileoFunctions.UpdateMap(instance));
 }