You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Lebai.SDK;
- using Lebai.SDK.Dtos;
- using Robotc;
-
- namespace HBLConsole.Communication
- {
- public class LebaiHelper
- {
-
- private volatile static LebaiHelper _Instance;
- public static LebaiHelper GetInstance => _Instance ?? (_Instance = new LebaiHelper());
- private LebaiHelper() { }
- private LebaiRobotClient client;
- public void Connect(string ip)
- {
- client = new LebaiRobotClient(ip);
- }
-
- /// <summary>
- /// 获取信号量
- /// </summary>
- /// <param name="index"></param>
- /// <returns></returns>
- public SignalResult GetValueAsync(int index = 0)
- {
- SignalValue signalValue = new SignalValue();
- signalValue.Index = index;
- return client?.GetSignal(signalValue).Result;
- }
-
- /// <summary>
- /// 设置信号量
- /// </summary>
- /// <param name="index"></param>
- /// <param name="value"></param>
- /// <returns></returns>
- public SignalResult SetValue(int value, int index = 0)
- {
- SignalValue signalValue = new SignalValue();
- signalValue.Index = index;
- signalValue.Value = value;
- return client.SetSignal(signalValue).Result;
- }
-
- /// <summary>
- /// 运行指定的场景
- /// </summary>
- /// <param name="id"></param>
- public void Scene(int id)
- {
- client?.RunScene(id);
- }
- }
- }
|