コード例 #1
0
        private void btn_Start_Click(object sender, EventArgs e)
        {
            try
            {
                // create grid application
                ga             = new GApplication(true);
                ga.GConnection = new GConnection(txtIP.Text, int.Parse(txtPort.Text), "user", "user");
                ga.Connection  = new GConnection(txtIP.Text, int.Parse(txtPort.Text), "user", "user");


                ga.ApplicationName = "eduGRID Bot Client";

                // add GridThread module (this executable) as a dependency
                ga.Manifest.Add(new ModuleDependency(typeof(eduGRID_Thread).Module));

                // subscribe to events
                ga.ThreadFinish += new GThreadFinish(ThreadFinished);
                ga.ThreadFailed += new GThreadFailed(ThreadFailed);
                //ga.ApplicationFinish += new GApplicationFinish(ApplicationFinished);

                ga.Start();
                Connect.Visible = false;



                chatgrp.Visible = true;
                chatgrp.BringToFront();
                txt_chat.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Connection Failure!");
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("[enter] to start grid application ...");
            Console.ReadLine();

            // create grid application
            ga = new GApplication(new GConnection("localhost", 9000, "user", "user"));
            ga.ApplicationName = "Alchemi Tutorial - Alchemi sample";

            // add GridThread module (this executable) as a dependency
            ga.Manifest.Add(new ModuleDependency(typeof(MultiplierThread).Module));

            // create and add 10 threads to the application
            for (int i = 0; i < 10; i++)
            {
                // create thread
                MultiplierThread thread = new MultiplierThread(i, i + 1);

                // add thread to application
                ga.Threads.Add(thread);
            }

            // subscribe to events
            ga.ThreadFinish      += new GThreadFinish(ThreadFinished);
            ga.ThreadFailed      += new GThreadFailed(ThreadFailed);
            ga.ApplicationFinish += new GApplicationFinish(ApplicationFinished);

            // start application
            ga.Start();

            Console.ReadLine();
        }
コード例 #3
0
 public void Disconnect()
 {
     if (ga != null)
     {
         ga.Stop();
     }
     ga = null;
 }
コード例 #4
0
ファイル: GThreadTester.cs プロジェクト: int64-tech/alchemi
        public void SetApplicationTestSimpleScenario()
        {
            GApplication application = new GApplication();

            GThread thread = new GThreadMock();

            thread.SetApplication(application);

            Assert.AreSame(application, thread.Application);
        }
コード例 #5
0
        static void Main(string[] args)
        {
            Console.WriteLine("[enter] to start grid application ....");
            Console.ReadLine();

            // create grid application
            ga = new GApplication(new GConnection("localhost", 80, "user", "user"));
            ga.ApplicationName = "Alchemi Tutorial - Alchemi sample";

            // add GridThread module (this executable) as a dependency
            ga.Manifest.Add(new ModuleDependency(typeof(MultiplierThread).Module));

            System.Console.WriteLine("successfully connected to manager and now going to start thread...");

            string I = "Hello";

            while (true)
            {
                flag = false;

                int i;
                for (i = 0; i < 100; i++)
                {
                    System.Console.Write("\nYour Query/You say: ");
                    I = System.Console.ReadLine();

                    //check for break signal
                    if ((I.ToLower() == "quit") || (I.ToLower() == "exit"))
                    {
                        break;
                    }

                    // create thread
                    MultiplierThread thread = new MultiplierThread(I);

                    // add thread to application
                    ga.Threads.Add(thread);
                }

                // subscribe to events
                ga.ThreadFinish      += new GThreadFinish(ThreadFinished);
                ga.ThreadFailed      += new GThreadFailed(ThreadFailed);
                ga.ApplicationFinish += new GApplicationFinish(ApplicationFinished);

                // start application
                ga.Start();

                break;
                while (!flag)
                {
                    //do nothing but wait...
                }
            }
            Console.ReadLine();
        }
コード例 #6
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (ga != null)
     {
         ga.Stop();
         ga = null;
     }
     FlushOP = false;
     if (OPFlush != null)
     {
         OPFlush.Join();
     }
 }
