Beispiel #1
0
        private void bLoadConfig_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            if (this.engine.Parameters.SolutionPath != "")
            {
                dialog.InitialDirectory = this.engine.Parameters.SolutionPath;
            }
            dialog.Filter = "Файл параметров отладчика|*.pdb";
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    DebuggerParameters dp = DebuggerParameters.FromFile(dialog.FileName);
                    if (engine != null && engine.EngineStatus == DebuggerEngineStatus.Started)
                    {
                        dp.ComConection = this.engine.Parameters.ComConection;
                        if (!this.engine.Parameters.ComConection)
                        {
                            dp.PortIP            = this.engine.Parameters.PortIP;
                            dp.PortNumber        = this.engine.Parameters.PortNumber;
                            dp.InterfaceProtocol = this.engine.Parameters.InterfaceProtocol;
                        }
                    }
                    this.engine.Parameters = dp;
                }
                catch (Exception ex)
                {
                    Utils.ErrorMessage(ex.Message);
                    return;
                }
                this.UpdateControlerParameters();
                this.RaiseDebuggerParametersUpdated();
            }
        }
Beispiel #2
0
        /// <summary>
        /// BRE debugger
        /// </summary>
        /// <param name="sources"></param>
        public BreDebugger(DebuggerParameters parms) : base(parms.WorkingDirectory)
        {
            Console.WriteLine("Starting debugger...");
            DebugApplicationContext.Start(parms);
            ApplicationServiceContext.Current = ApplicationContext.Current;
            ApplicationContext.Current.AddServiceProvider(typeof(FileSystemResolver));
            ApplicationContext.Current.AddServiceProvider(typeof(ServiceManager));
            Tracer.AddWriter(new ConsoleTraceWriter(EventLevel.LogAlways, "dbg"), EventLevel.LogAlways);

            if (!String.IsNullOrEmpty(parms.WorkingDirectory))
            {
                ApplicationContext.Current.GetService <FileSystemResolver>().RootDirectory = parms.WorkingDirectory;
            }
            var rootPath = ApplicationContext.Current.GetService <FileSystemResolver>().RootDirectory;

            // Load debug targets
            Console.WriteLine("Loading debuggees...");
            if (parms.Sources != null)
            {
                foreach (var rf in parms.Sources)
                {
                    var f = rf.Replace("~", rootPath);
                    if (!File.Exists(f))
                    {
                        Console.Error.WriteLine("Can't find file {0}", f);
                    }
                    else
                    {
                        this.Execute(f);
                    }
                }
            }
            JavascriptBusinessRulesEngine.SetDebugMode(true);
            JavascriptBusinessRulesEngine.Current.Engine.Step += JreStep;
        }
Beispiel #3
0
        /// <summary>
        /// Запись в массивы значений из указанного класса
        /// </summary>
        /// <param name="curentEngine"></param>
        private void LoadValues(DebuggerParameters curentEngine)
        {
            //сохранение значений датчиков
            adc = new List <DebuggerParameters.AnalogSensorDescription>();
            din = new List <DebuggerParameters.DigitalSensorDescription>();

            foreach (Kontel.Relkon.DebuggerParameters.AnalogSensorDescription asc in curentEngine.ADCSensors)
            {
                Kontel.Relkon.DebuggerParameters.AnalogSensorDescription asd = new Kontel.Relkon.DebuggerParameters.AnalogSensorDescription();
                asd.Address        = asc.Address;
                asd.Caption        = asc.Caption;
                asd.DisplayOneByte = asc.DisplayOneByte;
                asd.HasSign        = asc.HasSign;
                asd.MemoryType     = asc.MemoryType;
                asd.Name           = asc.Name;
                asd.Size           = asc.Size;
                asd.Type           = asc.Type;
                //asd.Value = asc.Value;
                if (asc.Value != null)
                {
                    asd.Value = new byte[asc.Value.Length];
                    Array.Copy(asc.Value, asd.Value, asc.Value.Length);
                }
                else
                {
                    asd.Value = new byte[asc.Size];
                }
                adc.Add(asd);
            }

            foreach (Kontel.Relkon.DebuggerParameters.DigitalSensorDescription asc in curentEngine.DINSensors)
            {
                Kontel.Relkon.DebuggerParameters.DigitalSensorDescription asd = new Kontel.Relkon.DebuggerParameters.DigitalSensorDescription();
                asd.Address    = asc.Address;
                asd.HasSign    = asc.HasSign;
                asd.MemoryType = asc.MemoryType;
                asd.Name       = asc.Name;
                asd.Size       = asc.Size;
                asd.Type       = asc.Type;
                asd.Labels     = asc.Labels;
                //asd.Value = asc.Value;
                if (asc.Value != null)
                {
                    asd.Value = new byte[asc.Value.Length];
                    Array.Copy(asc.Value, asd.Value, asc.Value.Length);
                }
                else
                {
                    asd.Value = new byte[asc.Size];
                }
                asd.BitNumber = asc.BitNumber;
                din.Add(asd);
            }
        }
 /// <summary>
 /// Creates a new debug configuration manager with the specified parameters
 /// </summary>
 public DebugConfigurationManager(DebuggerParameters parms)
 {
     // Get parameters from args
     if (!String.IsNullOrEmpty(parms.ConfigurationFile))
     {
         this.m_configPath = parms.ConfigurationFile;
     }
     if (!String.IsNullOrEmpty(parms.DatabaseFile))
     {
         this.m_dataPath = parms.DatabaseFile;
     }
 }
