コード例 #1
0
        public object Any(XPLMGetDataRefTypes request)
        {
            if (!string.IsNullOrEmpty(request.XPLMDataRefName))
            {
                try{
                    int res = 0;
                    res = XPConnector.GetInstance().DataConnector.XPLMGetDataRefTypes(request.XPLMDataRefName);
                    return(new XPLMGetDataRefTypesResponse {
                        Result = res
                    });
                }
                catch {
                    return(new XPLMGetDataiResponse {
                        Result = -1
                    });
                }
            }
            else if (request.XPLMDataRefHandle > 0)
            {
                try{
                    int res = 0;
                    res = XPConnector.GetInstance().DataConnector.XPLMGetDataRefTypes(request.XPLMDataRefHandle);
                    return(new XPLMGetDataRefTypesResponse {
                        Result = res
                    });
                }
                catch
                {
                    return(new XPLMGetDataiResponse {
                        Result = -1
                    });
                }
            }

            StringBuilder retstr = new StringBuilder();

            retstr.Append("<b>XPLMGetDataRefTypes:</b>" + "<br>");
            retstr.Append("This routine returns the types of the data ref for accessor use. " + "<br>");
            retstr.Append("" + "<br>");
            retstr.Append("<b>Parameter:</b>" + "<br>");
            retstr.Append("DataRefName [string]" + "<br>");
            retstr.Append("http://{yourserver_and_port}/XPLMDataAccess/XPLMGetDataRefTypes?XPLMDataRefName={DataRefName}" + "<br>");
            retstr.Append("<b>or</b>" + "<br>");
            retstr.Append("XPLMDataRefHandle [uint] (getting from XPLMFindDataRef routine)" + "<br>");
            retstr.Append("http://{yourserver_and_port}/XPLMDataAccess/XPLMGetDataRefTypes?DataRefHandle={DataRefHandle}" + "<br>");
            retstr.Append("" + "<br>");
            retstr.Append("<b>Return:</b>" + "<br>");
            retstr.Append("value [int] (-1 on error)" + "<br>");
            retstr.Append("" + "<br>");
            retstr.Append("<b>Meaning:</b>" + "<br>");
            retstr.Append("dtype_int = 0x00" + "<br>");
            retstr.Append("dtype_float = 0x01" + "<br>");
            retstr.Append("dtype_double = 0x02" + "<br>");
            retstr.Append("dtype_handle = 0x03" + "<br>");
            retstr.Append("dtype_float_array = 0x04" + "<br>");
            retstr.Append("dtype_int_array = 0x05" + "<br>");
            retstr.Append("dtype_byte_array = 0x06" + "<br>");

            return(new HttpResult(retstr.ToString(), System.Net.HttpStatusCode.OK));
        }
コード例 #2
0
        public object Any(XPLMSetDatab request)
        {
            if (!string.IsNullOrEmpty(request.XPLMDataRefName))
            {
                try
                {
                    XPConnector.GetInstance().DataConnector.XPLMSetDatab(request.XPLMDataRefName, request.values);
                    return(new XPLMSetDatabResponse {
                        Result = string.Empty
                    });
                }
                catch (Exception ex)
                {
                    return(new XPLMSetDatabResponse {
                        Result = ex.Message
                    });
                }
            }
            else if (request.XPLMDataRefHandle > 0)
            {
                try
                {
                    XPConnector.GetInstance().DataConnector.XPLMSetDatab(request.XPLMDataRefHandle, request.values);
                    return(new XPLMSetDatabResponse {
                        Result = string.Empty
                    });
                }
                catch (Exception ex)
                {
                    return(new XPLMSetDatabResponse {
                        Result = ex.Message
                    });
                }
            }

            StringBuilder retstr = new StringBuilder();

            retstr.Append("<b>XPLMSetDatab:</b>" + "<br>");
            retstr.Append("Write part or all of an array of bytes. " + "<br>");
            retstr.Append("" + "<br>");
            retstr.Append("<b>Parameter:</b>" + "<br>");
            retstr.Append("DataRefName [string]" + "<br>");
            retstr.Append("values [byte[]]" + "<br>");
            retstr.Append("http://{yourserver_and_port}/XPLMDataAccess/XPLMSetDatab?XPLMDataRefName={DataRefName}&values={values}" + "<br>");
            retstr.Append("<b>or</b>" + "<br>");
            retstr.Append("XPLMDataRefHandle [uint] (getting from XPLMFindDataRef routine)" + "<br>");
            retstr.Append("values [byte[]]" + "<br>");
            retstr.Append("http://{yourserver_and_port}/XPLMDataAccess/XPLMSetDatab?DataRefHandle={DataRefHandle}&values={values}" + "<br>");
            retstr.Append("" + "<br>");
            retstr.Append("<b>Return:</b>" + "<br>");
            retstr.Append("result [string] (empty when ok)" + "<br>");

            return(new HttpResult(retstr.ToString(), System.Net.HttpStatusCode.OK));
        }
