Ejemplo n.º 1
0
 public DeviceSetDTO(DeviceSet deviceSet, string mac)
 {
     this.clientId     = mac;
     this.bdlDsetId    = deviceSet.Bdl_Dset_Id.ToString();
     this.Gmt_Create   = deviceSet.Gmt_Create.ToString().Replace("/", "-");
     this.Gmt_Modified = deviceSet.Gmt_Modified.ToString().Replace("/", "-");
     this.DSet_Name    = deviceSet.DSet_Name;
 }
Ejemplo n.º 2
0
        public TestContext(DeviceSet defaultSet)
        {
            //new Mallos.Input.RawDeviceSet(windowHandle.Value), // TODO: Window Handle

            // Add the different types of input context.
            DeviceSets = new List <DeviceSet>(new[]
            {
                defaultSet,
                new Mallos.Input.Dummy.DummyDeviceSet(),
            });

            // Create a input system and register a few inputs.
            InputSystem = new InputSystem(defaultSet.Keyboard, defaultSet.Mouse);
            InputSystem.Actions.Add(new InputAction("Jump", Keys.Space));
            InputSystem.Axis.Add(new InputAxis("MoveForward", Keys.W, 1.0f));
            InputSystem.Axis.Add(new InputAxis("MoveForward", Keys.S, -1.0f));

            // Create a combo tracker and register a few combos.
            ComboTracker = new ComboTracker(defaultSet.KeyboardTracker, 0.5f, 4);
            ComboTracker.OnComboCalled += ComboTracker_OnComboCalled;
            ComboTracker.SequenceCombos.Add(new SequenceCombo("Attack1", Keys.A, Keys.B, Keys.C));
            ComboTracker.SequenceCombos.Add(new SequenceCombo("Attack2", Keys.A, Keys.C, Keys.B));
            ComboTracker.SequenceCombos.Add(new SequenceCombo("Attack3", Buttons.A, Buttons.B, Buttons.X));
        }
Ejemplo n.º 3
0
        private void TestWindwow_Input(DeviceSet inputContext)
        {
            string windowTitle = inputContext.Name + " Input";

            ImGui.BeginWindow(windowTitle);
            {
                if (inputContext.Keyboard != null)
                {
                    var keyboardState = inputContext.Keyboard.GetCurrentState();
                    if (ImGui.CollapsingHeader($"Keyboard (Name: \"{ inputContext.Keyboard.Name }\")", TreeNodeFlags.CollapsingHeader))
                    {
                        foreach (var item in keyboardState.Keys)
                        {
                            ImGui.Text(item.ToString());
                        }
                    }
                }

                if (inputContext.Mouse != null)
                {
                    var mouseState = inputContext.Mouse.GetCurrentState();
                    if (ImGui.CollapsingHeader($"Mouse (Name: \"{ inputContext.Mouse.Name }\")", TreeNodeFlags.CollapsingHeader))
                    {
                        sb.AppendLine($"Position: { mouseState.X }, { mouseState.Y }");
                        sb.AppendLine($"MouseWheel: { mouseState.ScrollWheelValue }");
                        sb.AppendLine();
                        sb.AppendLine($"Left Button: { mouseState.LeftButton }");
                        sb.AppendLine($"Middle Button: { mouseState.MiddleButton }");
                        sb.AppendLine($"Right Button: { mouseState.RightButton }");
                        sb.AppendLine($"XButton1: { mouseState.XButton1 }");
                        sb.AppendLine($"XButton2: { mouseState.XButton2 }");

                        ImGui.Text(sb.ToString());

                        sb.Clear();
                    }
                }

                if (ImGui.CollapsingHeader("GamePads", TreeNodeFlags.CollapsingHeader))
                {
                    for (int i = 0; i < 4; i++)
                    {
                        if (ImGui.CollapsingHeader($"GamePad [{ i }]", TreeNodeFlags.CollapsingHeader))
                        {
                            var gamepadState = inputContext.GamePads[i].GetCurrentState();

                            ImGui.Text($"Name: { inputContext.GamePads[i].Name }");
                            ImGui.Text($"IsConnected: { gamepadState.IsConnected }");

                            ImGui.BeginChild($"GamePad.{i}.Child1", true);
                            if (ImGui.CollapsingHeader("Buttons", TreeNodeFlags.CollapsingHeader))
                            {
                                var buttonValues = System.Enum.GetValues(typeof(Buttons));
                                for (int i2 = 0; i2 < buttonValues.Length; i2++)
                                {
                                    Buttons button     = (Buttons)buttonValues.GetValue(i2);
                                    var     buttonDown = gamepadState.Buttons.IsButtonDown(button);
                                    ImGui.Text($"{ button } = { buttonDown }");
                                }
                            }

                            if (ImGui.CollapsingHeader("ThumbSticks", TreeNodeFlags.CollapsingHeader))
                            {
                                ImGui.Text($"Left: { gamepadState.ThumbSticks.LeftThumbstick.X }, { gamepadState.ThumbSticks.LeftThumbstick.Y }");
                                ImGui.Text($"Right: { gamepadState.ThumbSticks.RightThumbstick.X }, { gamepadState.ThumbSticks.RightThumbstick.Y }");
                            }

                            if (ImGui.CollapsingHeader("Triggers", TreeNodeFlags.CollapsingHeader))
                            {
                                ImGui.Text($"Left: { gamepadState.Triggers.Left }");
                                ImGui.Text($"Right: { gamepadState.Triggers.Right }");
                            }
                            ImGui.EndChild();
                        }
                    }
                }

                //if (ImGui.CollapsingHeader("Touch", TreeNodeFlags.CollapsingHeader))
                //{
                //    ImGui.Text("Hello World!");
                //}
            }
            ImGui.EndWindow();
        }
Ejemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="uploadManagement">传入上传管理者实体</param>
        /// <returns>返回可以用来上传的辅助对象</returns>
        public ServiceResult GetServiceResult(UploadManagement uploadManagement)
        {
            //service返回结果对象
            ServiceResult serviceResult = new ServiceResult();
            //提前载入唯一Setter
            SetterDAO setterDAO = new SetterDAO();
            Setter    setter    = setterDAO.getSetter();
            //需要加入解密逻辑 TODO
            string mac = "";

            //try
            //{
            //    byte[] deBytes = AesUtil.Decrypt(Encoding.GetEncoding("GBK").GetBytes(setter.Set_Unique_Id),
            //        ProtocolConstant.USB_DOG_PASSWORD);
            //    mac = Encoding.GetEncoding("GBK").GetString(deBytes);
            //}
            //catch (Exception ex)
            //{
            //    mac = setter.Set_Unique_Id.Replace(":", "");
            //}
            byte[] a = ProtocolUtil.StringToBcd(setter.Set_Unique_Id);
            byte[] b = AesUtil.Decrypt(a, ProtocolConstant.USB_DOG_PASSWORD);
            mac = Encoding.GetEncoding("GBK").GetString(b).Replace(":", "-");

            ///if识别出表,设置发送路径,select出实体,转化至DTO,json打成string,返回
            //识别是否是权限用户添加
            if (uploadManagement.UM_DataTable == "bdl_auth")
            {
                AuthDAO authDAO = new AuthDAO();
                Auther  auther  = authDAO.Load(uploadManagement.UM_DataId);
                if (auther == null)
                {
                    return(null);
                }
                AutherDTO autherDTO = new AutherDTO(setter, auther, mac);


                //serviceResult.URL = "clientController/addClient.action";
                serviceResult.Data = JsonTools.Obj2JSONStrNew <AutherDTO>(autherDTO);
            }
            //bdl_customdata表
            else if (uploadManagement.UM_DataTable == "bdl_customdata")
            {
                CustomDataDAO customDataDAO = new CustomDataDAO();
                CustomData    customData    = customDataDAO.Load(uploadManagement.UM_DataId);
                if (customData == null)
                {
                    return(null);
                }
                CustomDataDTO customDataDTO = new CustomDataDTO(customData, mac);
                serviceResult.Data = JsonTools.Obj2JSONStrNew <CustomDataDTO>(customDataDTO);
            }
            //bdl_datacode表
            else if (uploadManagement.UM_DataTable == "bdl_datacode")
            {
                DataCodeDAO dataCodedao = new DataCodeDAO();
                DataCode    dataCode    = dataCodedao.Load(uploadManagement.UM_DataId);

                if (dataCode == null)
                {
                    return(null);
                }
                DataCodeDTO dataCodeDTO = new DataCodeDTO(dataCode, mac);
                serviceResult.Data = JsonTools.Obj2JSONStrNew <DataCodeDTO>(dataCodeDTO);
            }
            //bdl_deviceset表
            else if (uploadManagement.UM_DataTable == "bdl_deviceset")
            {
                DeviceSetDAO deviceSetDAO = new DeviceSetDAO();
                DeviceSet    deviceSet    = deviceSetDAO.Load(uploadManagement.UM_DataId);
                if (deviceSet == null)
                {
                    return(null);
                }
                DeviceSetDTO deviceSetDTO = new DeviceSetDTO(deviceSet, mac);

                serviceResult.Data = JsonTools.Obj2JSONStrNew <DeviceSetDTO>(deviceSetDTO);
            }
            //bdl_devicesort表
            else if (uploadManagement.UM_DataTable == "bdl_devicesort")
            {
                DeviceSortDAO deviceSortDAO = new DeviceSortDAO();
                DeviceSort    deviceSort    = deviceSortDAO.Load(uploadManagement.UM_DataId);
                if (deviceSort == null)
                {
                    return(null);
                }
                DeviceSortDTO deviceSortDTO = new DeviceSortDTO(deviceSort, mac);


                serviceResult.Data = JsonTools.Obj2JSONStrNew <DeviceSortDTO>(deviceSortDTO);
            }
            //bdl_onlinedevice表
            else if (uploadManagement.UM_DataTable == "bdl_onlinedevice")
            {
                OnlineDeviceDAO onlineDeviceDAO = new OnlineDeviceDAO();
                OnlineDevice    onlineDevice    = onlineDeviceDAO.Load(uploadManagement.UM_DataId);

                if (onlineDevice == null)
                {
                    return(null);
                }
                OnlineDeviceDTO onlineDeviceDTO = new OnlineDeviceDTO(onlineDevice, mac);

                serviceResult.Data = JsonTools.Obj2JSONStrNew <OnlineDeviceDTO>(onlineDeviceDTO);
            }
            //bdl_set表
            else if (uploadManagement.UM_DataTable == "bdl_set")
            {
                SetterDAO setterDAO1 = new SetterDAO();
                Setter    setter1    = setterDAO1.Load(uploadManagement.UM_DataId);

                if (setter1 == null)
                {
                    return(null);
                }

                SetterDTO setterDTO = new SetterDTO(setter1, mac);

                serviceResult.Data = JsonTools.Obj2JSONStrNew <SetterDTO>(setterDTO);
            }
            //病人表
            else if (uploadManagement.UM_DataTable == "bdl_user")
            {
                UserDAO userDAO = new UserDAO();
                User    user    = userDAO.Load(uploadManagement.UM_DataId);
                if (user == null)
                {
                    return(null);
                }


                UserDTO userDTO = new UserDTO(user, mac);
                //serviceResult.URL = "bigData/bodyStrongUser";
                serviceResult.Data = JsonTools.Obj2JSONStrNew <UserDTO>(userDTO);
            }

            //症状表
            else if (uploadManagement.UM_DataTable == "bdl_symptominfo")
            {
                SymptomInfoDao symptomInfoDao = new SymptomInfoDao();
                var            result         = symptomInfoDao.Load(uploadManagement.UM_DataId);
                if (result == null)
                {
                    return(null);
                }


                SymptomInfoDTO symptomInfoDTO = new SymptomInfoDTO(result, mac);
                //serviceResult.URL = "bigData/symptomInfo";
                serviceResult.Data = JsonTools.Obj2JSONStrNew <SymptomInfoDTO>(symptomInfoDTO);
            }

            //训练处方总表
            else if (uploadManagement.UM_DataTable == "bdl_traininfo")
            {
                TrainInfoDAO trainInfoDAO = new TrainInfoDAO();
                var          result       = trainInfoDAO.Load(uploadManagement.UM_DataId);
                if (result == null)
                {
                    return(null);
                }


                TrainInfoDTO trainInfoDTO = new TrainInfoDTO(result, mac);
                //serviceResult.URL = "bigData/trainInfo";
                serviceResult.Data = JsonTools.Obj2JSONStrNew <TrainInfoDTO>(trainInfoDTO);
            }

            //总表中的一条数据对某台设备的具体处方
            else if (uploadManagement.UM_DataTable == "bdl_deviceprescription")
            {
                DevicePrescriptionDAO devicePrescriptionDAO = new DevicePrescriptionDAO();
                var result = devicePrescriptionDAO.Load(uploadManagement.UM_DataId);
                if (result == null)
                {
                    return(null);
                }


                DevicePrescriptionDTO devicePrescriptionDTO = new DevicePrescriptionDTO(result, mac);
                //serviceResult.URL = "bigData/devicePrescription";
                serviceResult.Data = JsonTools.Obj2JSONStrNew <DevicePrescriptionDTO>(devicePrescriptionDTO);
            }
            //具体处方的具体反馈
            else if (uploadManagement.UM_DataTable == "bdl_prescriptionresult")
            {
                PrescriptionResultDAO prescriptionResultDAO = new PrescriptionResultDAO();
                var result = prescriptionResultDAO.Load(uploadManagement.UM_DataId);
                if (result == null)
                {
                    return(null);
                }


                PrescriptionResultDTO prescriptionResultDTO = new PrescriptionResultDTO(result, mac);
                //serviceResult.URL = "bigData/prescriptionResult";
                serviceResult.Data = JsonTools.Obj2JSONStrNew <PrescriptionResultDTO>(prescriptionResultDTO);
            }
            else if (uploadManagement.UM_DataTable == "bdl_physicalpower")
            {
                PhysicalPowerDAO physicalPowerDAO = new PhysicalPowerDAO();
                var result = physicalPowerDAO.Load(uploadManagement.UM_DataId);
                if (result == null)
                {
                    return(null);
                }

                PhysicalPowerDTO physicalPowerDTO = new PhysicalPowerDTO(result, mac);
                //serviceResult.URL = "bigData/physicalPower";
                serviceResult.Data = JsonTools.Obj2JSONStrNew <PhysicalPowerDTO>(physicalPowerDTO);
            }
            else if (uploadManagement.UM_DataTable == "bdl_error")
            {
                ErrorDao errorDao = new ErrorDao();
                var      result   = errorDao.Load(uploadManagement.UM_DataId);
                if (result == null)
                {
                    return(null);
                }

                ErrorDTO errorDTO = new ErrorDTO(result, mac);
                //serviceResult.URL = "bigData/physicalPower";
                serviceResult.Data = JsonTools.Obj2JSONStrNew <ErrorDTO>(errorDTO);
            }

            return(serviceResult);
        }
    Sprite FilterForDeviceInputBinding(DeviceSet targetDeviceSet, string inputBinding)
    {
        Sprite spriteIcon = null;

        switch (inputBinding)
        {
        case "Button North":
            spriteIcon = targetDeviceSet.deviceDisplaySettings.buttonNorthIcon;
            break;

        case "Button South":
            spriteIcon = targetDeviceSet.deviceDisplaySettings.buttonSouthIcon;
            break;

        case "Button West":
            spriteIcon = targetDeviceSet.deviceDisplaySettings.buttonWestIcon;
            break;

        case "Button East":
            spriteIcon = targetDeviceSet.deviceDisplaySettings.buttonEastIcon;
            break;

        case "Right Shoulder":
            spriteIcon = targetDeviceSet.deviceDisplaySettings.triggerRightFrontIcon;
            break;

        case "Right Trigger":
            spriteIcon = targetDeviceSet.deviceDisplaySettings.triggerRightBackIcon;
            break;

        case "rightTriggerButton":
            spriteIcon = targetDeviceSet.deviceDisplaySettings.triggerRightBackIcon;
            break;

        case "Left Shoulder":
            spriteIcon = targetDeviceSet.deviceDisplaySettings.triggerLeftFrontIcon;
            break;

        case "Left Trigger":
            spriteIcon = targetDeviceSet.deviceDisplaySettings.triggerLeftBackIcon;
            break;

        case "leftTriggerButton":
            spriteIcon = targetDeviceSet.deviceDisplaySettings.triggerLeftBackIcon;
            break;

        default:

            for (int i = 0; i < targetDeviceSet.deviceDisplaySettings.customContextIcons.Count; i++)
            {
                if (targetDeviceSet.deviceDisplaySettings.customContextIcons[i].customInputContextString == inputBinding)
                {
                    if (targetDeviceSet.deviceDisplaySettings.customContextIcons[i].customInputContextIcon != null)
                    {
                        spriteIcon = targetDeviceSet.deviceDisplaySettings.customContextIcons[i].customInputContextIcon;
                    }
                }
            }


            break;
        }

        return(spriteIcon);
    }