Exemplo n.º 1
0
        public bool LoadFromFile(string taskDataFile)
        {
            if (!LoadXmlFile(taskDataFile))
            {
                return(false);
            }

            if (!VerifyIsoVersion())
            {
                return(false);
            }

            LinkedIds    = LinkListLoader.Load(this);
            Units        = UnitLoader.Load(this);
            Customers    = CustomerLoader.Load(this);
            Farms        = FarmLoader.Load(this);
            Crops        = CropLoader.Load(this);
            Fields       = FieldLoader.Load(this);
            Products     = ProductLoader.Load(this);
            ProductMixes = ProductMixLoader.Load(this);
            Workers      = WorkerLoader.Load(this);
            Comments     = CommentLoader.Load(this);
            Tasks        = TaskLoader.Load(this);

            RasterPrescriptions = PrescriptionLoader.Load(this);
            Machines            = DeviceLoader.Load(this);

            return(true);
        }
Exemplo n.º 2
0
 public void ConfigureServices(IServiceCollection services)
 {
     foreach (var device in DeviceLoader.Load())
     {
         device.ConfigureServices(services);
     }
     services.AddScoped <ValidationFilterAttribute>();
     services.AddServiceLayer();
     services.AddPersistenceInfrastructure(_config);
     services.AddUnitOfWork();
     services.AddCqrs();
     services.AddControllersWithViews().AddRazorRuntimeCompilation();
     services.ConfigureMqttService();
     services.AddSignalR();
     services.AddHostedMqttClient(_config);
 }
Exemplo n.º 3
0
        private void LoadDevice(string fileName)
        {
            try
            {
                var loader = DeviceLoader.Load(fileName);
                deviceId          = loader.Factory;
                logDirectory      = Settings.GetDeviceDefaultLoggingDirectory(deviceId);
                logControl.Paused = false;
                Log.Status("Loaded assembly: {0}", loader.FileName);
                Log.Status("Device: {0} [Creation time: {1}]", loader.Factory, loader.CreationTime);
                Log.Status("Logging directory: {0}", logDirectory);
                Log.Status("Log settings [Auto save: {0}, Confirm deletion: {1}]", loader.AutoSaveLog, loader.ConfirmLogDeletion);

                autoSaveLogToolStripMenuItem.Checked = logControl.AutoSave = loader.AutoSaveLog;
                logControl.InitializeLogFile(logDirectory);
                confirmLogDeletion = loader.ConfirmLogDeletion;

                device = loader.Create();

                device.Profiler.Enabled = loader.Profiling;
                profilerWindow.SetDevice(device);
                commTester.Trials    = loader.Trials;
                commTester.TestDelay = loader.TestDelay;
                commTester.Master    = device.Central;

                Log.Status("Profiler: {0} (Test Trials: {1}, Test Delay: {2})",
                           loader.Profiling ? "ENABLED" : "DISABLED",
                           commTester.Trials,
                           commTester.TestDelay);

                if (device.AvailableAddress is object)
                {
                    foreach (var address in device.AvailableAddress)
                    {
                        var menuItem = new ToolStripMenuItem(address.Name)
                        {
                            Tag = address
                        };
                        menuItem.Click += (sender, e) =>
                        {
                            if (sender is ToolStripMenuItem item)
                            {
                                if (item.Tag is DeviceAddress current)
                                {
                                    device.CurrentAddress = current;
                                    Log.Status($"CURRENT ADDRESS: {current.Name} [ {current.Value} ]");
                                    UpdateAddressMenu();
                                }
                            }
                        };

                        addressMenu.DropDownItems.Add(menuItem);
                    }
                    ;

                    device.CurrentAddress = device.AvailableAddress[0];
                    UpdateAddressMenu();
                }

                UpdateProfiling();
                InitializeFunctions();
                UpdatePorts();
                UpdateAppStates(AppState.APP_STATE_INITIALIZED);
            }
            catch (Exception e)
            {
                UpdateAppStates(AppState.APP_STATE_UNINITIALIZED);
                Log.Error(e.Message);
                MessageBox.Show(e.Message, "Error loading device");
            }
        }