コード例 #1
0
ファイル: BUILD.cs プロジェクト: BrettJohn/CAT
        /// =======================================================================================================
        public static Return BUILD_FOLDER(string folder_to_code, string build_name)
        {
            Return             filenames          = DISK.READ_FILES_REGEX(folder_to_code, ".cs", "False");
            List <CATMessage>  returndata         = new List <CATMessage>();
            CSharpCodeProvider codeprovider       = new CSharpCodeProvider();
            CompilerParameters compilerparameters = new CompilerParameters();

            foreach (string ass in DefaultAssemblies)
            {
                compilerparameters.ReferencedAssemblies.Add(ass);
            }
            compilerparameters.GenerateExecutable = build_name.Contains(".exe");
            compilerparameters.OutputAssembly     = build_name;
            string[] sourcefiles = new string[filenames.Messages.Count];
            int      count       = 0;

            foreach (CATMessage sourcefile in filenames.Messages)
            {
                sourcefiles[count] = sourcefile.Text; count++;
            }
            CompilerResults   results            = codeprovider.CompileAssemblyFromFile(compilerparameters, sourcefiles);
            Status            overallbuildstatus = Status.PASS;
            List <CATMessage> errormsgs          = new List <CATMessage>();

            foreach (CompilerError CompErr in results.Errors)
            {
                overallbuildstatus = Status.FAIL;
                if (File.Exists(CompErr.FileName))
                {
                    string[] alllines = File.ReadAllLines(CompErr.FileName);
                    errormsgs.Add(new CATMessage(CompErr.FileName + " (line " + CompErr.Line + "): " + "\r\n" + CompErr.ErrorText + "\r\n" + alllines[CompErr.Line - 1], Status.FAIL));
                    new Thread(() => CAT.RunCmd(null, new Map("Null", 0, 0, 0), command: CompErr.FileName)).Start();
                }
                else
                {
                    returndata.Add(new CATMessage(CompErr.ErrorText, Status.FAIL));
                }
            }
            foreach (CATMessage sourcefile in filenames.Messages)
            {
                Status            filestatus    = Status.PASS;
                List <CATMessage> fileerrormsgs = new List <CATMessage>();
                foreach (CATMessage error in errormsgs)
                {
                    if (error.Text.ToUpper().Contains(sourcefile.Text.ToUpper()))
                    {
                        filestatus = Status.FAIL;
                        fileerrormsgs.Add(new CATMessage(error.Text, Status.FAIL));
                    }
                }
                string filestatusmessage = filestatus == Status.PASS ? sourcefile.Text : "";
                foreach (CATMessage fileerrmsg in fileerrormsgs)
                {
                    filestatusmessage += fileerrmsg.Text + "\r\n";
                }
                returndata.Add(new CATMessage(filestatusmessage, filestatus));
            }
            returndata.Add(new CATMessage(compilerparameters.OutputAssembly + " build " + (overallbuildstatus == Status.FAIL ? "failed" : "successful"), overallbuildstatus));
            return(new Return(returndata));
        }
コード例 #2
0
        /// =======================================================================================================
        public void WaitForAuto()
        {
            bool     complete = false;
            DateTime start    = DateTime.Now;

            CAT.FormAccess(CAT.FormDelegates.AddNamedOverlay, new object[] { Alias, Alias, CAT.Status.BUSY }, Alias);
            while (!complete && !CAT.AbortAll)
            {
                complete = true;
                CAT.FormAccess(CAT.FormDelegates.UpdateNamedOverlay, new object[] { Alias, Alias + " (" + (int)(DateTime.Now - start).TotalMilliseconds + "ms)", CAT.Status.BUSY }, Alias);
                foreach (KeyValuePair <int, BatchReport> b in BatchReports)
                {
                    if (!b.Value.BatchComplete)
                    {
                        complete = false;
                    }
                    foreach (KeyValuePair <Map, CommandReport> c in b.Value.CommandReports)
                    {
                        if (!c.Value.CommandComplete)
                        {
                            complete = false;
                        }
                    }
                    Thread.Sleep(10);
                }
            }
            AutoComplete();
        }
