Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            new N("INCC6 Console");
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
            NCCConfig.Config c = new NCCConfig.Config(); // gets DB params
            if (!N.App.LoadPersistenceConfig(c.DB)) // loads up DB, sets global AppContext
                return;
            c.AfterDBSetup(N.App.AppContext, args);  // apply the cmd line
            string[] possiblepaths = NCCFile.FileCtrl.ProcessINCC5IniFile(N.App.Logger(LMLoggers.AppSection.Control)); // iRap: optional use of INCC5 ini file to find results and output paths
            if (possiblepaths.Length > 2)  // use the iRAP defined input, results and log file paths
            {
                N.App.AppContext.FileInput = possiblepaths[0];
                if (System.IO.Directory.Exists(possiblepaths[1]))
                    N.App.AppContext.ResultsFilePath = possiblepaths[1];
                if (System.IO.Directory.Exists(possiblepaths[2]))
                    N.App.AppContext.LogFilePath = possiblepaths[2];
            }
            // check return bool and exit here on error
            bool initialized = N.App.Initialize(c);
            if (!initialized)
                return;

            if (N.App.Config.Cmd.ShowVersion && !N.App.Config.Cmd.Showcfg)
            {
                N.App.Config.Cmd.ShowVersionOnConsole(N.App.Config, N.App.Config.App.Verbose() == TraceEventType.Verbose);
                return;
            }
            else if (N.App.Config.Cmd.Showhelp)
            {
                N.App.Config.ShowHelp();
                return;
            }
            else if (N.App.Config.Cmd.Showcfg)
            {
                NCCConfig.Config.ShowCfg(N.App.Config, N.App.Config.App.Verbose() == TraceEventType.Verbose);
                return;
            }

            LMLoggers.LognLM applog = N.App.Logger(LMLoggers.AppSection.App);
            bool OpenResults = N.App.AppContext.OpenResults;
            try
            {
                applog.TraceInformation("==== Starting " + DateTime.Now.ToString("MMM dd yyy HH:mm:ss.ff K") + " [Cmd] " + N.App.Name + " " + N.App.Config.VersionString);
                applog.TraceInformation("==== DB " + N.App.Pest.DBDescStr);
                // These affect the current acquire state, so they occur here and not earlier in the inital processing sequence
                if (!string.IsNullOrEmpty(c.Cur.Detector) && !c.Cur.Detector.Equals("Default")) // command line set the value
                    initialized = Integ.SetNewCurrentDetector(c.Cur.Detector, true);
                if (!initialized)
                    goto end;

                if (!string.IsNullOrEmpty(c.Cur.Material) && !c.Cur.Material.Equals("Pu")) // command line set the value
                    initialized = Integ.SetNewCurrentMaterial(c.Cur.Material, true);
                if (!initialized)
                    goto end;

                if (!string.IsNullOrEmpty(c.Cur.ItemId)) // command line set the item value, use it to override the material and other acquire params
                    initialized = Integ.SetNewCurrentMaterial(c.Cur.Material, true);
                if (!initialized)
                    goto end;

                if (!N.App.AppContext.ReportSectional.Equals(NCCConfig.Config.DefaultReportSectional)) // command line set the value
                {
                    AcquireParameters acq = null;
                    Detector det = null;
                    Integ.GetCurrentAcquireDetectorPair(ref acq, ref det);
                    acq.review.Scan(N.App.AppContext.ReportSectional);
                    acq.MeasDateTime = DateTime.Now;
                    N.App.DB.UpdateAcquireParams(acq, det.ListMode);
                    N.App.Logger(LMLoggers.AppSection.Control).TraceEvent(LogLevels.Info, 32444, "The current report sections are now " + N.App.AppContext.ReportSectional);
                }
                if (N.App.Config.App.UsingFileInput || N.App.Opstate.Action == NCC.NCCAction.File)
                {
                    if (N.App.AppContext.AssayFromFiles)
                        N.App.Opstate.Action = NCC.NCCAction.Assay;
                    else if (N.App.AppContext.HasFileAction)
                        N.App.Opstate.Action = NCC.NCCAction.File;
                }

                if (N.App.Config.Cmd.Query != null)
                {
                    AcquireParameters acq = Integ.GetCurrentAcquireParams();
                    System.Collections.Generic.List<string> ls = acq.ToDBElementList(generate:true).AlignedNameValueList;
                    foreach(string s in ls)
                        Console.WriteLine(s);
                    OpenResults = false;
                    if (N.App.Opstate.Action == NCC.NCCAction.Nothing)
                        return;
                }

                if (N.App.Config.App.UsingFileInput || N.App.Opstate.Action == NCC.NCCAction.File)
                {
                    BuildMeasurement();
                    if (N.App.AppContext.AssayFromFiles)
                        N.App.Opstate.Action = NCC.NCCAction.Assay;
                    else if (N.App.AppContext.HasFileAction)
                        N.App.Opstate.Action = NCC.NCCAction.File;

                    // file processing for analysis and more
                    FileControlBind filecontrol = new FileControlBind();
                    filecontrol.SetupEventHandlers();
                    filecontrol.StartAction();  // step into the code and run
                    N.App.Opstate.SOH = NCC.OperatingState.Stopped;
                }
                else
                {
                    BuildMeasurement();
                    DAQControlBind control = new DAQControlBind();
                    DAQ.DAQControl.ActivateDetector(N.App.Opstate.Measurement.Detector);
                    control.SetupEventHandlers();
                    control.StartAction();
                    N.App.Opstate.SOH = NCC.OperatingState.Stopped;
                }
                end:
                ;
            } catch (Exception e)
            {
                N.App.Opstate.SOH = NCC.OperatingState.Trouble;
                applog.TraceException(e, true);
                applog.EmitFatalErrorMsg();
            } finally
            {
                N.App.Opstate.SOH = NCC.OperatingState.Stopped;
                N.App.Config.RetainChanges();
                applog.TraceInformation("==== Exiting " + DateTime.Now.ToString("MMM dd yyy HH:mm:ss.ff K") + " [Cmd] " + N.App.Name + " . . .");
                N.App.Loggers.Flush();
                if (OpenResults) Process.Start(System.IO.Path.Combine(Environment.SystemDirectory, "notepad.exe"), LMLoggers.LognLM.CurrentLogFilePath);
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            new NC("INCC6 Console");

            NCCConfig.Config c = new NCCConfig.Config(); // gets DB params
            NC.App.LoadPersistenceConfig(c.DB);          // loads up DB, sets global AppContext
            c.AfterDBSetup(NC.App.AppContext, args);     // apply the cmd line
            bool initialized = NC.App.Initialize(c);

            // check return bool and exit here on error
            if (!initialized)
            {
                return;
            }

            if (NC.App.Config.Cmd.ShowVersion && !NC.App.Config.Cmd.Showcfg)
            {
                NC.App.Config.Cmd.ShowVersionOnConsole(NC.App.Config, NC.App.Config.App.Verbose() == TraceEventType.Verbose);
                return;
            }
            else if (NC.App.Config.Cmd.Showhelp)
            {
                NC.App.Config.ShowHelp();
                return;
            }
            else if (NC.App.Config.Cmd.Showcfg)
            {
                NCCConfig.Config.ShowCfg(NC.App.Config, NC.App.Config.App.Verbose() == TraceEventType.Verbose);
                return;
            }

            LMLoggers.LognLM applog = NC.App.Logger(LMLoggers.AppSection.App);

            applog.TraceInformation("==== Starting " + DateTime.Now.ToString("MMM dd yyy HH:mm:ss.ff K") + " [Cmd] " + NC.App.Name + " " + NC.App.Config.VersionString);
            // TODO: log DB details at startup too
            try
            {
                BuildMeasurement();
                if (NC.App.Config.App.UsingFileInput)
                {
                    if (NC.App.AppContext.AssayFromFiles)
                    {
                        NC.App.Opstate.Action = NCC.NCCAction.Assay;
                    }
                    else
                    {
                        NC.App.Opstate.Action = NCC.NCCAction.File;
                    }

                    // file processing for analysis and more
                    FileControlBind filecontrol = new FileControlBind();

                    filecontrol.SetupEventHandlers();

                    filecontrol.StartAction();  // step into the code and Run run run!

                    NC.App.Opstate.SOH = NCC.OperatingState.Stopped;
                }
                else
                {
                    // NEXT: one of Assay, HV or Discover NC.App.Opstate.Action = NCC.NCCAction.;
                    // DAQ + prompt
                    DAQControlBind daqcontrol = new DAQControlBind((MLMEmulation.IEmulatorDiversion)(new LMProcessor.NullEmulation())); //<- here

                    daqcontrol.SetupTimerCallBacks();
                    daqcontrol.SetupEventHandlers();

                    DAQControlBind.ActivateDetector(NC.App.Opstate.Measurement.Detectors[0]);

                    daqcontrol.StartAction(); // step into the code and Run run run!

                    NC.App.Opstate.SOH = NCC.OperatingState.Stopped;
                }
            }
            catch (Exception e)
            {
                NC.App.Opstate.SOH = NCC.OperatingState.Trouble;
                applog.TraceException(e, true);
                applog.EmitFatalErrorMsg();
            }
            finally
            {
                NC.App.Opstate.SOH = NCC.OperatingState.Stopped;
                NC.App.Config.RetainChanges();
                applog.TraceInformation("==== Exiting " + DateTime.Now.ToString("MMM dd yyy HH:mm:ss.ff K") + " [Cmd] " + NC.App.Name + " . . .");
                NC.App.Loggers.Flush();
            }
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            new NC("INCC6 Console");

            NCCConfig.Config c = new NCCConfig.Config(); // gets DB params
            NC.App.LoadPersistenceConfig(c.DB); // loads up DB, sets global AppContext
            c.AfterDBSetup(NC.App.AppContext, args);  // apply the cmd line 
            bool initialized = NC.App.Initialize(c);
            // check return bool and exit here on error
            if (!initialized)
                return;

            if (NC.App.Config.Cmd.ShowVersion && !NC.App.Config.Cmd.Showcfg)
            {
                NC.App.Config.Cmd.ShowVersionOnConsole(NC.App.Config, NC.App.Config.App.Verbose() == TraceEventType.Verbose);
                return;
            }
            else if (NC.App.Config.Cmd.Showhelp)
            {
                NC.App.Config.ShowHelp();
                return;
            }
            else if (NC.App.Config.Cmd.Showcfg)
            {
                NCCConfig.Config.ShowCfg(NC.App.Config, NC.App.Config.App.Verbose() == TraceEventType.Verbose);
                return;
            }

            LMLoggers.LognLM applog = NC.App.Logger(LMLoggers.AppSection.App);

            applog.TraceInformation("==== Starting " + DateTime.Now.ToString("MMM dd yyy HH:mm:ss.ff K") + " [Cmd] " + NC.App.Name + " " + NC.App.Config.VersionString);
            // TODO: log DB details at startup too 
            try
            {
                BuildMeasurement();
                if (NC.App.Config.App.UsingFileInput)
                {
                    if (NC.App.AppContext.AssayFromFiles)
                        NC.App.Opstate.Action = NCC.NCCAction.Assay;
                    else
                        NC.App.Opstate.Action = NCC.NCCAction.File;

                    // file processing for analysis and more
                    FileControlBind filecontrol = new FileControlBind();

                    filecontrol.SetupEventHandlers();

                    filecontrol.StartAction();  // step into the code and Run run run!

                    NC.App.Opstate.SOH = NCC.OperatingState.Stopped;
                }
                else
                {
                    // NEXT: one of Assay, HV or Discover NC.App.Opstate.Action = NCC.NCCAction.;
                    // DAQ + prompt
                    DAQControlBind daqcontrol = new DAQControlBind((MLMEmulation.IEmulatorDiversion)(new LMProcessor.NullEmulation())); //<- here

                    daqcontrol.SetupTimerCallBacks();
                    daqcontrol.SetupEventHandlers();

                    DAQControlBind.ActivateDetector(NC.App.Opstate.Measurement.Detectors[0]);

                    daqcontrol.StartAction(); // step into the code and Run run run!

                    NC.App.Opstate.SOH = NCC.OperatingState.Stopped;
                }
            }
            catch (Exception e)
            {
                NC.App.Opstate.SOH = NCC.OperatingState.Trouble;
                applog.TraceException(e, true);
                applog.EmitFatalErrorMsg();
            }
            finally
            {
                NC.App.Opstate.SOH = NCC.OperatingState.Stopped;
                NC.App.Config.RetainChanges();
                applog.TraceInformation("==== Exiting " + DateTime.Now.ToString("MMM dd yyy HH:mm:ss.ff K") + " [Cmd] " + NC.App.Name + " . . .");
                NC.App.Loggers.Flush();
            }
        }