コード例 #7
0
ファイル: Tutorial_OTF.cs プロジェクト: bluetsys/alchemi
        static void Main(string[] args)
        {
            Console.WriteLine("[enter] to start grid application ...");
            Console.ReadLine();

            // create standard grid connection
            GConnection gc = new GConnection("localhost", 9000, "user", "user");

            // create multi-use grid application
            ga = new GApplication(true);
            ga.ApplicationName = "Tutorial OTF - Alchemi sample";

            // use standard grid connection
            ga.Connection = gc;

            // add GridThread module (this executable) as a dependency
            ga.Manifest.Add(new ModuleDependency(typeof(MultiplierThread).Module));

            // set the thread finish callback method
            ga.ThreadFinish += new GThreadFinish(ThreadFinished);

            // start application
            ga.Start();

            int    i     = -1;
            string input = "";

            while (input != "x")
            {
                i++;
                // create thread
                MultiplierThread thread = new MultiplierThread(i, i + 1);

                // add thread to application
                ga.StartThread(thread);

                Console.WriteLine("[enter] to start a new thread, [x] + [enter] to stop");
                input = Console.ReadLine();
            }

            ga.Stop();

            ApplicationStopped();
            Console.ReadLine();
        }
コード例 #8
0
        /// <summary>
        ///
        /// Const.Tor
        /// </summary>
        public eduGRID_botwrapper(string ManIP, int Port)
        {
            // create grid application
            ga             = new GApplication(true);
            ga.GConnection = new GConnection(ManIP, Port, "user", "user");
            ga.Connection  = new GConnection(ManIP, Port, "user", "user");


            ga.ApplicationName = "eduGRID Bot Client";

            // add GridThread module (this current one!) as a dependency
            ga.Manifest.Add(new ModuleDependency(typeof(eduGRID_Thread).Module));

            // subscribe to events
            ga.ThreadFinish += new GThreadFinish(ThreadFinished);
            ga.ThreadFailed += new GThreadFailed(ThreadFailed);
            //ga.ApplicationFinish += new GApplicationFinish(ApplicationFinished);

            ga.Start();
        }
コード例 #9
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter furmula: ");
            var formula = Console.ReadLine();
            var expr    = new Expression(formula, new [] { "x" });

            Console.WriteLine("Enter interval [start end]");
            var border_input = Console.ReadLine().Split(' ');
            var start        = Convert.ToDouble(border_input[0]);
            var end          = Convert.ToDouble(border_input[1]);

            Console.WriteLine("Enter number of threads: ");
            var num_threads = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("[enter] to start grid application ...");
            Console.ReadLine();

            ga = new GApplication(new GConnection("localhost", 9000, "user", "user"));
            ga.ApplicationName = "Integral calculator";

            // add GridThread module (this executable) as a dependency
            ga.Manifest.Add(new ModuleDependency(typeof(IntegralCalculationThread).Module));

            var thread_step = (end - start) / num_threads;

            for (int i = 0; i < num_threads; i++)
            {
                var s      = start + i * thread_step;
                var e      = start + (i + 1) * thread_step;
                var thread = new IntegralCalculationThread(s, e, expr);

                ga.Threads.Add(thread);
            }

            ga.ThreadFinish      += new GThreadFinish(ThreadFinished);
            ga.ThreadFailed      += new GThreadFailed(ThreadFailed);
            ga.ApplicationFinish += new GApplicationFinish(ApplicationFinished);

            ga.Start();
            Console.ReadLine();
        }