Beispiel #5
0
        /// <summary>
        /// BRE debugger
        /// </summary>
        /// <param name="sources"></param>
        public ProtoDebugger(DebuggerParameters parms) : base(parms.WorkingDirectory)
        {
            Console.WriteLine("Starting debugger...");

            DebugApplicationContext.Start(parms);
            ApplicationServiceContext.Current = ApplicationContext.Current;
            try
            {
                ApplicationContext.Current.RemoveServiceProvider(typeof(IClinicalProtocolRepositoryService));
            }
            catch { }

            ApplicationContext.Current.AddServiceProvider(typeof(FileSystemResolver));
            ApplicationContext.Current.AddServiceProvider(typeof(ServiceManager));
            ApplicationContext.Current.AddServiceProvider(typeof(DebugProtocolRepository));
            Tracer.AddWriter(new ConsoleTraceWriter(EventLevel.LogAlways, "dbg"), EventLevel.LogAlways);

            if (!String.IsNullOrEmpty(parms.WorkingDirectory))
            {
                ApplicationContext.Current.GetService <FileSystemResolver>().RootDirectory = parms.WorkingDirectory;
            }
            var rootPath = ApplicationContext.Current.GetService <FileSystemResolver>().RootDirectory;

            // Load debug targets
            Console.WriteLine("Loading debuggees...");
            if (parms.Sources != null)
            {
                foreach (var rf in parms.Sources)
                {
                    var f = rf.Replace("~", rootPath);
                    if (!File.Exists(f))
                    {
                        Console.Error.WriteLine("Can't find file {0}", f);
                    }
                    else
                    {
                        this.Add(f);
                    }
                }
            }
        }