Ejemplo n.º 4
0
Archivo: Cmd.cs Proyecto: radtek/INCC6
        static void Main(string[] args)
        {
            new N("INCC6 Console");
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
            NCCConfig.Config c = new NCCConfig.Config();        // gets DB params
            if (!N.App.LoadPersistenceConfig(c.DB))             // loads up DB, sets global AppContext
            {
                return;
            }
            c.AfterDBSetup(N.App.AppContext, args);                                                                    // apply the cmd line
            string[] possiblepaths = NCCFile.FileCtrl.ProcessINCC5IniFile(N.App.Logger(LMLoggers.AppSection.Control)); // iRap: optional use of INCC5 ini file to find results and output paths
            if (possiblepaths.Length > 2)                                                                              // use the iRAP defined input, results and log file paths
            {
                N.App.AppContext.FileInput = possiblepaths[0];
                if (System.IO.Directory.Exists(possiblepaths[1]))
                {
                    N.App.AppContext.ResultsFilePath = possiblepaths[1];
                }
                if (System.IO.Directory.Exists(possiblepaths[2]))
                {
                    N.App.AppContext.LogFilePath = possiblepaths[2];
                }
            }
            // check return bool and exit here on error
            bool initialized = N.App.Initialize(c);

            if (!initialized)
            {
                return;
            }

            if (N.App.Config.Cmd.ShowVersion && !N.App.Config.Cmd.Showcfg)
            {
                N.App.Config.Cmd.ShowVersionOnConsole(N.App.Config, N.App.Config.App.Verbose() == TraceEventType.Verbose);
                return;
            }
            else if (N.App.Config.Cmd.Showhelp)
            {
                N.App.Config.ShowHelp();
                return;
            }
            else if (N.App.Config.Cmd.Showcfg)
            {
                NCCConfig.Config.ShowCfg(N.App.Config, N.App.Config.App.Verbose() == TraceEventType.Verbose);
                return;
            }

            LMLoggers.LognLM applog      = N.App.Logger(LMLoggers.AppSection.App);
            bool             OpenResults = N.App.AppContext.OpenResults;

            try
            {
                applog.TraceInformation("==== Starting " + DateTime.Now.ToString("MMM dd yyy HH:mm:ss.ff K") + " [Cmd] " + N.App.Name + " " + N.App.Config.VersionString);
                applog.TraceInformation("==== DB " + N.App.Pest.DBDescStr);
                // These affect the current acquire state, so they occur here and not earlier in the initial processing sequence
                if (!string.IsNullOrEmpty(c.Cur.Detector) && !c.Cur.Detector.Equals("Default"))                 // command line set the value
                {
                    initialized = Integ.SetNewCurrentDetector(c.Cur.Detector, true);
                }
                if (!initialized)
                {
                    goto end;
                }

                if (!string.IsNullOrEmpty(c.Cur.Material) && !c.Cur.Material.Equals("Pu")) // command line set the value
                {
                    initialized = Integ.SetNewCurrentMaterial(c.Cur.Material, true);
                }
                if (!initialized)
                {
                    goto end;
                }

                if (!string.IsNullOrEmpty(c.Cur.ItemId)) // command line set the item value, use it to override the material and other acquire params
                {
                    initialized = Integ.SetNewCurrentMaterial(c.Cur.Material, true);
                }
                if (!initialized)
                {
                    goto end;
                }

                if (!N.App.AppContext.ReportSectional.Equals(NCCConfig.Config.DefaultReportSectional))                 // command line set the value
                {
                    AcquireParameters acq = null;
                    Detector          det = null;
                    Integ.GetCurrentAcquireDetectorPair(ref acq, ref det);
                    acq.review.Scan(N.App.AppContext.ReportSectional);
                    acq.MeasDateTime = DateTime.Now;
                    N.App.DB.UpdateAcquireParams(acq, det.ListMode);
                    N.App.Logger(LMLoggers.AppSection.Control).TraceEvent(LogLevels.Info, 32444, "The current report sections are now " + N.App.AppContext.ReportSectional);
                }
                if (N.App.Config.App.UsingFileInput || N.App.Opstate.Action == NCC.NCCAction.File)
                {
                    if (N.App.AppContext.AssayFromFiles)
                    {
                        N.App.Opstate.Action = NCC.NCCAction.Assay;
                    }
                    else if (N.App.AppContext.HasFileAction)
                    {
                        N.App.Opstate.Action = NCC.NCCAction.File;
                    }
                }

                if (N.App.Config.Cmd.Query != null)
                {
                    AcquireParameters acq = Integ.GetCurrentAcquireParams();
                    System.Collections.Generic.List <string> ls = acq.ToDBElementList(generate: true).AlignedNameValueList;
                    foreach (string s in ls)
                    {
                        Console.WriteLine(s);
                    }
                    OpenResults = false;
                    if (N.App.Opstate.Action == NCC.NCCAction.Nothing)
                    {
                        return;
                    }
                }


                if (N.App.Config.App.UsingFileInput || N.App.Opstate.Action == NCC.NCCAction.File)
                {
                    BuildMeasurement();
                    if (N.App.AppContext.AssayFromFiles)
                    {
                        N.App.Opstate.Action = NCC.NCCAction.Assay;
                    }
                    else if (N.App.AppContext.HasFileAction)
                    {
                        N.App.Opstate.Action = NCC.NCCAction.File;
                    }

                    // file processing for analysis and more
                    FileControlBind filecontrol = new FileControlBind();
                    filecontrol.SetupEventHandlers();
                    filecontrol.StartAction();                      // step into the code and run
                    N.App.Opstate.SOH = NCC.OperatingState.Stopped;
                }
                else
                {
                    BuildMeasurement();
                    DAQControlBind control = new DAQControlBind();
                    DAQ.DAQControl.ActivateDetector(N.App.Opstate.Measurement.Detector);
                    control.SetupEventHandlers();
                    control.StartAction();
                    N.App.Opstate.SOH = NCC.OperatingState.Stopped;
                }
end:
                ;
            } catch (Exception e)
            {
                N.App.Opstate.SOH = NCC.OperatingState.Trouble;
                applog.TraceException(e, true);
                applog.EmitFatalErrorMsg();
            } finally
            {
                N.App.Opstate.SOH = NCC.OperatingState.Stopped;
                N.App.Config.RetainChanges();
                applog.TraceInformation("==== Exiting " + DateTime.Now.ToString("MMM dd yyy HH:mm:ss.ff K") + " [Cmd] " + N.App.Name + " . . .");
                N.App.Loggers.Flush();
                if (OpenResults)
                {
                    Process.Start(System.IO.Path.Combine(Environment.SystemDirectory, "notepad.exe"), LMLoggers.LognLM.CurrentLogFilePath);
                }
            }
        }