コード例 #10
0
ファイル: GridReverser.cs プロジェクト: int64-tech/alchemi
        static void Main(string[] args)
        {
            Console.WriteLine("Press [enter] to start ...");
            Console.ReadLine();

            try
            {
                ga = new GApplication(GConnection.FromConsole("localhost", "9000", "user", "user"));
                ga.ApplicationName = "Grid Reverser - Alchemi sample";

                ga.ThreadFinish      += new GThreadFinish(JobFinished);
                ga.ApplicationFinish += new GApplicationFinish(ApplicationFinished);

                ga.Manifest.Add(new EmbeddedFileDependency("Reverse.exe", @"..\..\..\Reverse\bin\Debug\Reverse.exe"));

                for (int jobNum = 0; jobNum < 2; jobNum++)
                {
                    GJob   job            = new GJob();
                    string inputFileName  = string.Format("input{0}.txt", jobNum);
                    string outputFileName = string.Format("output{0}.txt", jobNum);

                    job.InputFiles.Add(new EmbeddedFileDependency(inputFileName, @"..\..\" + inputFileName));
                    job.RunCommand = string.Format("Reverse {0} > {1}", inputFileName, outputFileName);
                    job.OutputFiles.Add(new EmbeddedFileDependency(outputFileName));

                    ga.Threads.Add(job);
                }

                ga.Start();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.GetType() + " : " + e.Message);
                Console.ReadLine();
                return;
            }
            Console.WriteLine("Started .. Waiting for jobs to finish ..\n");
            Console.ReadLine();
        }
コード例 #11
0
        private void Connect(object sender, EventArgs e)
        {
            //start the process of connecting...
            try
            {
                // create grid application
                ga             = new GApplication(true);
                ga.GConnection = new GConnection(ManagerIP, Port, "user", "user");
                ga.Connection  = new GConnection(ManagerIP, Port, "user", "user");


                ga.ApplicationName = "eduGRID Bot Client";

                // add GridThread module (this executable) as a dependency
                ga.Manifest.Add(new ModuleDependency(typeof(eduGRID_Thread).Module));

                // subscribe to events
                ga.ThreadFinish      += new GThreadFinish(ThreadFinished);
                ga.ThreadFailed      += new GThreadFailed(ThreadFailed);
                ga.ApplicationFinish += new GApplicationFinish(ApplicationFinished);

                ga.Start();
                connected = true;
                Append_Queryset(Queryset.GetUpperBound(0), "Bot", "Connected. Done!", "", "");
                Refresh_Display();
            }
            catch (Exception ex)
            {
                Append_Queryset(Queryset.GetUpperBound(0), "Bot", "Attempt failed! Disconnected", "Error", (ex.ToString()));
                Refresh_Display();
            }
            finally
            {
                tmr_connect.Enabled = false;
            }
        }
コード例 #12
0
        static void Main()
        {
            Console.WriteLine("[Pi Calculator Grid Application]\n--------------------------------\n");

            Console.WriteLine("Press <enter> to start ...");
            Console.ReadLine();

            Logger.LogHandler += new LogEventHandler(LogHandler);

            try
            {
                // get the number of digits from the user
                bool numberOfDigitsEntered = false;

                while (!numberOfDigitsEntered)
                {
                    try
                    {
                        NumberOfDigits = Int32.Parse(Utils.ValueFromConsole("Digits to calculate", "100"));

                        if (NumberOfDigits > 0)
                        {
                            numberOfDigitsEntered = true;
                        }
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Invalid numeric value.");
                        numberOfDigitsEntered = false;
                    }
                }

                // get settings from user
                GConnection gc = GConnection.FromConsole("localhost", "9000", "user", "user");

                StartTiming();

                // create a new grid application
                App = new GApplication(gc);
                App.ApplicationName = "PI Calculator - Alchemi sample";

                // add the module containing PiCalculatorThread to the application manifest
                App.Manifest.Add(new ModuleDependency(typeof(PiCalculatorThread).Module));

                NumThreads = (Int32)Math.Floor((double)NumberOfDigits / DigitsPerThread);
                if (DigitsPerThread * NumThreads < NumberOfDigits)
                {
                    NumThreads++;
                }

                // create and add the required number of grid threads
                for (int i = 0; i < NumThreads; i++)
                {
                    int StartDigitNum = 1 + (i * DigitsPerThread);

                    /// the number of digits for each thread
                    /// Each thread will get DigitsPerThread digits except the last one
                    /// which might get less
                    int DigitsForThisThread = Math.Min(DigitsPerThread, NumberOfDigits - i * DigitsPerThread);

                    Console.WriteLine(
                        "starting a thread to calculate the digits of pi from {0} to {1}",
                        StartDigitNum,
                        StartDigitNum + DigitsForThisThread - 1);

                    PiCalculatorThread thread = new PiCalculatorThread(
                        StartDigitNum,
                        DigitsForThisThread
                        );

                    App.Threads.Add(thread);
                }

                // subcribe to events
                App.ThreadFinish      += new GThreadFinish(ThreadFinished);
                App.ApplicationFinish += new GApplicationFinish(ApplicationFinished);

                // start the grid application
                App.Start();

                logger.Debug("PiCalc started.");
            }
            catch (Exception e)
            {
                Console.WriteLine("ERROR: {0}", e.ToString());
            }

            Console.ReadLine();
        }
コード例 #13
0
ファイル: MandelForm.cs プロジェクト: int64-tech/alchemi
        private void Generate()
        {
            try
            {
                totalHorzMaps = int.Parse(txHorz.Text);
                totalVertMaps = int.Parse(txVert.Text);
            }
            catch
            {
                MessageBox.Show("Invalid value(s) for 'No. Cells'.");
                return;
            }

            if (!initted)
            {
                GConnectionDialog gcd = new GConnectionDialog();
                if (gcd.ShowDialog() == DialogResult.OK)
                {
                    // initialise application
                    ga = new GApplication(true);
                    ga.ApplicationName = "Alchemi Fractal Generator - Alchemi sample";

                    ga.Connection = gcd.Connection;
                }
                else
                {
                    return;
                }

                // set dependencies
                ga.Manifest.Add(new ModuleDependency(typeof(KarlsTools.Complex).Module));
                ga.Manifest.Add(new ModuleDependency(typeof(MandelThread).Module));

                // subscribe to events
                ga.ThreadFinish      += new GThreadFinish(UpdateBitmap);
                ga.ApplicationFinish += new GApplicationFinish(AppDone);

                try
                {
                    ga.Start();
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString());
                }

                initted = true;
            }

            startTime = DateTime.Now;

            for (int mapNumX = 0; mapNumX < totalHorzMaps; mapNumX++)
            {
                for (int mapNumY = 0; mapNumY < totalVertMaps; mapNumY++)
                {
                    MandelThread mandel = new MandelThread(
                        mapNumX,
                        mapNumY,
                        width / totalHorzMaps,
                        height / totalVertMaps,
                        xOffset + mapNumX * width / totalHorzMaps,
                        yOffset + mapNumY * height / totalVertMaps,
                        zoom,
                        pbColorOne.BackColor,
                        pbColorTwo.BackColor
                        );
                    //ga.Threads.Add(mandel);
                    ga.StartThread(mandel);
                }
            }

            pb.Minimum = 0;
            pb.Value   = 0;
            pb.Maximum = totalHorzMaps * totalVertMaps;
        }
