Exemple #1
0
        public MachineConfig DeserializeMachineConfigParameters(out bool success)
        {
            FileStream readFileStream = null;

            success = false;

            string path = Path.Combine(Environment.ExpandEnvironmentVariables("%PUBLIC%").ToString(),
                                       "BluePrint Robotics", "PopsicleImaging", "PopsicleImagingJobs", "Config");

            if (!Directory.Exists(path) || !Directory.Exists(@"C:\Program Files\Blueprint Robotics"))
            {
                path = Application.StartupPath + "\\Jobs\\Config";

                // Determine if running from the IDE and change the path
                if (path.Contains("\\bin\\Debug"))
                {
                    path = path.Replace("\\bin\\Debug", "");
                }

                if (path.Contains("\\bin\\Release"))
                {
                    path = path.Replace("\\bin\\Release", "");
                }
            }

            // Deserialize the object
            try
            {
                // Create a new file stream for reading the XML file
                using (readFileStream = new FileStream(path + "\\machineConfig.xml", FileMode.Open))
                {
                    XmlReader reader = XmlReader.Create(readFileStream);

                    // Deserialize object
                    this.mc = (MachineConfig)this.machineXmlSerializer.Deserialize(reader);
                    readFileStream.Close();
                    success = true;
                }
            }
            catch (FileNotFoundException)
            {
                StringBuilder st = new StringBuilder();
                st.Append("**** Machine Configuration file not found!****\n");
                st.Append("\n");
                st.Append("Ensure the file 'machineConfig.xml exists @path: " + path + "\\");

                MessageBox.Show(st.ToString(), "Error!");
            }
            catch (Exception ex) { MessageBox.Show("Exception @DeserializeMachineConfigParamters: " + ex.Message, "Exception Error"); }
            finally
            {
                if (readFileStream != null)
                {
                    readFileStream.Close();
                }
            }

            return(mc);
        }
Exemple #2
0
        public void SerializeMachineConfigParameters(MachineConfig mc, out bool success)
        {
            TextWriter writeFileStream = null;
            string     path            = Path.Combine(Environment.ExpandEnvironmentVariables("%PUBLIC%").ToString(),
                                                      "BluePrint Robotics", "PopsicleImaging", "PopsicleImagingJobs", "Config");

            success = false;

            if (!Directory.Exists(path) || !Directory.Exists(@"C:\Program Files\Blueprint Robotics"))
            {
                path = Application.StartupPath + "\\Jobs\\Config";

                // Determine if running from the IDE and change the path
                if (path.Contains("\\bin\\Debug"))
                {
                    path = path.Replace("\\bin\\Debug", "");
                }

                if (path.Contains("\\bin\\Release"))
                {
                    path = path.Replace("\\bin\\Release", "");
                }
            }

            // Serialize the object

            try
            {
                using (writeFileStream = new StreamWriter(path + "\\machineConfig.xml"))
                {
                    XmlWriter writer = XmlWriter.Create(writeFileStream);

                    machineXmlSerializer.Serialize(writer, mc);

                    writeFileStream.Close();

                    success = true;
                }
            }
            catch (FileNotFoundException)
            {
                StringBuilder st = new StringBuilder();
                st.Append("**** Machine Configuration file not found!****\n");
                st.Append("\n");
                st.Append("Ensure the file 'machineConfig.xml exists @path: " + path + "\\");

                MessageBox.Show(st.ToString(), "Error!");
            }
            catch (Exception ex) { MessageBox.Show("Exception @SerializeMachineConfigParamters: " + ex.Message, "Exception Error"); }
            finally
            {
                if (writeFileStream != null)
                {
                    writeFileStream.Close();
                }
            }
        }
Exemple #3
0
        public ParmLauncher(MainForm mf, RuntimeParameters rp, CogJobManager cjm, MachineConfig mc)
        {
            InitializeComponent();

            mainForm          = mf;
            runtimeParameters = rp;
            machineParameters = mc;
            mcjmAcq           = cjm;
        }