Example #1
0
        public async Task <ControllerAction> AddOrUpdateControllerActionAsync(ControllerEvent controllerEvent, string deviceId, int channel, bool isInvert, ControllerButtonType buttonType, ControllerAxisCharacteristic axisCharacteristic, int maxOutputPercent, int axisDeadZonePercent)
        {
            using (await _asyncLock.LockAsync())
            {
                var controllerAction = controllerEvent.ControllerActions.FirstOrDefault(ca => ca.DeviceId == deviceId && ca.Channel == channel);
                if (controllerAction != null)
                {
                    controllerAction.IsInvert            = isInvert;
                    controllerAction.ButtonType          = buttonType;
                    controllerAction.AxisCharacteristic  = axisCharacteristic;
                    controllerAction.MaxOutputPercent    = maxOutputPercent;
                    controllerAction.AxisDeadZonePercent = axisDeadZonePercent;
                    await _creationRepository.UpdateControllerActionAsync(controllerAction);
                }
                else
                {
                    controllerAction = new ControllerAction
                    {
                        DeviceId            = deviceId,
                        Channel             = channel,
                        IsInvert            = isInvert,
                        ButtonType          = buttonType,
                        AxisCharacteristic  = axisCharacteristic,
                        MaxOutputPercent    = maxOutputPercent,
                        AxisDeadZonePercent = axisDeadZonePercent
                    };
                    await _creationRepository.InsertControllerActionAsync(controllerEvent, controllerAction);
                }

                return(controllerAction);
            }
        }
Example #2
0
        public async Task<ControllerAction> AddOrUpdateControllerActionAsync(
            ControllerEvent controllerEvent,
            string deviceId,
            int channel,
            bool isInvert,
            ControllerButtonType buttonType,
            ControllerAxisType axisType,
            ControllerAxisCharacteristic axisCharacteristic,
            int maxOutputPercent,
            int axisActiveZonePercent,
            int axisDeadZonePercent,
            ChannelOutputType channelOutputType,
            int maxServoAngle,
            int servoBaseAngle,
            int stepperAngle,
            string sequenceName)
        {
            using (await _asyncLock.LockAsync())
            {
                var controllerAction = controllerEvent.ControllerActions.FirstOrDefault(ca => ca.DeviceId == deviceId && ca.Channel == channel);
                if (controllerAction != null)
                {
                    controllerAction.IsInvert = isInvert;
                    controllerAction.ButtonType = buttonType;
                    controllerAction.AxisType = axisType;
                    controllerAction.AxisCharacteristic = axisCharacteristic;
                    controllerAction.MaxOutputPercent = maxOutputPercent;
                    controllerAction.AxisActiveZonePercent = axisActiveZonePercent;
                    controllerAction.AxisDeadZonePercent = axisDeadZonePercent;
                    controllerAction.ChannelOutputType = channelOutputType;
                    controllerAction.MaxServoAngle = maxServoAngle;
                    controllerAction.ServoBaseAngle = servoBaseAngle;
                    controllerAction.StepperAngle = stepperAngle;
                    controllerAction.SequenceName = sequenceName;
                    await _creationRepository.UpdateControllerActionAsync(controllerAction);
                }
                else
                {
                    controllerAction = new ControllerAction
                    {
                        DeviceId = deviceId,
                        Channel = channel,
                        IsInvert = isInvert,
                        ButtonType = buttonType,
                        AxisType = axisType,
                        AxisCharacteristic = axisCharacteristic,
                        MaxOutputPercent = maxOutputPercent,
                        AxisActiveZonePercent = axisActiveZonePercent,
                        AxisDeadZonePercent = axisDeadZonePercent,
                        ChannelOutputType = channelOutputType,
                        MaxServoAngle = maxServoAngle,
                        ServoBaseAngle = servoBaseAngle,
                        StepperAngle = stepperAngle,
                        SequenceName = sequenceName
                    };
                    await _creationRepository.InsertControllerActionAsync(controllerEvent, controllerAction);
                }

                return controllerAction;
            }
        }