Example #1
0
        public FfbEngineLogic(IReportDescriptorProperties reportDescriptorProperties)
        {
            _effectsContainer           = new EffectsContainer(reportDescriptorProperties);
            _reportDescriptorProperties = reportDescriptorProperties;

            pidState.status = 30;
            pidState.effectPlayingAndEffectBlockIndex = 0;
        }
        public EffectsContainer(IReportDescriptorProperties reportDescriptorProperties)
        {
            _effects = new List <IEffect>();

            ICalculationProvider calculationProvider = TinyIoCContainer.Current.Resolve <ICalculationProvider>();

            _reportDescriptorProperties = reportDescriptorProperties;

            efectsDict = new Dictionary <EFFECT_TYPE, IEffectType>()
            {
                { EFFECT_TYPE.CONSTANT, new ConstantEffect(calculationProvider) },
                { EFFECT_TYPE.RAMP, new RampEffect(calculationProvider) },
                { EFFECT_TYPE.SQUARE, new SquareEffect(calculationProvider, reportDescriptorProperties) },
                { EFFECT_TYPE.SINE, new SineEffect(calculationProvider, reportDescriptorProperties) },
                { EFFECT_TYPE.TRIANGLE, new TriangleEffect(calculationProvider, reportDescriptorProperties) },
                { EFFECT_TYPE.SAWTOOTH_UP, new SawtoothDownEffect(calculationProvider, reportDescriptorProperties) },
                { EFFECT_TYPE.SAWTOOTH_DOWN, new SawtoothUpEffect(calculationProvider, reportDescriptorProperties) },
                { EFFECT_TYPE.SPRING, new SpringEffect(calculationProvider) },
                { EFFECT_TYPE.DAMPER, new DamperEffect(calculationProvider) },
                { EFFECT_TYPE.INERTIA, new InertiaEffect(calculationProvider) },
                { EFFECT_TYPE.FRICTION, new FrictionEffect(calculationProvider) },
                { EFFECT_TYPE.CUSTOM, new CustomEffect(calculationProvider) }
            };
        }
Example #3
0
 public CalculationProvider(IReportDescriptorProperties reportDescriptorProperties)
 {
     _reportDescriptorProperties = reportDescriptorProperties;
 }
Example #4
0
 public SquareEffect(ICalculationProvider calculationProvider, IReportDescriptorProperties reportDescriptorProperties)
 {
     _calculationProvider        = calculationProvider;
     _reportDescriptorProperties = reportDescriptorProperties;
 }
Example #5
0
 public Effect(IEffectType effect, IReportDescriptorProperties reportDescriptorProperties)
 {
     _effect                     = effect;
     _structDictonary            = new Dictionary <string, object>();
     _reportDescriptorProperties = reportDescriptorProperties;
 }
Example #6
0
        public vJoyFfbHandler(vJoy joystick, IReportDescriptorProperties reportDescriptorProperties, ILogger logger)
        {
            _logger   = logger;
            _joystick = joystick;
            FfbEngineFactory factory = new FfbEngineFactory(reportDescriptorProperties);

            _ffbEngine = factory.Create();

            EffectOperationMapper = new Dictionary <FFBOP, EFFECT_OPERATION>()
            {
                { FFBOP.EFF_START, EFFECT_OPERATION.START },
                { FFBOP.EFF_SOLO, EFFECT_OPERATION.SOLO },
                { FFBOP.EFF_STOP, EFFECT_OPERATION.STOP }
            };

            EffectTypeMapper = new Dictionary <FFBEType, EFFECT_TYPE>()
            {
                { FFBEType.ET_CONST, EFFECT_TYPE.CONSTANT },
                { FFBEType.ET_RAMP, EFFECT_TYPE.RAMP },
                { FFBEType.ET_SQR, EFFECT_TYPE.SQUARE },
                { FFBEType.ET_SINE, EFFECT_TYPE.SINE },
                { FFBEType.ET_TRNGL, EFFECT_TYPE.TRIANGLE },
                { FFBEType.ET_STUP, EFFECT_TYPE.SAWTOOTH_UP },
                { FFBEType.ET_STDN, EFFECT_TYPE.SAWTOOTH_DOWN },
                { FFBEType.ET_SPRNG, EFFECT_TYPE.SPRING },
                { FFBEType.ET_DMPR, EFFECT_TYPE.DAMPER },
                { FFBEType.ET_INRT, EFFECT_TYPE.INERTIA },
                { FFBEType.ET_FRCTN, EFFECT_TYPE.FRICTION },
                { FFBEType.ET_CSTM, EFFECT_TYPE.CUSTOM }
            };

            FfbReportMapper = new Dictionary <string, Func <object, object> >()
            {
                { "SetEffect", SetEffectMapper },
                { "SetEnvelope", EnvelopeMapper },
                { "SetCondition", ConditionMapper },
                { "SetPeriodic", PeriodMapper },
                { "SetConstantForce", ConstantMapper },
                { "SetRampForce", RampMapper },
                { "EffectOperation", OperationMapper },
                { "DeviceGain", DeviceGainMapper },
                { "PIDDeviceControl", PidDeviceControlMapper },
                { "PIDBlockFree", BlockFreeMapper },
                { "CreateNewEffect", CreateNewEffectMapper },
                { "BlockLoad", PidBlockLoadMapper },
                { "PIDState", PidStateMapper },
                { "CustomForceData", null },
                { "SetCustomForce", null }
            };

            FfbReportTypeMapper = new Dictionary <FFBPType, string>()
            {
                { FFBPType.PT_EFFREP, "SetEffect" },
                { FFBPType.PT_ENVREP, "SetEnvelope" },
                { FFBPType.PT_CONDREP, "SetCondition" },
                { FFBPType.PT_PRIDREP, "SetPeriodic" },
                { FFBPType.PT_CONSTREP, "SetConstantForce" },
                { FFBPType.PT_RAMPREP, "SetRampForce" },
                { FFBPType.PT_EFOPREP, "EffectOperation" },
                { FFBPType.PT_GAINREP, "DeviceGain" },
                { FFBPType.PT_CTRLREP, "PIDDeviceControl" },
                { FFBPType.PT_BLKFRREP, "PIDBlockFree" },
                { FFBPType.PT_NEWEFREP, "CreateNewEffect" },
                { FFBPType.PT_BLKLDREP, "BlockLoad" },
                { FFBPType.PT_POOLREP, "PIDState" },
                { FFBPType.PT_CSTMREP, "CustomForceData" },
                { FFBPType.PT_SETCREP, "SetCustomForce" }
            };

            PidControlMapper = new Dictionary <FFB_CTRL, PID_CONTROL>()
            {
                { FFB_CTRL.CTRL_ENACT, PID_CONTROL.ENABLE_ACTUATORS },
                { FFB_CTRL.CTRL_DISACT, PID_CONTROL.DISABLE_ACTUATORS },
                { FFB_CTRL.CTRL_STOPALL, PID_CONTROL.STOP_ALL_EFFECTS },
                { FFB_CTRL.CTRL_DEVRST, PID_CONTROL.RESET },
                { FFB_CTRL.CTRL_DEVPAUSE, PID_CONTROL.PAUSE },
                { FFB_CTRL.CTRL_DEVCONT, PID_CONTROL.CONTINUE },
            };
        }
 public FfbEngineFactory(IReportDescriptorProperties reportDescriptorProperties)
 {
     TinyIoCContainer.Current.Register <ICalculationProvider>(new CalculationProvider(reportDescriptorProperties));
     _ffbLogic = new FfbEngineLogic(reportDescriptorProperties);
 }