/// <summary> /// /// </summary> /// <param name="windowSizeMillis">millis</param> /// <param name="pin"></param> /// <param name="samplingRate"></param> /// <param name="readProcess"></param> /// <param name="readOutput"></param> /// <param name="readSetPoint"></param> /// <param name="proportionalGain"></param> /// <param name="integralGain"></param> /// <param name="derivativeGain"></param> /// <param name="controllerDirection"></param> /// <param name="controllerMode"></param> public TimeProportionedPidController(string name, ulong windowSizeMillis, WisePin pin, TimeSpan samplingRate, Func <int> stopSimulatedProcess, Func <int> readProcess, Func <ulong> readOutput, Action <ulong> writeOutput, Func <int> readSetPoint, float proportionalGain, float integralGain, float derivativeGain, ControllerMode controllerMode = ControllerMode.Automatic) : base(name, samplingRate, (float)0.0, (float)100.0, readProcess, readOutput, writeOutput, readSetPoint, proportionalGain, integralGain, derivativeGain, pin.Direction == Const.Direction.Increasing ? ControllerDirection.Direct : ControllerDirection.Reverse, controllerMode) { _windowSize = windowSizeMillis * TimeSpan.TicksPerMillisecond; base.SetOutputLimits(0, _windowSize); _pin = pin; if (readProcess == null) { throw new ArgumentNullException(nameof(readProcess), "Read process must not be null."); } if (readOutput == null) { throw new ArgumentNullException(nameof(readOutput), "Read output must not be null."); } _stopSimulatedProcess = stopSimulatedProcess; debugger.init(); }
static void Main(string[] args) { WisePin bit0, bit7; WiseEncoder enc; WiseEncSpec[] encSpecs; Hardware hw = new Hardware(); bit0 = new WisePin("bit0", Hardware.Instance.domeboard, MccDaq.DigitalPortType.FirstPortA, 0, MccDaq.DigitalPortDirection.DigitalOut); bit7 = new WisePin("bit7", Hardware.Instance.domeboard, MccDaq.DigitalPortType.FirstPortA, 7, MccDaq.DigitalPortDirection.DigitalOut); encSpecs = new WiseEncSpec[] { new WiseEncSpec() { brd = Hardware.Instance.domeboard, port = MccDaq.DigitalPortType.FirstPortA }, new WiseEncSpec() { brd = Hardware.Instance.domeboard, port = MccDaq.DigitalPortType.FirstPortA, mask = 0x3 }, }; enc = new WiseEncoder("testEncoder", 1024, encSpecs, true, 100); bit0.SetOn(); Console.WriteLine(Hardware.Instance.domeboard.ownersToString()); bit0.SetOff(); System.Threading.Thread.Sleep(60000); }
public void init() { if (_initialized) { return; } int wantedBoards = 3; // We always have three boards, either real or simulated int maxMccBoards; if (!Simulated) { MccService.GetRevision(out mccRevNum, out mccVxdRevNum); MccService.ErrHandling(MccDaq.ErrorReporting.DontPrint, MccDaq.ErrorHandling.DontStop); maxMccBoards = MccDaq.GlobalConfig.NumBoards; // get the real Mcc boards for (int i = 0; i < maxMccBoards; i++) { int type; MccDaq.MccBoard board = new MccDaq.MccBoard(i); board.BoardConfig.GetBoardType(out type); if (type != 0) { WiseBoards.Add(new WiseBoard(board)); } } } // Add simulated boards, as needed for (int i = WiseBoards.Count; i < wantedBoards; i++) { WiseBoards.Add(new WiseBoard(null, i)); } domeboard = WiseBoards.Find(x => x.mccBoard.BoardNum == 0); teleboard = WiseBoards.Find(x => x.mccBoard.BoardNum == 1); miscboard = WiseBoards.Find(x => x.mccBoard.BoardNum == 2); if (computerControlPin == null) { computerControlPin = new WisePin("CompControl", teleboard, DigitalPortType.SecondPortCH, 0, DigitalPortDirection.DigitalIn); computerControlPin.Connect(true); } _initialized = true; }
public WiseVirtualMotor( string name, WisePin motorPin, WisePin guideMotorPin, WisePin slewPin, TelescopeAxes axis, Const.AxisDirection direction, List <object> encoders = null) { this.WiseName = name; this.motorPin = motorPin; this.guideMotorPin = guideMotorPin; this.slewPin = slewPin; this.allPins = new List <WisePin> { motorPin, slewPin, guideMotorPin }; this.encoders = encoders; this._axis = axis; this._otherAxis = (_axis == TelescopeAxes.axisPrimary) ? TelescopeAxes.axisSecondary : TelescopeAxes.axisPrimary; this._direction = direction; if (Simulated && (encoders == null || encoders.Count() == 0)) { throw new WiseException(WiseName + ": A simulated WiseVirtualMotor must have at least one encoder reference"); } if (Simulated) { simulationTimerFrequency = 30; // 15; TimerCallback TimerCallback = new TimerCallback(bumpEncoders); simulationTimer = new System.Threading.Timer(TimerCallback, null, Timeout.Infinite, Timeout.Infinite); } }