Beispiel #6
0
        /// <summary>
        /// BRE debugger
        /// </summary>
        /// <param name="sources"></param>
        public BreDebugger(DebuggerParameters parms) : base(parms.WorkingDirectory)
        {
            this.m_parms = parms;
            Console.WriteLine("Starting debugger...");
            DebugApplicationContext.Start(parms);
            ApplicationServiceContext.Current = ApplicationContext.Current;
            ApplicationServiceContext.Current.GetService <IServiceManager>().AddServiceProvider(typeof(FileSystemResolver));
            Tracer.AddWriter(new ConsoleTraceWriter(EventLevel.LogAlways, "dbg", null), EventLevel.LogAlways);

            if (!String.IsNullOrEmpty(parms.WorkingDirectory))
            {
                ApplicationContext.Current.GetService <FileSystemResolver>().RootDirectory = parms.WorkingDirectory;
            }
            var rootPath = ApplicationContext.Current.GetService <FileSystemResolver>().RootDirectory;

            // Load debug targets
            Console.WriteLine("Loading debuggees...");

            JavascriptExecutorPool.Current.ExecuteGlobal(o => o.Engine.Step += JreStep);
            JavascriptExecutorPool.Current.ExecuteGlobal(j => j.AddExposedObject("SanteDBDcg", new DisconnectedGatewayJni()));

            if (parms.Sources != null)
            {
                foreach (var rf in parms.Sources)
                {
                    var f = rf.Replace("~", rootPath);
                    if (!File.Exists(f))
                    {
                        Console.Error.WriteLine("Can't find file {0}", f);
                    }
                    else
                    {
                        this.Execute(f);
                    }
                }
            }
        }
		public void Update(DebuggerParameters parameters) {
			Update(parameters.Time, parameters.Exception, parameters.StackTrace, parameters.Message);
		}
        /// <summary>
        /// Start the application context
        /// </summary>
        public static bool Start(DebuggerParameters consoleParms)
        {
            var retVal = new DebugApplicationContext();

            retVal.m_configurationManager = new DebugConfigurationManager(consoleParms);

            try
            {
                // Set master application context
                ApplicationContext.Current = retVal;

                retVal.ConfigurationManager.Load();
                retVal.m_tracer = Tracer.GetTracer(typeof(DebugApplicationContext), retVal.ConfigurationManager.Configuration);

                var appService = retVal.GetService <IAppletManagerService>();

                retVal.SetProgress("Loading configuration", 0.2f);

                if (consoleParms.References != null)
                {
                    // Load references
                    foreach (var appletInfo in consoleParms.References)// Directory.GetFiles(this.m_configuration.GetSection<AppletConfigurationSection>().AppletDirectory)) {
                    {
                        try
                        {
                            retVal.m_tracer.TraceInfo("Loading applet {0}", appletInfo);
                            String appletPath = appletInfo;
                            if (!Path.IsPathRooted(appletInfo))
                            {
                                appletPath = Path.Combine(Environment.CurrentDirectory, appletPath);
                            }
                            using (var fs = File.OpenRead(appletPath))
                            {
                                var package = AppletPackage.Load(fs);
                                retVal.m_tracer.TraceInfo("Loading {0} v{1}", package.Meta.Id, package.Meta.Version);

                                // Is this applet in the allowed applets
                                appService.LoadApplet(package.Unpack());
                            }
                        }
                        catch (Exception e)
                        {
                            retVal.m_tracer.TraceError("Loading applet {0} failed: {1}", appletInfo, e.ToString());
                            throw;
                        }
                    }
                }

                // Ensure data migration exists
                try
                {
                    // If the DB File doesn't exist we have to clear the migrations
                    if (!File.Exists(retVal.Configuration.GetConnectionString(retVal.Configuration.GetSection <DataConfigurationSection>().MainDataSourceConnectionStringName).Value))
                    {
                        retVal.m_tracer.TraceWarning("Can't find the OpenIZ database, will re-install all migrations");
                        retVal.Configuration.GetSection <DataConfigurationSection>().MigrationLog.Entry.Clear();
                    }
                    retVal.SetProgress("Migrating databases", 0.6f);

                    DataMigrator migrator = new DataMigrator();
                    migrator.Ensure();

                    // Set the entity source
                    EntitySource.Current = new EntitySource(retVal.GetService <IEntitySourceProvider>());

                    // Prepare clinical protocols
                    //retVal.GetService<ICarePlanService>().Repository = retVal.GetService<IClinicalProtocolRepositoryService>();
                    ApplicationServiceContext.Current  = ApplicationContext.Current;
                    ApplicationServiceContext.HostType = OpenIZHostType.OtherClient;
                }
                catch (Exception e)
                {
                    retVal.m_tracer.TraceError(e.ToString());
                    throw;
                }
                finally
                {
                    retVal.ConfigurationManager.Save();
                }

                // Set the tracer writers for the PCL goodness!
                foreach (var itm in retVal.Configuration.GetSection <DiagnosticsConfigurationSection>().TraceWriter)
                {
                    OpenIZ.Core.Diagnostics.Tracer.AddWriter(itm.TraceWriter, itm.Filter);
                }
                // Start daemons
                retVal.GetService <IThreadPoolService>().QueueUserWorkItem(o => { retVal.Start(); });

                //retVal.Start();
            }
            catch (Exception e)
            {
                retVal.m_tracer?.TraceError(e.ToString());
                throw;
            }
            return(true);
        }
Beispiel #9
0
 public void Update(DebuggerParameters parameters)
 {
     Update(parameters.Time, parameters.Exception, parameters.StackTrace, parameters.Message);
 }
 /// <summary>
 /// Creates a new debug application context
 /// </summary>
 public DebugApplicationContext(DebuggerParameters parms) : base(new DebugConfigurationManager(parms))
 {
 }