public async Task DeleteControllerActionAsync(ControllerAction controllerAction)
 {
     using (await _lock.LockAsync())
     {
         await _databaseConnection.DeleteAsync(controllerAction);
     }
 }
示例#2
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);
            }
        }
示例#3
0
 public async Task DeleteControllerActionAsync(ControllerAction controllerAction)
 {
     using (await _asyncLock.LockAsync())
     {
         var parent = controllerAction.ControllerEvent;
         await _creationRepository.DeleteControllerActionAsync(controllerAction);
         parent.ControllerActions.Remove(controllerAction);
     }
 }
        public async Task UpdateControllerActionAsync(
            ControllerAction controllerAction,
            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 otherControllerAction = controllerAction.ControllerEvent.ControllerActions.FirstOrDefault(ca => ca.Id != controllerAction.Id && ca.DeviceId == deviceId && ca.Channel == channel);
                if (otherControllerAction != null)
                {
                    var parent = otherControllerAction.ControllerEvent;
                    await _creationRepository.DeleteControllerActionAsync(otherControllerAction);

                    parent.ControllerActions.Remove(otherControllerAction);
                }

                controllerAction.DeviceId              = deviceId;
                controllerAction.Channel               = channel;
                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);
            }
        }
        public async Task InsertControllerActionAsync(ControllerEvent controllerEvent, ControllerAction controllerAction)
        {
            using (await _lock.LockAsync())
            {
                await _databaseConnection.InsertAsync(controllerAction);

                if (controllerEvent.ControllerActions == null)
                {
                    controllerEvent.ControllerActions = new ObservableCollection <ControllerAction>();
                }

                controllerEvent.ControllerActions.Add(controllerAction);
                await _databaseConnection.UpdateWithChildrenAsync(controllerEvent);
            }
        }
示例#6
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;
            }
        }