Esempio n. 1
0
        public void SetOn(double rate)
        {
            rate = Math.Abs(rate);
            string activeBefore = ActiveMortorPins();

            if (motorPin != null && motorPin.isOn)
            {
                motorPin.SetOff();
            }
            if (guideMotorPin != null && guideMotorPin.isOn)
            {
                guideMotorPin.SetOff();
            }
            if (slewPin != null && slewPin.isOn)
            {
                bool inUseByOtherAxis = false;
                foreach (WiseVirtualMotor m in wisetele.axisMotors[_otherAxis])
                {
                    if (m.currentRate == Const.rateSlew)
                    {
                        inUseByOtherAxis = true;
                        break;
                    }
                }
                if (!inUseByOtherAxis)
                {
                    slewPin.SetOff();
                }
            }

            currentRate = rate;
            if (rate == Const.rateSlew)
            {
                slewPin.SetOn();
                motorPin.SetOn();
            }
            else if (rate == Const.rateSet)
            {
                motorPin.SetOn();
            }
            else if (rate == Const.rateGuide)
            {
                guideMotorPin.SetOn();
            }
            else if (rate == Const.rateTrack)
            {
                motorPin.SetOn();
            }

            debugger.WriteLine(Debugger.DebugLevel.DebugAxes, "{0}.SetOn at {1}: pins before: {2}, pins after: {3}",
                               WiseName, WiseTele.RateName(rate), activeBefore, ActiveMortorPins());

            if (Simulated)
            {
                timer_counts = 0;
                prevTick     = DateTime.Now;
                simulationTimer.Change(0, 1000 / simulationTimerFrequency);
            }
        }
Esempio n. 2
0
        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);
        }
        protected override void Compute()
        {
            ulong now = (ulong)DateTime.Now.Ticks;

            base.Compute();

            if ((now - windowStartTime) > _windowSize)
            {
                windowStartTime += _windowSize;
            }

            if (_output <= now - windowStartTime)
            {
                #region debug
                debugger.WriteLine(Debugger.DebugLevel.DebugLogic,
                                   "{0}: Compute: _output: {1} <= {2} ({3} - {4}), Stopping",
                                   Name, _output, now - windowStartTime, now, windowStartTime);
                #endregion
                base.Stop();
                _pin.SetOff();
                _stopSimulatedProcess();
            }
        }