public void Send(DataQueryInteraction DataQueryInteraction) { //NetSimAgent.Instance.SetDQISenderId(DataQueryInteraction.IntPtr, DataQueryInteraction.SenderId); //NetSimAgent.Instance.SetDQIReceiverId(DataQueryInteraction.IntPtr, DataQueryInteraction.ReceiverId); //NetSimAgent.Instance.SetDQIRequestId(DataQueryInteraction.IntPtr, DataQueryInteraction.RequestId); NetSimAgent.Instance.SendDQI(ExerciseConnection.ExerciseConnectionPtr, DataQueryInteraction.IntPtr); }
private void DataQueryInteractionReceived(IntPtr DataQueryInteractionIntPtr) { DataQueryInteraction DataQueryInteraction = new DataQueryInteraction(DataQueryInteractionIntPtr); foreach (var subscriber in DataQueryInteractionSubscribers) { //DataQueryInteraction.IntPtr = DataQueryInteractionIntPtr; //DataQueryInteraction.SenderId = NetSimAgent.Instance.DISenderId(DataQueryInteractionIntPtr); //DataQueryInteraction.ReceiverId = NetSimAgent.Instance.DIReceiverId(DataQueryInteractionIntPtr); //DataQueryInteraction.RequestId = NetSimAgent.Instance.DIRequestId(DataQueryInteractionIntPtr); subscriber(DataQueryInteraction); } }
void DataQueryInteractionCallBack(DataQueryInteraction dataQueryInteraction) { if (!dataQueryInteraction.ReceiverId.Equals(PublishedEntity.MyEntityId)) { return; } int numFixedFieldsRequested = dataQueryInteraction.NumFixedFields; int numVarFieldsRequested = dataQueryInteraction.NumVarFields; if ((numFixedFieldsRequested + numVarFieldsRequested) <= 0) { return; } DataInteraction dataInteraction = new DataInteraction(); for (int i = 1; i <= numFixedFieldsRequested; ++i) { int datumId = dataQueryInteraction.FixedDatumId(i); switch (datumId) { case (int)NetStructs.DatumId.DATUM_STATUS_ORIENTATION_HEADING_FLOAT: { dataInteraction.AddDataInteractionFixedFloat(Camera.transform.rotation.eulerAngles.y, (uint)datumId); break; } case (int)NetStructs.DatumId.DATUM_STATUS_ORIENTATION_PITCH_FLOAT: { float pitch = Camera.transform.rotation.eulerAngles.x; if (pitch > 180) { pitch -= 360; } pitch *= -1; dataInteraction.AddDataInteractionFixedFloat(pitch, (uint)datumId); break; } case (int)NetStructs.DatumId.DATUM_STATUS_FOV_HORIZONTAL: { float hfov = Mathf.Rad2Deg * (2 * Mathf.Atan(Mathf.Tan((Camera.fieldOfView / 2) * Mathf.Deg2Rad) * Camera.aspect)); //google dataInteraction.AddDataInteractionFixedFloat(hfov, (uint)datumId); break; } case (int)NetStructs.DatumId.DATUM_STATUS_FOV_VERTICAL: { float vfov = Camera.fieldOfView; dataInteraction.AddDataInteractionFixedFloat(vfov, (uint)datumId); break; } default: break; } } for (int i = 1; i <= numVarFieldsRequested; ++i) { int datumId = dataQueryInteraction.VarDatumId(i); switch (datumId) { case (int)NetStructs.DatumId.DATUM_STATUS_DEVICE: { string weaponName = InfantryDevices.SelectedDeviceEngName; dataInteraction.AddDataInteractionVarString(weaponName, (int)((weaponName.Length + 1) * sizeof(char)), (uint)datumId); break; } default: break; } } dataInteraction.SenderId = PublishedEntity.MyEntityId; dataInteraction.ReceiverId = dataQueryInteraction.SenderId; dataInteraction.RequestId = dataQueryInteraction.RequestId; DataInteractionManager.Send(dataInteraction); }