Ejemplo n.º 1
0
        private void ConfigChangeHandler(Config newConfig)
        {
            this.Invoke((MethodInvoker)(() =>
            {
                var currectConfig = configManager.CurrentConfig;
                if (currectConfig.Port != newConfig.Port)
                {
                    btnRunProgram.Enabled = false;
                    groupBoxOptions.Enabled = false;
                    SetStatusText(localizator.GetString("Status_Reconnecting", "Reconnecting"));
                    hardwareLibrary.Dispose();
                    hardwareLibrary = new HardwareLibrary(MessageManager.MessageHandler, ErrorHandler, EventHandler, newConfig.LogEnable);

                    Connect();
                }
                else if (currectConfig.LogEnable != newConfig.LogEnable)
                {
                    hardwareLibrary.LogEnable = newConfig.LogEnable;
                }

                if (currectConfig.Locale != newConfig.Locale)
                {
                    Main_Load(null, null);
                }
            }));

            configManager.UpdateConfig(newConfig);
        }
Ejemplo n.º 2
0
        public Main()
        {
            InitializeComponent();

            cancelTokenSource = new CancellationTokenSource();
            token             = cancelTokenSource.Token;

            localizator = new Localizator(configManager.CurrentConfig.Locale);

            hardwareLibrary = new HardwareLibrary(MessageManager.MessageHandler, ErrorHandler, EventHandler, configManager.CurrentConfig.LogEnable);
        }
Ejemplo n.º 3
0
        public Result PostHardwareLibrary([FromBody] HardwareLibrary hardwareLibrary)
        {
            hardwareLibrary.CreateUserId   = Request.GetIdentityInformation();
            hardwareLibrary.MarkedDateTime = DateTime.Now;
            ServerConfig.DeviceDb.Execute(
                "INSERT INTO hardware_library (`CreateUserId`, `MarkedDateTime`, `MarkedDelete`, `ModifyId`, `HardwareName`, `InputNumber`, `OutputNumber`, " +
                "`DacNumber`, `AdcNumber`, `AxisNumber`, `ComNumber`, `Description`) VALUES (@CreateUserId, @MarkedDateTime, @MarkedDelete, @ModifyId, @HardwareName, " +
                "@InputNumber, @OutputNumber, @DacNumber, @AdcNumber, @AxisNumber, @ComNumber, @Description);",
                hardwareLibrary);

            return(Result.GenError <Result>(Error.Success));
        }
Ejemplo n.º 4
0
        public Result PutHardwareLibrary([FromRoute] int id, [FromBody] HardwareLibrary hardwareLibrary)
        {
            var cnt =
                ServerConfig.DeviceDb.Query <int>("SELECT * FROM `hardware_library` WHERE Id = @id AND `MarkedDelete` = 0;", new { id }).FirstOrDefault();

            if (cnt == 0)
            {
                return(Result.GenError <Result>(Error.HardwareLibraryNotExist));
            }

            hardwareLibrary.Id             = id;
            hardwareLibrary.CreateUserId   = Request.GetIdentityInformation();
            hardwareLibrary.MarkedDateTime = DateTime.Now;
            ServerConfig.DeviceDb.Execute(
                "UPDATE hardware_library SET `CreateUserId` = @CreateUserId, `MarkedDateTime` = @MarkedDateTime, `MarkedDelete` = @MarkedDelete, " +
                "`ModifyId` = @ModifyId, `HardwareName` = @HardwareName, `InputNumber` = @InputNumber, `OutputNumber` = @OutputNumber, `DacNumber` = @DacNumber, " +
                "`AdcNumber` = @AdcNumber, `AxisNumber` = @AxisNumber, `ComNumber` = @ComNumber, `Description` = @Description WHERE `Id` = @Id;", hardwareLibrary);

            return(Result.GenError <Result>(Error.Success));
        }
Ejemplo n.º 5
0
 public FirmwareFrm(HardwareLibrary hardwareLibrary)
 {
     InitializeComponent();
     this.hardwareLibrary = hardwareLibrary;
 }