internal JoyStickChannel(string ChannelName, MotorSimulation Motor, double Value, double PosLimit, double NegLimit) { channelName = ChannelName; motor = Motor; upperLmt = PosLimit; lowerLmt = NegLimit; backupValue = Value; currentValue = Value; Bond(); }
async Task <bool> CheckMotionStatusDoneAsyn(MotorSimulation Motor) { var task = Task.Run(async() => { await Task.Yield(); while (Motor.Status == MotorSimulation.StatusEnum.EXECUTING) { } }); return(await Task.WhenAny(task, Task.Delay(10000)) == task); }
public async Task TriggerCommandAsync(DirectionEnum Dir) { int set = (int)mCurrentChannelSet; mCurDirection = Dir; bool syncX = false; bool syncY = false; if (mChannelSets[set].ChannelX != null && IsVectorX()) { SetJoyCurSpeedModeX(); syncX = mChannelSets[set].ChannelX.Increment(mFactorX * StepX()); } if (mChannelSets[set].ChannelY != null && IsVectorY()) { SetJoyCurSpeedModeY(); syncY = mChannelSets[set].ChannelY.Increment(mFactorY * StepY()); } if (syncX || syncY) { CallBackFunction(mCallback); } if (syncX) { MotorSimulation motor = mChannelSets[set].ChannelX.GetMotor(); var task = CheckMotionStatusDoneAsyn(motor); FailureHandling(await task); } if (syncY) { MotorSimulation motor = mChannelSets[set].ChannelY.GetMotor(); var task = CheckMotionStatusDoneAsyn(motor); FailureHandling(await task); } }
public void SetYChannel(string Name, int Value, MotorSimulation Motor, double PosLimit = 9999, double NegLimit = 9999, SETEnum Set = SETEnum.ONE) { int set = (int)Set; mChannelSets[set].ChannelY = new JoyStickChannel(Name, Motor, Value, PosLimit, NegLimit); }