コード例 #14
0
ファイル: Program.cs プロジェクト: bluetsys/alchemi
        void Run()
        {
            // All grid applications must have a GApplication instance.  The GConnection information
            // specifies the Manager's host name, the port to connect on, and the username and password
            // to use.  A GApplication is created with this connection information.
            GConnection  gridConnection  = new GConnection("localhost", 9000, "user", "user");
            GApplication gridApplication = new GApplication(gridConnection);

            while (!File.Exists(this._inputFileName))
            {
                if (this._inputFileName != null)
                {
                    Console.WriteLine("\nFile does not exist.  Please try again.\n");
                }
                Console.WriteLine("Enter the input file name: ");
                this._inputFileName = Console.ReadLine();
            }

            Console.WriteLine("Enter the output file name: ");
            this._outputFileName = Console.ReadLine();

            try
            {
                // Open the input file for reading.
                StreamReader streamReader = new StreamReader(this._inputFileName);

                int    blockSize  = 100;
                char[] charBuffer = new char[blockSize];
                string stringBuffer;
                int    currentBlock = 0;

                // In order to ensure that all required DLLs to run the thread exist at each Executor
                // we must add a dependency to the Manifest for each DLL and/or file needed by the GThreads.
                gridApplication.Manifest.Add(new ModuleDependency(typeof(CustomGThread).Module));

                // Loop through the file reading blocks of size blockSize into the char[] array charBuffer
                // until we hit the end of the file.
                while (streamReader.ReadBlock(charBuffer, 0, blockSize) != 0)
                {
                    // ReadBlock returns a char[] buffer so convert it to a string to pass to our custom GThread.
                    stringBuffer = new string( charBuffer );

                    // Instantiate our custom GThread and pass the data we need to process through the constructor.
                    // Note: other methods of passing data to GThreads are possible.
                    CustomGThread customGThread = new CustomGThread(currentBlock, stringBuffer);

                    // Add the thread to the GApplication's Threads collection.
                    gridApplication.Threads.Add(customGThread);

                    currentBlock++;
                }

                // Close the input file.
                streamReader.Close();

                // Resize the output array to hold one entry per GThread.
                this._outputArray = new string[currentBlock];

                // Bind the ThreadFinished and ApplicationFinished events to local event handlers.
                gridApplication.ThreadFinish      += new GThreadFinish(gridApp_ThreadFinish);
                gridApplication.ApplicationFinish += new GApplicationFinish(gridApp_ApplicationFinish);

                // Start the GApplication.
                gridApplication.Start();

                Console.WriteLine("Application Started");
            }
            catch (Exception ex)
            {
                Console.WriteLine("An exception occurred: " + ex.Message + "\r\n" + ex.StackTrace);
            }
        }
