Beispiel #1
0
        private static IEnumerator GetStateInformationInternal(string domain, StateInformationCallback callback)
        {
            FullStateResponse result;

#if LDMT_TESTING_WITHOUT_PRINT_JOB
            yield return(null);

            var json = @"
{
  ""temperature"": {
    ""tool0"": {
                ""actual"": 214.8821,
      ""target"": 220.0,
      ""offset"": 0
    },
    ""tool1"": {
                ""actual"": 25.3,
      ""offset"": 0
    },
    ""bed"": {
                ""actual"": 50.221,
      ""target"": 70.0,
      ""offset"": 5
    },
    ""history"": [
      {
        ""time"": 1395651928,
        ""tool0"": {
          ""actual"": 214.8821,
          ""target"": 220.0
        },
        ""tool1"": {
          ""actual"": 25.3,
        },
        ""bed"": {
          ""actual"": 50.221,
          ""target"": 70.0
        }
      },
      {
        ""time"": 1395651926,
        ""tool0"": {
          ""actual"": 212.32,
          ""target"": 220.0
        },
        ""tool1"": {
          ""actual"": 25.1,
        },
        ""bed"": {
          ""actual"": 49.1123,
          ""target"": 70.0
        }
      }
    ]
  },
  ""sd"": {
    ""ready"": true
  },
  ""state"": {
    ""text"": ""Operational"",
    ""flags"": {
      ""operational"": true,
      ""paused"": false,
      ""printing"": false,
      ""cancelling"": false,
      ""pausing"": false,
      ""sdReady"": true,
      ""error"": false,
      ""ready"": true,
      ""closedOrError"": false
    }
  }
}";
#else
            UnityWebRequest request = UnityWebRequest.Get(domain + "/api/printer");
            request.SetRequestHeader("x-api-key", xApiKey);
            yield return(request.SendWebRequest());

            if (request.isNetworkError || request.isHttpError)
            {
                callback.Invoke(false, null);
            }
            else
            {
                var json = System.Text.Encoding.ASCII.GetString(request.downloadHandler.data);
#endif
            result = JsonConvert.DeserializeObject <FullStateResponse>(json);
            callback.Invoke(true, result);
#if !LDMT_TESTING_WITHOUT_PRINT_JOB
        }
#endif
        }
Beispiel #2
0
 public static void GetStateInformation(string domain, StateInformationCallback callback)
 {
     Instance.StartCoroutine(GetStateInformationInternal(domain, callback));
 }