<feat> 모터 상태 api통신

This commit is contained in:
SOOBEEN HAN
2025-10-24 11:55:43 +09:00
parent 5308a505a5
commit ff8afeb045
25 changed files with 77 additions and 906 deletions

View File

@@ -1,5 +1,7 @@
using System;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.XR.ARSubsystems;
public class ProgramPresenter
{
@@ -7,6 +9,7 @@ public class ProgramPresenter
private IProgramView view;
private RobotController controlledRobot;
private string _programId;
private bool lastKnownMotorState = false;
public ProgramPresenter(ProgramModel model, IProgramView view)
{
@@ -26,12 +29,29 @@ public class ProgramPresenter
this.controlledRobot = robot;
}
public async Task UpdateMotorStateAsync()
{
try
{
bool currentState = await model.GetRobotMotorStateAsync();
if (currentState != lastKnownMotorState)
{
controlledRobot.SetMotorState(currentState);
lastKnownMotorState = currentState;
}
}
catch (Exception e)
{
Debug.LogWarning($"모터 상태 업데이트 실패: {e.Message}");
}
}
public void OnApplicationStart()
{
if (controlledRobot != null)
{
Debug.Log("로봇 모터를 ON 상태로 설정합니다.");
controlledRobot.SetMotorState(true);
Debug.Log("제어할 로봇이 등록되었습니다.");
}
else
{
@@ -43,7 +63,7 @@ public class ProgramPresenter
{
if (await model.CreateNewProgram(programId))
{
view.DisplayProgram(model.CurrentProgram);
view.DisplayProgram(programId);
view.HideProgramSelectPanel();
OnApplicationStart();
}
@@ -68,7 +88,7 @@ public class ProgramPresenter
{
if(_programId != null && await model.LoadProgram(_programId))
{
view.DisplayProgram(model.CurrentProgram);
view.DisplayProgram(_programId);
view.HideProgramSelectPanel();
view.HideProgramList();