public HttpResponseMessage ReadOffsets(string datagroup) { Logger log = LogManager.GetCurrentClassLogger(); log.Info("Received OpenFSUIPC read offsets call"); try { if (FSPFSUIPCConnection.IsOpen) { List <FSPOffset> _offsets = FSPFSUIPCConnection.Process(datagroup); List <OffsetResponse> resp = new List <OffsetResponse>(); foreach (FSPOffset _offset in _offsets) { resp.Add(OffsetHelpers.setOffsetResponse(_offset)); } return(Request.CreateResponse(HttpStatusCode.OK, resp)); } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "FSUIPC Connection is not opened!")); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Exception Getting Offsets", ex)); } }
public HttpResponseMessage OpenPost([FromBody] FSUIPCConnect value) { Logger log = LogManager.GetCurrentClassLogger(); try { log.Info("Received OpenFSUIPC Connection call"); ConnectResponse resp = new ConnectResponse(); if (FSPFSUIPCConnection.IsOpen) { log.Info("Connection already is open"); resp.Message = "Connection Opened"; } else { log.Info("Opening connection.."); FSPFSUIPCConnection.Open(); resp.Message = "Connection Opened"; } FSPFSUIPCConnection.AddOffset(15616, Datatype.String, "Connect"); FSPOffset _offset = FSPFSUIPCConnection.Process("Connect").First(); OffsetResponse _resp = OffsetHelpers.setOffsetResponse(_offset); resp.Version = FSPServerV2.Library.Properties.Version.getVersion(); resp.Simulator = FSPFSUIPCConnection.FlightSimVersionConnected.ToString(); resp.Aircraft = _resp.Value; return(Request.CreateResponse(HttpStatusCode.OK, resp)); } catch (Exception ee) { Console.WriteLine(ee.Message); return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Connection Error", ee)); //return Request.CreateResponse(HttpStatusCode.OK, "error: " + ee.Message); } }
public HttpResponseMessage ReadOffset(int offset, string datatype, string datagroup) { if (FSPFSUIPCConnection.IsOpen) { try { List <FSPOffset> offsets = FSPFSUIPCConnection.Process(datagroup); FSPOffset _offset = (from o in offsets where o.Address == offset select o).First(); OffsetResponse resp = OffsetHelpers.setOffsetResponse(_offset); return(Request.CreateResponse(HttpStatusCode.OK, resp)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Exception Getting Offset", ex)); } } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "FSUIPC Connection is closed!")); } }