コード例 #3
0
        public object Any(XPLMGetDataf request)
        {
            if (!string.IsNullOrEmpty(request.XPLMDataRefName))
            {
                try
                {
                    float res = 0;
                    res = XPConnector.GetInstance().DataConnector.XPLMGetDataf(request.XPLMDataRefName);
                    return(new XPLMGetDatafResponse {
                        Result = res
                    });
                }
                catch
                {
                    return(new XPLMGetDatafResponse {
                        Result = -999
                    });
                }
            }
            else if (request.XPLMDataRefHandle > 0)
            {
                try
                {
                    float res = 0;
                    res = XPConnector.GetInstance().DataConnector.XPLMGetDataf(request.XPLMDataRefHandle);
                    return(new XPLMGetDatafResponse {
                        Result = res
                    });
                }
                catch
                {
                    return(new XPLMGetDatafResponse {
                        Result = -999
                    });
                }
            }

            StringBuilder retstr = new StringBuilder();

            retstr.Append("<b>XPLMGetDataf:</b>" + "<br>");
            retstr.Append("Read a single precision floating point (float) data ref. " + "<br>");
            retstr.Append("" + "<br>");
            retstr.Append("<b>Parameter:</b>" + "<br>");
            retstr.Append("DataRefName [string]" + "<br>");
            retstr.Append("http://{yourserver_and_port}/XPLMDataAccess/XPLMGetDataf?XPLMDataRefName={DataRefName}" + "<br>");
            retstr.Append("<b>or</b>" + "<br>");
            retstr.Append("XPLMDataRefHandle [uint] (getting from XPLMFindDataRef routine)" + "<br>");
            retstr.Append("http://{yourserver_and_port}/XPLMDataAccess/XPLMGetDataf?DataRefHandle={DataRefHandle}" + "<br>");
            retstr.Append("" + "<br>");
            retstr.Append("<b>Return:</b>" + "<br>");
            retstr.Append("value [float] (-999 on error)" + "<br>");

            return(new HttpResult(retstr.ToString(), System.Net.HttpStatusCode.OK));
        }
コード例 #4
0
        public object Any(XPLMCanWriteDataRef request)
        {
            if (!string.IsNullOrEmpty(request.XPLMDataRefName))
            {
                try{
                    int res = 0;
                    res = XPConnector.GetInstance().DataConnector.XPLMCanWriteDataRef(request.XPLMDataRefName);
                    return(new XPLMCanWriteDataRefResponse {
                        Result = res
                    });
                }
                catch
                {
                    return(new XPLMGetDataiResponse {
                        Result = -1
                    });
                }
            }
            else if (request.XPLMDataRefHandle > 0)
            {
                try{
                    int res = 0;
                    res = XPConnector.GetInstance().DataConnector.XPLMCanWriteDataRef(request.XPLMDataRefHandle);
                    return(new XPLMCanWriteDataRefResponse {
                        Result = res
                    });
                }
                catch
                {
                    return(new XPLMGetDataiResponse {
                        Result = -1
                    });
                }
            }

            StringBuilder retstr = new StringBuilder();

            retstr.Append("<b>XPLMCanWriteDataRef:</b>" + "<br>");
            retstr.Append("This routine returns 1 if you can successfully set the data, 0 otherwise. Some datarefs are read-only. " + "<br>");
            retstr.Append("" + "<br>");
            retstr.Append("<b>Parameter:</b>" + "<br>");
            retstr.Append("DataRefName [string]" + "<br>");
            retstr.Append("http://{yourserver_and_port}/XPLMDataAccess/XPLMCanWriteDataRef?XPLMDataRefName={DataRefName}" + "<br>");
            retstr.Append("<b>or</b>" + "<br>");
            retstr.Append("XPLMDataRefHandle [uint] (getting from XPLMFindDataRef routine)" + "<br>");
            retstr.Append("http://{yourserver_and_port}/XPLMDataAccess/XPLMCanWriteDataRef?DataRefHandle={DataRefHandle}" + "<br>");
            retstr.Append("" + "<br>");
            retstr.Append("<b>Return:</b>" + "<br>");
            retstr.Append("value [int] (-1 on error)" + "<br>");

            return(new HttpResult(retstr.ToString(), System.Net.HttpStatusCode.OK));
        }