コード例 #3
0
        /// =======================================================================================================
        public static Return UDP_LISTEN(string IP_address, string port, string duration_seconds)
        {
            List <CATMessage> msgs = new List <CATMessage>();

            if (Listening || ListenerClient != null)
            {
                try
                {
                    ListenerClient.Close();
                }
                catch (Exception e)
                {
                    CAT.FormAccess(CAT.FormDelegates.AddOverlay, new object[] { ErrorMsg(e), Status.FAIL });
                    msgs.Add(new CATMessage(ErrorMsg(e), Status.FAIL));
                }
            }
            Listening        = true;
            ListenerClient   = new UdpClient(Convert.ToInt16(port));
            ListenerEndPoint = new IPEndPoint(IPAddress.Any, Convert.ToInt16(port));
            string receivedtext;

            byte[]   receivebytearray;
            DateTime start = DateTime.Now;

            while ((DateTime.Now - start).TotalSeconds < Convert.ToInt32(duration_seconds) && Listening)
            {
                receivebytearray = ListenerClient.Receive(ref ListenerEndPoint);
                receivedtext     = Encoding.ASCII.GetString(receivebytearray, 0, receivebytearray.Length);
                CAT.FormAccess(CAT.FormDelegates.AddOverlay, new object[] { receivedtext, Status.INFO });
                msgs.Add(new CATMessage(receivedtext));
            }
            ListenerClient.Close();
            Listening = false;
            return(new Return(msgs));
        }
コード例 #4
0
ファイル: User.cs プロジェクト: BrettJohn/CAT
        // Utilities
        /// =======================================================================================================
        public static bool GetInput(ref string upatedtext, string caption, List <string> options = null)
        {
            Form prompt = new Form()
            {
                Icon            = (Icon)CAT.FormAccess(FormDelegates.GetIcon),
                Width           = 610,
                Height          = 100,
                BackColor       = System.Drawing.Color.Black,
                FormBorderStyle = FormBorderStyle.FixedDialog,
                Text            = caption,
                StartPosition   = FormStartPosition.CenterParent,
            };
            TextBox textBox      = CAT.GetTextBox(upatedtext, left: 5, top: 5, width: 500);
            Button  confirmation = CAT.GetButton("OK", left: 510, width: 80, top: 3);

            confirmation.Click += (sender, e) => { prompt.DialogResult = DialogResult.OK; prompt.Close(); };
            if (options != null)
            {
                ComboBox cb = CAT.GetComboBox(upatedtext, options, left: 5, top: 30, width: 580);
                cb.SelectedValueChanged += new EventHandler((object o, EventArgs e) => { textBox.Text = cb.Text; });
                prompt.Controls.Add(cb);
            }
            prompt.Controls.Add(textBox);
            prompt.Controls.Add(confirmation);
            prompt.AcceptButton = confirmation;
            DialogResult result = prompt.ShowDialog();

            if (result == DialogResult.OK)
            {
                upatedtext = textBox.Text.Trim();
                return(true);
            }
            return(false);
        }
コード例 #5
0
        /// =======================================================================================================
        public static Return UDP_SEND(string IP_address, string port, string text_to_send)
        {
            List <CATMessage> msgs   = new List <CATMessage>();
            Socket            socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

            socket.SendTo(Encoding.ASCII.GetBytes(text_to_send), new IPEndPoint(IPAddress.Parse(IP_address), Convert.ToInt16(port)));
            socket.Close();
            CAT.FormAccess(CAT.FormDelegates.AddOverlay, new object[] { text_to_send, Status.INFO });
            return(new Return(msgs));
        }
