Esempio n. 1
0
        /// <summary>
        /// SetLaserState turns the Laser either on or off
        /// based on the Boolean input.
        /// </summary>
        /// <param name="bitValue">The value to set the bit</param>
        /// <returns>Boolean TRUE if successful, FALSE otherwise</returns>
        public Boolean SetLaserState(Boolean bitValue)
        {
            //Declare a variable to return
            Boolean rtn = true;

            //Turn the bitValue into a DigitalLogicState
            DigitalLogicState state = DigitalLogicState.High;

            if (bitValue == false)
            {
                state = DigitalLogicState.Low;
            }

            //Set the bit
            ErrorInfo ei = MCCDaq._board.DBitOut(MCCDaq._laserPortType, MCCDaq._laserBit, state);

            //If an error occurred, set the return value
            if (ei.Value != ErrorInfo.ErrorCode.NoErrors)
            {
                rtn = false;
            }

            //Return the result
            return(rtn);
        }
Esempio n. 2
0
        // This is the tuning function
        public void tuning()
        {
            try
            {
                while (stop_check != 1)
                {
                    MccBoard         daq = new MccDaq.MccBoard(BoardNum);
                    MccDaq.ErrorInfo RetVal;

                    DigitalLogicState[] TuneData = new DigitalLogicState[MAX_CHANCOUNT];

                    Update_Freeze update_freeze_del = new
                                                      Update_Freeze(tuning_helper);

                    for (int i = 0; i < MAX_CHANCOUNT; i++)
                    {
                        RetVal = daq.DConfigBit(DigitalPortType.AuxPort, i, DigitalPortDirection.DigitalIn);
                        RetVal = daq.DBitIn(DigitalPortType.AuxPort, i, out TuneData[i]);
                    }

                    Invoke(update_freeze_del, TuneData);

                    Thread.Sleep(500);
                }

                return;
            }
            catch
            {
                return;
            }
        }
Esempio n. 3
0
 public ErrorInfo.ErrorCode Set(DigitalPortType port, int outputID, DigitalLogicState state)
 {
     lock (this)
     {
         Console.WriteLine(String.Format("port: {0}, outputID: {1}, state: {2}", port, outputID, state));
         if (!BoardFound)
         {
             return(ErrorInfo.ErrorCode.BoardNotExist);
         }
         if (port == DigitalPortType.FirstPortA && outputID >= 0 && outputID <= 7)
         {
             MccDaq.ErrorInfo ULStat;
             ULStat = DaqBoard.DBitOut(port, outputID, state);
             return(PrintError(ULStat));
         }
         else
         {
             SimpleLogger.Logger.Log("Port Not supported");
             Environment.Exit(1);
             return(ErrorInfo.ErrorCode.InvalidNetPort);
         }
     }
 }
Esempio n. 4
0
 public MsgSingleOuput(DigitalPortType digiPortType, int outputID, DigitalLogicState digiLogicState)
 {
     DigiPortType   = digiPortType;
     OutputID       = outputID;
     DigiLogicState = digiLogicState;
 }
Esempio n. 5
0
 public void setBit(DigitalPortType port, int bit, DigitalLogicState val)
 {
     this.gpio_board.DBitOut(port, bit, val);
 }
Esempio n. 6
0
        public void SendSetOneOutput(DigitalPortType port, int outputID, DigitalLogicState state)
        {
//			MessageContainer message;
            PushMessage(new MsgSingleOuput(port, outputID, state));
        }
        // Tuning helper function
        public void tuning_helper(DigitalLogicState[] TuneData)
        {
            try
            {
                for (int i = 1; i <= NumSamples; i++)
                {
                    this.Controls["StateBox" + i].ForeColor = Color.LawnGreen;
                    if (TuneData[(i - 1)] == DigitalLogicState.High)
                    {
                        this.Controls["StateBox" + i].Text = "LIQUID";
                        this.Controls["InfoBox" + i].Text = null;
                        SamplesStates[(i - 1)] = 1.0;
                        IsSampleFrozen[(i - 1)] = false;
                    }
                    else
                    {
                        this.Controls["StateBox" + i].Text = "FROZEN";

                        if (start_check == 1)
                        {
                            if (IsSampleFrozen[(i - 1)] == false)
                            {
                                this.Controls["InfoBox" + i].Text = "at " +
                                TimeSpan.ToString(@"h\:mm\:ss");

                                IsSampleFrozen[(i - 1)] = true;
                            }

                            SamplesStates[(i - 1)] = 1.2;
                        }
                    }
                }

                if (start_check == 1)
                {
                    int count = 0;
                    for (int i = 0; i < NumSamples; i++)
                    {
                        if (SamplesStates[i] == 1.2)
                            count++;
                    }
                    if (count == NumSamples)
                    {
                        all_frozen = true;

                        if (reset_all_frozen == true)
                        {
                            Frozen_Time = DateTime.Now;
                            reset_all_frozen = false;
                        }
                    }
                    else
                    {
                        all_frozen = false;
                        reset_all_frozen = true;
                    }
                }
            }
            catch
            {
                MessageBox.Show("tuning_helper has an error!", "   " + "ERROR!");
                return;
            }
        }
        // This is the tuning function
        public void tuning()
        {
            try
            {
                while (stop_check != 1)
                {
                    MccBoard daq = new MccDaq.MccBoard(BoardNum);
                    MccDaq.ErrorInfo RetVal;

                    DigitalLogicState[] TuneData = new DigitalLogicState[MAX_CHANCOUNT];

                    Update_Freeze update_freeze_del = new
                        Update_Freeze(tuning_helper);

                    for (int i = 0; i < MAX_CHANCOUNT; i++)
                    {
                        RetVal = daq.DConfigBit(DigitalPortType.AuxPort, i, DigitalPortDirection.DigitalIn);
                        RetVal = daq.DBitIn(DigitalPortType.AuxPort, i, out TuneData[i]);
                    }

                    Invoke(update_freeze_del, TuneData);

                    Thread.Sleep(500);
                }

                return;
            }
            catch
            {
                return;
            }
        }