Exemple #1
0
 public void writetolist(Plot p)
 {
     lock (this)  // Enter synchronization block
     {
         if (readerFlag)
         {      // Wait until ReadFromCell is done consuming.
             try
             {
                 Monitor.Wait(this);   // Wait for the Monitor.Pulse in
                 // ReadFromList
             }
             catch (SynchronizationLockException e)
             {
                 Console.WriteLine(e);
                 OnError(121, e.Message);
             }
             catch (ThreadInterruptedException e)
             {
                 Console.WriteLine(e);
             }
         }
         list.Add(p);
         Console.WriteLine("Element added to List By Core Team");
         readerFlag = true;    // Reset the state flag to say insertion to List
         // is done
         Monitor.Pulse(this);  // Pulse tells ReadFromList that 
         // WriteToList is done.
     }   // Exit synchronization block
 }
        public override void VisitPlotFunctionElement(PlotFunctionElement element)
        {
            if (mVariableMap.ContainsKey(element.getData().getText()))
            {
                //   double[,] temp = ((MatrixVariableDeclaration)(mVariableMap[element.getData().getText()])).getdoubleValue();
                if (element.getPlotFunction() == "subPlot")
                {
                    int pane = int.Parse(element.getPeno().getText()); //.getPane().getText());
                    string plotType = element.getPlotType();

                    if (pane >= 4 || pane <= 0)
                    {
                        Console.Write("pane no. is not valid.. it lies between 1 to 4.. Try again..");
                        sendres(112, "pane no. is not valid.. it lies between 1 to 4.. Try again..");
                        return;
                    }
                    else if (plotType == "2D" || plotType == "1D")
                    {
                        if ((IntegerElement)(element.getMode()) != null)
                        {
                            Console.Write("Invalid argumenet.. Mode is not required.. Try again.. ");
                            sendres(112, "Invalid argumenet.. Mode is not required.... Try again..");
                            return;
                        }
                    }
                    else if (plotType == "3D")
                    {
                        int mode = int.Parse(((IntegerElement)(element.getMode())).getText());
                        if (mode > 3 || mode <= 0)
                        {
                            Console.Write("Invalid mode.. Give the input between 1..3 ");
                            sendres(112, "Invalid mode.. Give the input between 1..3 ");
                            return;
                        }
                    }
                }
                else if (element.getPlotFunction() == "plot")
                {
                    string plotType = element.getPlotType();
                    string data = element.getData().getText();
                    if (plotType == "1D" || plotType == "2D")
                    {
                        if ((IntegerElement)(element.getMode()) != null)
                        {
                            Console.Write("Invalid argumenet.. Mode is not required.. Try again.. ");
                            sendres(112, "Invalid argumenet.. Mode is not required.. Try again.. ");
                            return;
                        }
                    }
                    else if (plotType == "3D")
                    {
                        int mode = int.Parse(((IntegerElement)(element.getMode())).getText());
                        if (mode >= 3 || mode <= 0)
                        {
                            Console.Write("Invalid mode.. Give the input between 1..3 ");
                            sendres(112, "Invalid mode.. Give the input between 1..3 ");
                            return;
                        }

                    }
                }
                else if (element.getPlotFunction() == "setScaleMode")
                {
                    string scaleMode = element.getScaleMode();
                    if (scaleMode != "log" || scaleMode != "linear")
                    {
                        Console.Write("Invalid scale mode.. it should be either 'linear' or 'log'");
                        sendres(112, "Invalid scale mode.. it should be either 'linear' or 'log'");
                        return;
                    }
                }

                Plot pr = new Plot();
                pr = convert_Ele_to_plot(element);
                p.writetolist(pr);
            }
            else
            {
                Console.Write("Plot data not declared.. Try again..");
                sendres(112, "Plot data not declared.. Try again..");
                return;
            }

        }
 private Plot convert_Ele_to_plot(PlotFunctionElement p)
 {
     Plot p1 = new Plot();
     p1.Command = p.getPlotFunction();
     p1.PaneNum = p.getPeno() == null ? 0 : int.Parse(p.getPeno().getText());
     if (mVariableMap.ContainsKey(p.getData().getText()))
     {
         double[,] temp = ((MatrixVariableDeclaration)(mVariableMap[p.getData().getText()])).getdoubleValue();
         p1.Data = p.getData().getText() == null ? null : temp;
     }
     p1.Mode = p.getMode() == null ? 0 : int.Parse(p.getMode().getText());
     p1.Dimensions = p.getPlotType() == null ? 0 : p.getPlotType() == "2D" ? 2 : 3;
     p1.PlotTitle = p.getTitle() == null ? "" : p.getTitle().getText();
     p1.X_Fact = p.getXFact() == null ? 1.0 : double.Parse(p.getXFact().getText());
     p1.Y_Fact = p.getYFact() == null ? 1.0 : double.Parse(p.getYFact().getText());
     p1.Z_Fact = p.getZFact() == null ? 1.0 : double.Parse(p.getZFact().getText());
     p1.X_Axis_Title = p.getXTitle() == null ? "" : p.getXTitle().getText();
     p1.Y_Axis_Title = p.getYTitle() == null ? "" : p.getYTitle().getText();
     p1.Z_Axis_Title = p.getZTitle() == null ? "" : p.getZTitle().getText();
     p1.ScaleMode = p.getScaleMode() == null ? 1 : (p.getScaleMode() == "linear") ? 1 : 2;
     return (p1);
 }
Exemple #4
0
    private void ReadFromList()
    {
        lock (this)   // Enter synchronization block
        {
            if (!readerFlag)
            {            // Wait until WriteToList is done producing
                try
                {
                    // Waits for the Monitor.Pulse in WriteToList
                    Monitor.Wait(this);
                }
                catch (SynchronizationLockException e)
                {
                    Console.WriteLine(e);
                }
                catch (ThreadInterruptedException e)
                {
                    Console.WriteLine(e);
                }
            }
            Console.WriteLine("Element removed from list invoked By Plot Team");
            p1 = list[0];
            list.RemoveAt(0);
            readerFlag = false;    // Reset the state flag to say reading
            // is done.
            Monitor.Pulse(this);   // Pulse tells WriteToList that
            // ReadFromList is done.

            display();        //unit test for receiver
               
            parsePaint();
            //call the various subroutines for parsing and other function in paint module

        }   // Exit synchronization block
    }