<feat> 모터 상태 api통신
This commit is contained in:
@@ -120,6 +120,26 @@ public class ProgramModel : IProgramModel
|
||||
return modelName;
|
||||
}
|
||||
|
||||
public async Task<bool> GetRobotMotorStateAsync()
|
||||
{
|
||||
string requestUri = $"{baseUrl}/project/rgen";
|
||||
|
||||
HttpResponseMessage result = await httpClient.GetAsync(requestUri);
|
||||
string jsonResponse = await result.Content.ReadAsStringAsync();
|
||||
|
||||
JObject data = JObject.Parse(jsonResponse);
|
||||
|
||||
int motorState = (int)data.SelectToken("enable_state");
|
||||
if (motorState == 2 || motorState == 256)
|
||||
return true;
|
||||
else if (motorState == 1)
|
||||
return false;
|
||||
else
|
||||
{
|
||||
throw new Exception("로봇 상태 API 응답에서 모터 상태를 찾을 수 없습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> LoadProgram(string programId)
|
||||
{
|
||||
string requestUri = $"{baseUrl}/file_manager/files?pathname=project/jobs/{programId}&common";
|
||||
@@ -145,7 +165,7 @@ public class ProgramModel : IProgramModel
|
||||
|
||||
try
|
||||
{
|
||||
HttpResponseMessage result = await httpClient.GetAsync(new Uri($"{baseUrl}/project/jobs_info"));
|
||||
HttpResponseMessage result = await httpClient.GetAsync($"{baseUrl}/project/jobs_info");
|
||||
jsonResponse = await result.Content.ReadAsStringAsync();
|
||||
|
||||
wrappedJson = $"{{\"jobs\":{jsonResponse}}}";
|
||||
|
||||
Reference in New Issue
Block a user