コード例 #6
0
ファイル: RunAuto.cs プロジェクト: BrettJohn/CAT
        /// =======================================================================================================
        private static void RunAuto(AutoReport auto_report, string auto_alias, string binary_name,
                                    out List <Control> interactive_controls)
        {
            List <Control> interactivecontrols = new List <Control>();
            DataGridView   autodata            = Data.BlankDgv((int)CAT.AutoFields.NumberOfColumns);
            DataGridView   batchdata           = Data.BlankDgv((int)CAT.BatchFields.NumberOfColumns);
            string         binary_path         = DISK.AutoAddBaseDirectory(auto_alias + @"\" + binary_name);

            Data.LoadDataGrid(binary_path, ref autodata);
            FormAccess(FormDelegates.LoadAutoData, null, auto_alias);
            FormAccess(FormDelegates.ClearAutoStatuses, new object[] { }, auto_alias);
            foreach (DataGridViewRow autorow in autodata.Rows)
            {
                if (autorow.Index < autodata.RowCount - 1)
                {
                    if (!AbortAll)
                    {
                        Data.LoadDataGrid(new FileInfo(binary_path).Directory.FullName + @"\batch" + autorow.Index + ".bin", ref batchdata);
                        Action runbatch = new Action(() =>
                        {
                            List <Control> ctrls;
                            RunBatch(auto_report, auto_alias, autorow.Index, autodata, batchdata, out ctrls);
                            if (ctrls != null)
                            {
                                foreach (Control ctrl in ctrls)
                                {
                                    interactivecontrols.Add(ctrl);
                                }
                            }
                        });
                        if (Regex.IsMatch(Data.GetCell(autodata, (int)CAT.AutoFields.Mode, autorow.Index), "-t"))
                        {
                            Task t = new Task(() => { runbatch(); });
                            AutoTasks.Add(t);
                            t.Start();
                        }
                        else
                        {
                            runbatch();
                        }
                    }
                    else
                    {
                        FormAccess(FormDelegates.SetBatchStatus, new object[] { Status.ABORT, autorow.Index }, auto_alias);
                    }
                }
            }
            CAT.FormAccess(CAT.FormDelegates.SaveAuto, new object[] { }, auto_alias);
            interactive_controls = interactivecontrols;
        }
コード例 #7
0
ファイル: InteractiveControls.cs プロジェクト: BrettJohn/CAT
        /// =======================================================================================================
        public static void InteractiveShowReport(Func <Return> returndatafunction, double y_scale)
        {
            CAT.FormAccess(CAT.FormDelegates.FormClose, null, "Report");
            AutoReport autoreport = new AutoReport(CAT.InteractiveControlsFormName);
            Map        map        = new Map(CAT.InteractiveControlsFormName, 0, 0);

            try
            {
                DateTime start    = DateTime.Now;
                bool     complete = false;
                InteractiveAddNamedOverlay("InteractiveProgress", "Started", Status.BUSY);
                new Thread(() =>
                {
                    while (!complete)
                    {
                        InteractiveUpdateNamedOverlay("InteractiveProgress", "Processing " + (DateTime.Now - start).TotalMilliseconds + "ms", Status.BUSY);
                        Thread.Sleep(10);
                    }
                    InteractiveUpdateNamedOverlay("InteractiveProgress", "Complete " + (DateTime.Now - start).TotalMilliseconds + "ms", Status.PASS);
                }).Start();
                autoreport.AddBatch(new BatchReport(0, "Batch"));
                autoreport.AddCommand(new CommandReport(map, "Command"));
                Return returndata = returndatafunction();
                if (returndata.Charts != null)
                {
                    autoreport.AddChartList(map, returndata.Charts);
                }
                if (returndata.Messages != null)
                {
                    foreach (CATMessage msg in returndata.Messages)
                    {
                        autoreport.AddOverlayedMessage(map, msg.Text, msg.Status);
                    }
                }
                autoreport.CommandComplete(map, CAT.Status.PASS);
                autoreport.BatchComplete(0);
                autoreport.AutoComplete();
                CAT.ShowReport(autoreport, y_scale);
                complete = true;
            }
            catch (Exception ex)
            {
                InteractiveUpdateNamedOverlay("InteractiveProgress", "Failed control", Status.PASS);
                autoreport.AddOverlayedMessage(map, CAT.ErrorMsg(ex), CAT.Status.FAIL);
                try { CAT.ShowReport(autoreport, y_scale); } catch { }
            }
        }
コード例 #8
0
        // FEATURES
        /// =======================================================================================================
        public static void RUN_AUTO(string auto_alias)
        {
            Running = false; // TODO hack to get passed recursion

            foreach (Form o in Application.OpenForms)
            {
                if (o.Name.Contains("CAT"))
                {
                    ConstructorInfo ci       = o.GetType().GetConstructor(new[] { typeof(string) });
                    object          instance = ci.Invoke(new object[] { auto_alias });
                    Thread          thread   = new Thread(() => Application.Run((Form)instance));
                    thread.Start();
                    Thread.Sleep(2000);
                    //AutoReport = new AutoReport(auto_alias);
                    CAT.FormAccess(CAT.FormDelegates.RunAuto, null, auto_alias);
                }
            }
        }
コード例 #9
0
 /// =======================================================================================================
 public void AutoComplete()
 {
     EndTime = DateTime.Now;
     if (BatchReports.Count > 0)
     {
         string reportfolder = DISK.AutoAddBaseDirectory(Alias) + @"\Reports\";
         DISK.CreateFolder(reportfolder);
         string reportpath            = reportfolder + "AutoReport.bin";
         string timestampedreportpath = reportfolder + "AutoReport" + Timer.TimeStamp() + ".bin";
         Save(reportpath);
         Save(timestampedreportpath);
         CAT.FormAccess(CAT.FormDelegates.UpdateNamedOverlay, new object[] { Alias, Alias + " complete (" + AutoDuration() + ")", CalculatedAutoResult() }, Alias);
     }
     else
     {
         CAT.FormAccess(CAT.FormDelegates.UpdateNamedOverlay, new object[] { Alias, "No report for" + Alias, CAT.Status.ABORT }, Alias);
         Enabled = false;
     }
 }
コード例 #10
0
 /// =======================================================================================================
 public void BatchComplete(int batch, CAT.Status?status = null)
 {
     CAT.Status result = status == null ? BatchReports[batch].CalculatedResult() : (CAT.Status)status;
     CAT.FormAccess(CAT.FormDelegates.UpdateNamedOverlay, new object[] { BatchAlias(batch), BatchDescription(batch) + " complete", result }, Alias);
     BatchReports[batch].Complete(result);
 }
コード例 #11
0
 /// =======================================================================================================
 public void UpdateOverlay(string overlayname, string message, CAT.Status status)
 {
     CAT.FormAccess(CAT.FormDelegates.UpdateNamedOverlay, new object[] { overlayname, message, status }, Alias);
 }
コード例 #12
0
 /// =======================================================================================================
 public void BatchComplete(int b, CAT.Status status)
 {
     CAT.FormAccess(CAT.FormDelegates.UpdateNamedOverlay, new object[] { BatchAlias(b), BatchDescription(b) + " complete", status }, Alias);
     BatchReports[b].Complete(status);
 }
コード例 #13
0
 /// =======================================================================================================
 public void AddOverlay(string message, CAT.Status status)
 {
     CAT.FormAccess(CAT.FormDelegates.AddNamedOverlay, new object[] { "autoReportOverlay" + overlaynumber++, message, status }, Alias);
 }
コード例 #14
0
 /// =======================================================================================================
 public void UpdateBatchProgress(int b)
 {
     CAT.FormAccess(CAT.FormDelegates.UpdateNamedOverlay, new object[] { BatchAlias(b),
                                                                         BatchDescription(b) + " " + BatchReports[b].Duration(), CAT.Status.BUSY }, Alias);
 }
コード例 #15
0
 /// =======================================================================================================
 public void CommandComplete(Map map, CAT.Status status)
 {
     CAT.FormAccess(CAT.FormDelegates.UpdateNamedOverlay, new object[] { CommandAlias(map), CommandDescription(map) + " complete", status }, Alias);
     BatchReports[map.B].CommandReports[map].Complete(status);
 }
コード例 #16
0
 /// =======================================================================================================
 public string Summary()
 {
     return("[" + CAT.IndexLetter(Number) + "] " + Alias + " " + StartTime + " " + Duration() + " " + ResultStatus);
 }
コード例 #17
0
ファイル: RunBatch.cs プロジェクト: BrettJohn/CAT
        /// =======================================================================================================
        private static void RunBatch(AutoReport auto_report, string auto_alias, int batch_number,
                                     DataGridView auto_data, DataGridView batch_data, out List <Control> interactive_controls, int?command_number = null)
        {
            List <Control> interactivecontrols = new List <Control>();
            int            rep = 1;

            if (Regex.IsMatch(Data.GetCell(auto_data, (int)CAT.AutoFields.Mode, batch_number), COMMAND_MODE_REPEAT))
            {
                rep = Convert.ToInt16(Regex.Match(Data.GetCell(auto_data, (int)CAT.AutoFields.Mode, batch_number), COMMAND_MODE_REPEAT).Value.Substring(1));
            }
            for (int i = 0; i < rep; i++)
            {
                Action runbatch = new Action(() =>
                {
                    FormAccess(FormDelegates.SelectAutoRow, new object[] { batch_number }, auto_alias);
                    FormAccess(FormDelegates.LoadBatchData, new object[] { batch_number }, auto_alias);
                    FormAccess(FormDelegates.ClearBatchStatuses, new object[] { }, auto_alias);
                    auto_report.AddBatch(new BatchReport(batch_number, Data.GetCell(auto_data, (int)CAT.AutoFields.Name, batch_number)));
                    Status?status = null;
                    if (Data.IsBatchEnabled(auto_data, batch_number) || command_number != null)
                    {
                        CAT.FormAccess(CAT.FormDelegates.SetBatchStatus, new object[] { Status.BUSY, batch_number }, auto_alias);
                        foreach (DataGridViewRow commandrow in batch_data.Rows)
                        {
                            if (!AbortAll && ((command_number != null && command_number == commandrow.Index) || command_number == null) && commandrow.Index < batch_data.RowCount - 1)
                            {
                                FormAccess(FormDelegates.SelectBatchRow, new object[] { commandrow.Index }, auto_alias);
                                List <Control> ctrls;
                                RunCommand(auto_report, new Map(auto_alias, batch_number, commandrow.Index), batch_data, out ctrls, GetAutoVars(auto_data, batch_number, auto_alias));
                                if (ctrls != null)
                                {
                                    foreach (Control ctrl in ctrls)
                                    {
                                        interactivecontrols.Add(ctrl);
                                    }
                                }
                            }
                        }
                        status = auto_report.CalculatedBatchResult(batch_number);
                    }
                    else
                    {
                        status = Status.SKIP;
                    }

                    CAT.FormAccess(CAT.FormDelegates.SetBatchStatus, new object[] { status, batch_number }, auto_alias);
                    auto_report.BatchComplete(batch_number, status);
                });
                if (Regex.IsMatch(Data.GetCell(auto_data, (int)CAT.AutoFields.Mode, batch_number), "-t"))
                {
                    Task t = new Task(() => { runbatch(); });
                    BatchTasks.Add(t);
                    t.Start();
                }
                else
                {
                    runbatch();
                    CAT.FormAccess(CAT.FormDelegates.SaveSelectedBatch, new object[] { }, auto_alias);
                }
            }
            interactive_controls = interactivecontrols;
        }
コード例 #18
0
 /// =======================================================================================================
 public string Alias()
 {
     return(CommandMap + CAT.Simplify(Description));
 }                                                                    // Not visible to user
コード例 #19
0
 /// =======================================================================================================
 public string BatchDescription(int batch)
 {
     return("Batch[" + CAT.IndexLetter(BatchReports[batch].Number) + "]:" + BatchReports[batch].Alias);
 }
コード例 #20
0
ファイル: RunCommand.cs プロジェクト: BrettJohn/CAT
        /// =======================================================================================================
        private static void RunCommand(AutoReport auto_report, Map map, DataGridView batch_data,
                                       out List <Control> interactive_controls,
                                       List <Var> vars = null)
        {
            List <Control> interactivecontrols = null;
            int            rep = 1;

            if (Regex.IsMatch(Data.GetCell(batch_data, (int)CAT.BatchFields.Mode, map.C), COMMAND_MODE_REPEAT))
            {
                rep = Convert.ToInt16(Regex.Match(Data.GetCell(batch_data, (int)CAT.BatchFields.Mode, map.C), COMMAND_MODE_REPEAT).Value.Substring(1));
            }
            if (Regex.IsMatch(Data.GetCell(batch_data, (int)CAT.BatchFields.Mode, map.C), COMMAND_MODE_THREAD_CATCH))
            {
                auto_report.WaitForPreviousBatches(map);
            }
            Action runcommand = new Action(() =>
            {
                for (int i = 1; i <= rep; i++)
                {
                    DataGridViewRow cmd = batch_data.Rows[map.C];
                    string workdir      = Data.GetCell(cmd, (int)CAT.BatchFields.Path);
                    string command      = Data.GetCell(cmd, (int)CAT.BatchFields.Command);
                    Map newmap          = new Map(map.A, map.B, map.C, rep > 1 ? i : 0);
                    auto_report.AddCommand(new CommandReport(newmap, workdir + ">" + command));
                    Status status = Status.START;
                    if (Data.IsCommandEnabled(cmd))
                    {
                        if (vars != null)
                        {
                            string initialcommand = command;
                            string initialworkdir = workdir;
                            foreach (Var vartoinsert in vars)
                            {
                                command = command.Replace("{" + vartoinsert.Name + "}", vartoinsert.Value);
                                workdir = workdir.Replace("{" + vartoinsert.Name + "}", vartoinsert.Value);
                            }
                            command = BasicArithmetic(command);
                            if (initialcommand != command || initialworkdir != workdir)
                            {
                                auto_report.AddOverlayedMessage(newmap, "Variable updates (Workdir>Command): " + workdir + ">" + command, Status.WARN);
                            }
                        }
                        if (string.IsNullOrWhiteSpace(Data.GetCell(cmd, (int)CAT.BatchFields.Command)))
                        {
                            auto_report.AddOverlayedMessage(newmap, "Command is null", Status.FAIL);
                            status = Status.FAIL;
                        }
                        else if (string.IsNullOrWhiteSpace(Data.GetCell(cmd, (int)CAT.BatchFields.Timeout)))
                        {
                            auto_report.AddOverlayedMessage(newmap, "Timeout is null", Status.FAIL);
                            status = Status.FAIL;
                        }
                        else
                        {
                            CAT.FormAccess(CAT.FormDelegates.SetCommandStatus, new object[] { Status.BUSY, newmap.C }, newmap.A);
                            if (Regex.IsMatch(Data.GetCell(cmd, (int)CAT.BatchFields.Path), @".*\.dll"))
                            {
                                status = RunDll(newmap, workdir, command, Data.GetCmdTimeout(cmd), out interactivecontrols, auto_report);
                            }
                            else
                            {
                                status = RunCmd(auto_report, newmap, "cmd.exe", workdir, command, Data.GetCmdTimeout(cmd), "/C");
                            }
                        }
                    }
                    else
                    {
                        status = Status.SKIP;
                    }
                    auto_report.CommandComplete(newmap, status);
                    CAT.FormAccess(CAT.FormDelegates.SetCommandStatus, new object[] { status, newmap.C }, newmap.A);
                }
            });

            if (Regex.IsMatch(Data.GetCell(batch_data, (int)CAT.BatchFields.Mode, map.C), "-t"))
            {
                Task t = new Task(() => { runcommand(); });
                CommandTasks.Add(t);
                t.Start();
            }
            else
            {
                runcommand();
            }
            interactive_controls = interactivecontrols;
        }
コード例 #21
0
ファイル: Graph.cs プロジェクト: BrettJohn/CAT
        /// =======================================================================================================
        public static Chart Milliseconds(ChartData input, string title, int height = 100,
                                         double vertical_scale = 1.0, int width = 500, double interval_s = 1.0)
        {
            Chart graph = new Chart()
            {
                Name = string.IsNullOrWhiteSpace(title) ? "Graph" + GraphCounter : CAT.Simplify(title),
                Font = CAT.CATFont, Height = height, Dock = DockStyle.None, BackColor = Color.Black, ForeColor = Color.White
            };
            ChartArea chartArea = new ChartArea()
            {
                Name = "ChartArea"
            };

            graph.ChartAreas.Add(chartArea);
            Color[] linecolors = { Color.Blue, Color.Purple, Color.Green, Color.Orange, Color.Beige, Color.Pink };
            graph.ChartAreas[0].BackColor = Color.Black;
            graph.ChartAreas[0].Axes[0].MajorGrid.LineColor = Color.Yellow;
            graph.ChartAreas[0].Axes[0].MinorGrid.LineColor = Color.DimGray;
            graph.ChartAreas[0].Position.Auto            = false;
            graph.ChartAreas[0].Position.X               = 0;
            graph.ChartAreas[0].Position.Y               = 0;
            graph.ChartAreas[0].Position.Width           = 100;
            graph.ChartAreas[0].Position.Height          = 90;
            graph.ChartAreas[0].InnerPlotPosition.Auto   = false;
            graph.ChartAreas[0].InnerPlotPosition.X      = 0;
            graph.ChartAreas[0].InnerPlotPosition.Y      = 0;
            graph.ChartAreas[0].InnerPlotPosition.Width  = 100;
            graph.ChartAreas[0].InnerPlotPosition.Height = 90;


            // Lines
            List <double> newwaveX = new List <double>();
            List <double> newwaveY = new List <double>();
            int           count    = 0;

            foreach (List <Xy> xy in input.Data)
            {
                newwaveX = new List <double>();
                newwaveY = new List <double>();
                for (int i = 0; i < xy.Count; i++)
                {
                    newwaveX.Add(xy[i].X);
                    newwaveY.Add(xy[i].Y * vertical_scale);
                }
                graph.Series.Add(count.ToString());
                graph.Series[count].Points.DataBindXY(newwaveX.ToArray(), newwaveY.ToArray());
                graph.Series[count].Color             = linecolors[count];
                graph.Series[count].ChartType         = SeriesChartType.Line;
                graph.Series[count].YValueMembers     = "Y";
                graph.Series[count].XValueMember      = "X";
                graph.Series[count].IsVisibleInLegend = false;
                graph.DataBind();
                count++;
            }

            // Grids
            Xy     max       = Maths.Max(input.Data);
            double smallestx = newwaveX[0];
            double largestx  = newwaveX[newwaveX.Count - 1];

            graph.ChartAreas[0].AxisX.Minimum                 = smallestx;
            graph.ChartAreas[0].AxisX.Maximum                 = largestx;
            graph.ChartAreas[0].AxisX.MinorGrid.Interval      = interval_s;
            graph.ChartAreas[0].AxisX.MinorGrid.LineDashStyle = ChartDashStyle.Dot;
            graph.ChartAreas[0].AxisX.LabelStyle.ForeColor    = Color.White;
            graph.ChartAreas[0].AxisY.Maximum                 = 0.5;
            graph.ChartAreas[0].AxisY.Minimum                 = -0.5;
            //graph.ChartAreas[0].AxisX.IsMarginVisible = true;
            //  graph.ChartAreas[0].AxisY.IsMarginVisible = false;

            // Determine graph dimensions
            string text = "";

            if (input.Type == ChartType.Time)
            {
                graph.Width = width;
                graph.ChartAreas[0].AxisX.Interval = input.Time.TimeBaseSeconds;
                //graph.ChartAreas[0].AxisX.MinorGrid.Enabled = true;
                //graph.ChartAreas[0].AxisX.MajorGrid.Enabled = true;
                text = max.Y.ToString("F2") + " at " + (int)(max.X % (int)input.Time.TimeBaseSeconds) + "ms";
            }
            else
            {
                graph.Width = width;
                graph.ChartAreas[0].AxisX.Interval = largestx;
                // graph.ChartAreas[0].AxisX.MinorGrid.Enabled = false;
                // graph.ChartAreas[0].AxisX.MajorGrid.Enabled = true;
                text = "";
            }
            graph.BorderlineColor = Color.White;
            graph.Titles.Add(new Title(string.IsNullOrWhiteSpace(title) ? text : title, Docking.Top, CAT.CATFont, Color.White));
            return(graph);
        }
コード例 #22
0
 /// =======================================================================================================
 public string CommandDescription(Map map)
 {
     return("Command[" + CAT.IndexLetter(map.C) + "]:" + BatchReports[map.B].CommandReports[map].Description);
 }
コード例 #23
0
ファイル: FormDelegate.cs プロジェクト: BrettJohn/CAT
 // Basic Abstractions
 /// =======================================================================================================
 public static void AddOverlay(string auto_alias, string msg, Status status = Status.FAIL)
 {
     CAT.FormAccess(CAT.FormDelegates.AddOverlay, new object[] { msg, status }, auto_alias);
 }
コード例 #24
0
 /// =======================================================================================================
 public void UpdateCommandProgress(Map map)
 {
     CAT.FormAccess(CAT.FormDelegates.UpdateNamedOverlay, new object[] { CommandAlias(map),
                                                                         CommandDescription(map) + " " + BatchReports[map.B].CommandReports[map].Duration(), CAT.Status.BUSY }, Alias);
 }