Esempio n. 1
0
        void sc_OnRecvClientData(SimConnect sender, SIMCONNECT_RECV_CLIENT_DATA data)
        {
            switch ((Requests)data.dwRequestID)
            {
            case Requests.HostAPI0:
            {
                HostAPI0 api0 = (HostAPI0)data.dwData;
            }
            break;

            case Requests.HostAPI1:
            {
                HostAPI1 api1 = (HostAPI1)data.dwData;
                if (api1.RequestedDataIndex < 0 ||
                    api1.RequestedDataIndex > 4)
                {
                    HostException1 exc = new HostException1();
                    exc.RequestorID        = api1.RequestorID;
                    exc.ReqeustedDataIndex = api1.RequestedDataIndex;
                    exc.szErrorMessage     = "HostAPI1: RequestedDataIndex out of range";
                    sender.SetClientData(exc);
                    return;
                }

                HostResponse1 resp = new HostResponse1();

                resp.RequestorID        = api1.RequestorID;
                resp.RequestedDataIndex = api1.RequestedDataIndex;
                switch (api1.RequestedDataIndex)
                {
                case 0:
                    // return the highest valid value for RequestDataIndex
                    resp.RequestedDataValue = 4;
                    break;

                case 1:
                    // return var 1
                    resp.RequestedDataValue = double.Parse(txtVal1.Text);
                    break;

                case 2:
                    // return var 2
                    resp.RequestedDataValue = double.Parse(txtVal2.Text);
                    break;

                case 3:
                    // return var 3
                    resp.RequestedDataValue = double.Parse(txtVal3.Text);
                    break;

                case 4:
                    // return var 4
                    resp.RequestedDataValue = double.Parse(txtVal4.Text);
                    break;
                }
                sender.SetClientData(resp);
            }
            break;
            }
        }
Esempio n. 2
0
        private void GetDataFromHost(int index)
        {
            HostAPI1 api = new HostAPI1();

            api.RequestorID        = guidClient;
            api.RequestedDataIndex = index;

            sc.SetClientData(api);
        }