示例#1
0
        public static void Main()
        {
            DemonstrateAsyncPattern demonstrator = new DemonstrateAsyncPattern();

            demonstrator.FactorizeNumberUsingCallback();
            demonstrator.FactorizeNumberAndWait();
        }
示例#2
0
        public int calibrateAWG(int AWGFreq)
        {
            double EquSampRate = 0;
            double time        = 0;

            //AWGFreq = 100000000;
            System.Console.WriteLine("Please configure unit to output waveform with freqeucncy specified.\nBegin waveform capture? (y/n)");
            string line = Console.ReadLine();

            if (line == "y")
            {
                DemonstrateAsyncPattern demonstrator = new DemonstrateAsyncPattern();
                demonstrator.stopWatch.Start();
                int numSamples = demonstrator.CalcNumSamples(AWGFreq, out EquSampRate, out time);
                int timeMs     = (int)(time * 1000);
                //sleep amount of time to collect samples calculated by CalcNumSamples and sleep thread
                //for that amount of time to simulate real waveform capture
                Thread.Sleep(timeMs);

                /* ResourceManager rMgr = new ResourceManager();
                 * FormattedIO488 src = new FormattedIO488();
                 * string srcAddress = "USB::0x0699::0x0343::C025388::0";
                 * src.IO = (Ivi.Visa.Interop.IMessage)rMgr.Open(srcAddress, AccessMode.NO_LOCK, 2000, null);
                 * src.IO.Timeout = 2000;
                 * src.WriteString("*IDN?", true);
                 * string temp = src.ReadString();
                 * src.WriteString("OUTPut1:STATe ON", true);*/
                demonstrator.GetSamplesUsingCallback(numSamples, SAMPLE_RATE, AWGFreq);
                // demonstrator.GetSamplesUsingCallback(numSamples, SAMPLE_RATE, AWGFreq);
                return(0);
            }
            else if (line == "n")
            {
                System.Console.WriteLine("Capture cancelled");
                return(2);
            }
            else
            {
                System.Console.WriteLine("Invalid input, please enter 'y' or 'n'. Exiting with code 1");
                return(1);
            }
        }
示例#3
0
        /*MAIN TAKES IN COMMAND LINE ARGUMENT OF AWG WAVEFORM FREQUENCY.
         * USES READ AND WRITE FUNCTIONS TO SEND/RECIEVE INFO TO/FROM USER
         * MULTIPLE CLASSES AND FUNCTIONS ARE USED. TYPE CASTING CAN BE SEEN
         * IN THE PROCESS SAMPPLES FUNCTION. ARRAY AND LOOP USE CAN BE SEEN IN
         * THE SAMPLE COLLECTOR CLASS. ALL REQUIREMENTS SHOULD BE MET FOR C#
         * level 1 MASTERY ACHIEVEMENT*/

        public static int Main(string[] args)
        {
            DemonstrateAsyncPattern demonstrator = new DemonstrateAsyncPattern();
            int  AWGFreq = 0;
            bool test    = int.TryParse(args[0], out AWGFreq);

            if (args.Length == 0)
            {
                System.Console.WriteLine("Invalid usage");
                demonstrator.PrintError(AWGFreq);
                return(1);
            }
            else if ((!test) || AWGFreq > 500000000 || AWGFreq < 100)
            {
                System.Console.WriteLine("Please use numeric input for AWG frequency between 100Hz and 500MHz.");
                demonstrator.PrintError(AWGFreq);
                return(1);
            }
            else
            {
                demonstrator.calibrateAWG(AWGFreq);
                return(0);
            }
        }
示例#4
0
 public static void Main()
 {
     DemonstrateAsyncPattern demonstrator = new DemonstrateAsyncPattern();
     demonstrator.FactorizeNumberUsingCallback();
     demonstrator.FactorizeNumberAndWait();
     demonstrator.FactorizeUsingTask();
     demonstrator.FactorizeUsingAsync();
     Console.WriteLine("Hello!");
     Thread.Sleep(5000);
 }