コード例 #15
0
ファイル: RendererForm.cs プロジェクト: bluetsys/alchemi
        private void render_Click(object sender, EventArgs e)
        {
            stop.Enabled   = true;
            render.Enabled = !stop.Enabled;

            drawnFirstSegment = false;
            showSplash();

            // model path
            modelPath = paths[modelCombo.SelectedIndex];
            // get width and height from combo box
            imageWidth  = Int32.Parse(widthCombo.SelectedItem.ToString());
            imageHeight = Int32.Parse(heightCombo.SelectedItem.ToString());

            // get cols and rows from up downs
            columns = Decimal.ToInt32(columnsUpDown.Value);
            rows    = Decimal.ToInt32(rowsUpDown.Value);

            segmentWidth  = imageWidth / columns;
            segmentHeight = imageHeight / rows;

            int x = 0;
            int y = 0;

            logger.Debug("WIDTH:" + imageWidth);
            logger.Debug("HEIGHT:" + imageHeight);
            logger.Debug("COLUMNS:" + columns);
            logger.Debug("ROWS:" + rows);
            logger.Debug("" + modelPath);

            // reset the display
            clearImage();

            if (!initted)
            {
                GConnectionDialog gcd = new GConnectionDialog();
                gcd.ShowDialog();

                ga = new GApplication(true);
                ga.ApplicationName    = "Alchemi POV-Ray Renderer - Alchemi sample";
                ga.Connection         = gcd.Connection;
                ga.ThreadFinish      += new GThreadFinish(ga_ThreadFinish);
                ga.ThreadFailed      += new GThreadFailed(ga_ThreadFailed);
                ga.ApplicationFinish += new GApplicationFinish(ga_ApplicationFinish);

                ga.Manifest.Add(new ModuleDependency(typeof(RenderThread).Module));

                initted = true;
            }

            if (ga != null && ga.Running)
            {
                ga.Stop();
            }

            pbar.Maximum    = columns * rows;
            pbar.Minimum    = 0;
            pbar.Value      = 0;
            lbProgress.Text = "Starting to render image ... ";

            for (int col = 0; col < columns; col++)
            {
                for (int row = 0; row < rows; row++)
                {
                    x = col * segmentWidth;
                    y = row * segmentHeight;

                    int startRowPixel = y + 1;
                    int endRowPixel   = y + segmentHeight;
                    int startColPixel = x + 1;
                    int endColPixel   = x + segmentWidth;

                    RenderThread rth = new RenderThread(modelPath,
                                                        imageWidth, imageHeight,
                                                        segmentWidth, segmentHeight,
                                                        startRowPixel, endRowPixel,
                                                        startColPixel, endColPixel,
                                                        "");

                    rth.BasePath = this.basepath;
                    rth.Col      = col + 1;
                    rth.Row      = row + 1;

                    ga.Threads.Add(rth);
                }
            }

            try
            {
                ga.Start();
            }
            catch (Exception ex)
            {
                Console.WriteLine("" + ex.StackTrace);
                MessageBox.Show("Alchemi Rendering Failed!" + ex.ToString());
            }

            lbProgress.Text = "Rendering image ... ";
            ShowBusyGif();
        }