コード例 #5
0
        public object Any(XPLMFindDataRef request)
        {
            if (!string.IsNullOrEmpty(request.XPLMDataRefName))
            {
                try{
                    uint   res  = 0;
                    string name = request.XPLMDataRefName;
                    res = XPConnector.GetInstance().DataConnector.XPLMFindDataRef(request.XPLMDataRefName);
                    return(new XPLMFindDataRefResponse {
                        Result = res
                    });
                }
                catch
                {
                    return(new XPLMGetDataiResponse {
                        Result = -1
                    });
                }
            }

            StringBuilder retstr = new StringBuilder();

            retstr.Append("<b>XPLMFindDataRef:</b>" + "<br>");
            retstr.Append("Returns a uint handle from named data ref." + "<br>");
            retstr.Append("" + "<br>");
            retstr.Append("<b>NOTE:</b> this function is relatively expensive; save the XPLMDataRef this function returns for future use." + "<br>");
            retstr.Append("Do not look up your data ref by string every time you need to read or write it." + "<br>");
            retstr.Append("" + "<br>");
            retstr.Append("<b>Parameter:</b>" + "<br>");
            retstr.Append("DataRefName [string]" + "<br>");
            retstr.Append("" + "<br>");
            retstr.Append("http://{yourserver_and_port}/XPLMDataAccess/XPLMFindDataRef?XPLMDataRefName={DataRefName}" + "<br>");
            retstr.Append("" + "<br>");
            retstr.Append("<b>Return:</b>" + "<br>");
            retstr.Append("value [uint] (-1 on error)" + "<br>");

            return(new HttpResult(retstr.ToString(), System.Net.HttpStatusCode.OK));
        }
コード例 #6
0
        public object Any(XPLMGetDatavi request)
        {
            if (!string.IsNullOrEmpty(request.XPLMDataRefName))
            {
                try
                {
                    Int16[] res = new Int16[1] {
                        0
                    };
                    res = XPConnector.GetInstance().DataConnector.XPLMGetDatavi(request.XPLMDataRefName);
                    return(new XPLMGetDataviResponse {
                        Result = res
                    });
                }
                catch
                {
                    return(new XPLMGetDataviResponse {
                        Result = new Int16[1] {
                            -1
                        }
                    });
                }
            }
            else if (request.XPLMDataRefHandle > 0)
            {
                try
                {
                    Int16[] res = new Int16[1] {
                        0
                    };
                    res = XPConnector.GetInstance().DataConnector.XPLMGetDatavi(request.XPLMDataRefHandle);
                    return(new XPLMGetDataviResponse {
                        Result = res
                    });
                }
                catch
                {
                    return(new XPLMGetDataviResponse {
                        Result = new Int16[1] {
                            -1
                        }
                    });
                }
            }

            StringBuilder retstr = new StringBuilder();

            retstr.Append("<b>XPLMGetDatavi:</b>" + "<br>");
            retstr.Append("Read a part of an array of integers. Returns number of ints returned." + "<br>");
            retstr.Append("" + "<br>");
            retstr.Append("<b>Parameter:</b>" + "<br>");
            retstr.Append("DataRefName [string]" + "<br>");
            retstr.Append("http://{yourserver_and_port}/XPLMDataAccess/XPLMGetDatavi?XPLMDataRefName={DataRefName}" + "<br>");
            retstr.Append("<b>or</b>" + "<br>");
            retstr.Append("XPLMDataRefHandle [uint] (getting from XPLMFindDataRef routine)" + "<br>");
            retstr.Append("http://{yourserver_and_port}/XPLMDataAccess/XPLMGetDatavi?DataRefHandle={DataRefHandle}" + "<br>");
            retstr.Append("" + "<br>");
            retstr.Append("<b>Return:</b>" + "<br>");
            retstr.Append("values [int[]] (one -1 on error)" + "<br>");

            return(new HttpResult(retstr.ToString(), System.Net.HttpStatusCode.OK));
        }