|
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using Lebai.SDK;
- using Lebai.SDK.Dtos;
- using Robotc;
- using BPASmartClient.Message;
- using BPASmartClient.Helper;
- using TaskStatus = Lebai.SDK.Dtos.TaskStatus;
- using BPASmartClient.Peripheral;
- using BPASmartClient.EventBus;
- using static BPASmartClient.EventBus.EventBus;
- using BPASmartClient.Model;
- using BPASmartClient.LebaiRobot;
-
- namespace BPASmartClient.Lebai
- {
- public class LebaiRobot: BasePeripheral
- {
-
- /// <summary>
- /// IP地址
- /// </summary>
- public string IpAddress { get; set; } = "192.168.0.1";
- /// <summary>
- /// 抓手上传感器输入位索引
- /// </summary>
- public int HandSensor { get; set; }
- /// <summary>
- /// 输出信号量索引
- /// </summary>
- public int OutputSingalValue { get; set; }
-
- protected override void InitStatus()
- {
- status["Connected"] = false;
- status["HandSensor"] = 0;
- status["OutputSingalValue"] = 0;
- }
-
- public override void Start()
- {
- LebaiHelper.GetInstance().Connect(IpAddress);
- ThreadManage.GetInstance().StartLong(() => { LebaiHelper.GetInstance().Reconnect(IpAddress); Thread.Sleep(5000); }, "机器人重连检测");
- ThreadManage.GetInstance().StartLong(() =>
- {
- status["Connected"] = LebaiHelper.GetInstance().IsConnected;
- if (LebaiHelper.GetInstance().robotData != null) status["RobotMode"] = LebaiHelper.GetInstance().robotData.RobotMode.Mode;
- },"获取乐白机器人数据");
- }
-
- public override void Stop()
- {
-
- }
-
- public override void Init()
- {
- EventBus.EventBus.GetInstance().Subscribe<Demo_MakeCoffeeEvent>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack )
- {
-
- });
- InitStatus();
- Start();
- }
-
-
- }
- }
|