Ejemplo n.º 1
0
        public void SawMillHeatMapPersistance()
        {
            List <SawMillScreen> screens = new List <SawMillScreen>();

            screens.Add(new VEScreen(7100, 2.5f));
            SawMill sawMill1 = SawMill.GetInstance(Environment.CurrentDirectory, "Mock ECU", null, screens, this.Update);

            MemoryStream stream = new MemoryStream();

            sawMill1.WriteTo(stream);

            stream.Position = 0;

            SawMill sawMill2 = SawMill.GetInstance(Environment.CurrentDirectory, "Mock ECU", null, screens, this.Update);

            sawMill2.ReadFrom(stream);

            // TODO: verify consistency of data
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Load
        /// </summary>
        void SawMillMainForm_Load(object sender, EventArgs e)
        {
            this.SetBounds();

            string configurationDirectory = Path.Combine(
                Environment.CurrentDirectory,
                "Configuration");

            Trace.WriteLine("SawMill.SawMillMainForm_Load: SSM Port = " + Settings.Default.SsmPort);
            if (Settings.Default.SsmPort == "Mock ECU")
            {
                MessageBox.Show(
                    "Bogus data will be displayed." +
                    Environment.NewLine +
                    "If you want real data, change the \"Port\" setting in" +
                    Environment.NewLine +
                    "SawMill.exe.config to COM1 or COM2 or whatever.",
                    "SawMill");
            }

            while (this.sawMill == null)
            {
                Exception exception = null;

                try
                {
                    this.sawMill = SawMill.GetInstance(
                        configurationDirectory,
                        Settings.Default.SsmPort,
                        Settings.Default.PlxPort,
                        this.screens,
                        this.Update);
                }
                catch (SecurityException ex)
                {
                    exception = ex;
                }
                catch (IOException ex)
                {
                    exception = ex;
                }
                catch (UnauthorizedAccessException ex)
                {
                    exception = ex;
                }

                if (exception != null)
                {
                    string message = string.Format("Unable to start: {0}{1}({2})",
                                                   exception.Message,
                                                   Environment.NewLine,
                                                   exception.GetType().Name);

                    DialogResult result = MessageBox.Show(
                        message,
                        "SawMill",
                        MessageBoxButtons.RetryCancel);

                    if (result == DialogResult.Retry)
                    {
                        continue;
                    }

                    this.Close();
                    return;
                }
            }

            this.sawMill.Exception += this.RenderException;
            this.ReadData();
            this.sawMill.BeginConnect(this.Connected, null);
        }