Exemplo n.º 1
0
        public DesignUserControlViewModel(FireworkManager fireworkManager, SoftwareConfiguration configuration)
        {
            _fireworkManager = fireworkManager;
            _fireworkManager.FireworkLoaded += _fireworkManager_FireworkLoaded;

            _configuration = configuration;
        }
Exemplo n.º 2
0
        public MainWindowViewModel()
        {
            //Gets software version
            _softwareVersion = Assembly.GetExecutingAssembly().GetName().Version;

            //Initialize Software configuration
            _configuration = new SoftwareConfiguration();

            //Initialize new firework
            _fireworkManager = new FireworkManager(_configuration);
            _fireworkManager.FireworkLoaded             += FireworkManager_FireworkLoaded;
            _fireworkManager.FireworkSaved              += FireworkManager_FireworkSaved;
            _fireworkManager.FireworkDefinitionModified += FireworkManager_FireworkDefinitionModified;
            _fireworkManager.TransceiverInfoChanged     += FireworkManager_TransceiverInfoChanged;
            _fireworkManager.FireworkStarted            += FireworkManager_FireworkStarted;
            _fireworkManager.FireworkFinished           += FireworkManager_FireworkFinished;
            _fireworkManager.ReceptorTestStarted        += FireworkManager_ReceptorTestStarted;
            _fireworkManager.ReceptorTestFinished       += FireworkManager_ReceptorTestFinished;

            _designUserControlViewModel   = new DesignUserControlViewModel(_fireworkManager, _configuration);
            _testUserControlViewModel     = new TestUserControlViewModel(_fireworkManager, Dispatcher.CurrentDispatcher);
            _fireworkUserControlViewModel = new FireworkUserControlViewModel(_fireworkManager, Dispatcher.CurrentDispatcher);

            //Trasnceiver already plugged?
            _fireworkManager.DiscoverDevice();
        }
Exemplo n.º 3
0
        public ConfigurationWindow(SoftwareConfiguration configuration)
        {
            InitializeComponent();

            _configuration = configuration;

            this.Loaded += ConfigurationWindow_Loaded;
        }
Exemplo n.º 4
0
        public FireworkManagementWindow(FireworkManager fm, SoftwareConfiguration softwareConfiguration)
        {
            InitializeComponent();

            _fireworkManager       = fm;
            _softwareConfiguration = softwareConfiguration;

            this.Loaded += FireworkManagementWindow_Loaded;
        }
Exemplo n.º 5
0
        public DeviceManager(SoftwareConfiguration softwareConfiguration)
        {
            _softwareConfiguration = softwareConfiguration;

            //WMI Query
            WqlEventQuery deviceArrivalQuery = new WqlEventQuery("SELECT * FROM Win32_DeviceChangeEvent WHERE EventType = 2");

            _deviceWatcher = new ManagementEventWatcher(deviceArrivalQuery);

            // Attach an event listener to the device watcher.
            _deviceWatcher.EventArrived += DeviceWatcher_EventArrived;

            // Start monitoring the WMI tree for changes in SerialPort devices.
            _deviceWatcher.Start();
        }
Exemplo n.º 6
0
        public static void Run(CancellationTokenSource cancellationTokenSource, LoggingProvider logger)
        {
            _cancellationTokenSource = cancellationTokenSource ?? throw new ArgumentNullException(nameof(cancellationTokenSource));
            _logger = logger ?? throw new ArgumentNullException(nameof(logger));
            var config = new SoftwareConfiguration(new AppConfigurationValueProvider());

            while (_shouldReloadConfig)
            {
                _shouldReloadConfig = false;
                try
                {
                    if (_scriptManager != null)
                    {
                        _scriptManager.Dispose();
                    }
                    _scriptManager = new ScriptManager(_logger, config);
                }
                catch (Exception e)
                {
                    _logger.Error(e);
                    _cancellationTokenSource.Cancel();
                }

                while (!_cancellationTokenSource.Token.IsCancellationRequested)
                {
                    try
                    {
                        App.notifyIcon.Text = "Trying to connect...";
                        App.notifyIcon.Icon = Software.Properties.Resources.SearchingIcon;
                        TheActualLoop();
                    }
                    catch (Exception e)
                    {
                        _logger.Error(e);
                        System.Threading.Thread.Sleep(1000);
                    }
                    if (_shouldReloadConfig)
                    {
                        break;
                    }
                }
            }
        }
        public EditSoftwareInfoViewModel(IDeviceRelatedRepository repo)
        {
            Repository = repo;

            FillFieldsWithSoftwareConfiguration();

            ApplyChangesCommand = RegisterCommandAction(
                (obj) =>
            {
                var newConfig = new SoftwareConfiguration();

                try
                {
                    InitializeSoftwareConfiguration(newConfig);

                    Repository.UpdateSoftwareConfiguration(newConfig);
                    Repository.SaveChanges();

                    MessageToUser = "******";
                }
                catch (Exception e) { MessageToUser = e.Message; }
            }
                );
        }
Exemplo n.º 8
0
 public FireworkManagementWindow(FireworkManager fm, SoftwareConfiguration softwareConfiguration, Line line) : this(fm, softwareConfiguration)
 {
     _line = line;
 }
Exemplo n.º 9
0
 public FireworkManagementViewModel(FireworkManager fm, SoftwareConfiguration softwareConfiguration, Line line)
 {
     _softwareConfiguration = softwareConfiguration;
     _fireworkManager       = fm;
     _line = line;
 }
 public ConfigurationWindowViewModel(SoftwareConfiguration configuration)
 {
     _configuration = configuration;
 }
Exemplo n.º 11
0
        /// <summary>
        /// Loads the configuration from an xml file
        /// </summary>
        /// <param name="xmlFile">The name of an xml file that stores the configuration information</param>
        public void FromXML(string xmlFile)
        {
            XmlDocument dom = new XmlDocument();

            dom.Load(xmlFile);
            XmlNode xNode = dom.DocumentElement;

            if ((xNode.Name == CONFIGURATION_ELEMENT) && (xNode.HasChildNodes))
            {
                foreach (XmlNode iNode in xNode.ChildNodes)
                {
                    if (iNode.Name == SOFTWARE_ELEMENT)
                    {
                        foreach (XmlAttribute iAttribute in iNode.Attributes)
                        {
                            /*if (iAttribute.Name == VERSION_ATTRIBUTE)
                             *  CurrentWockets._Version = iAttribute.Value;
                             * else*/if (iAttribute.Name == MODE_ATTRIBUTE)
                            {
                                this._SoftwareMode = ((String.Compare(iAttribute.Value, SoftwareConfiguration.DEBUG.ToString(), true) == 0) ? SoftwareConfiguration.DEBUG : SoftwareConfiguration.RELEASE);
                            }
                            else if (iAttribute.Name == MEMORY_MODE_ATTRIBUTE)
                            {
                                this._MemoryMode = ((String.Compare(iAttribute.Value, MemoryConfiguration.NON_SHARED.ToString(), true) == 0) ? MemoryConfiguration.NON_SHARED : MemoryConfiguration.SHARED);
                            }
                        }
                    }
                    else if (iNode.Name == FEATURES_ELEMENT)
                    {
                        foreach (XmlAttribute iAttribute in iNode.Attributes)
                        {
                            if (iAttribute.Name == FFT_INTERPOLATION_POWER_ATTRIBUTE)
                            {
                                this._FFTInterpolationPower = Convert.ToInt32(iAttribute.Value);
                            }
                            else if (iAttribute.Name == FFT_MAX_FREQUENCIES_ATTRIBUTE)
                            {
                                this._FFTMaximumFrequencies = Convert.ToInt32(iAttribute.Value);
                            }
                            else if (iAttribute.Name == SMOOTH_WINDOW_ATTRIBUTE)
                            {
                                this._SmoothWindowCount = Convert.ToInt32(iAttribute.Value);
                            }
                            else if (iAttribute.Name == FEATURE_WINDOW_SIZE_ATTRIBUTE)
                            {
                                this._FeatureWindowSize = Convert.ToInt32(iAttribute.Value);
                            }
                            else if (iAttribute.Name == FEATURE_WINDOW_OVERLAP_ATTRIBUTE)
                            {
                                this._FeatureWindowOverlap = Convert.ToDouble(iAttribute.Value);
                            }
                            else if (iAttribute.Name == ERROR_WINDOW_SIZE_ATTRIBUTE)
                            {
                                this._ErrorWindowSize = Convert.ToInt32(iAttribute.Value);
                            }
                            else if (iAttribute.Name == MAXIMUM_CONSECUTIVE_PACKET_LOSS_ATTRIBUTE)
                            {
                                this._MaximumConsecutivePacketLoss = Convert.ToInt32(iAttribute.Value);
                            }
                            else if (iAttribute.Name == MAXIMUM_NONCONSECUTIVE_PACKET_LOSS_ATTRIBUTE)
                            {
                                this._MaximumNonconsecutivePacketLoss = Convert.ToDouble(iAttribute.Value);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Loads the configuration from an xml file
        /// </summary>
        /// <param name="xmlFile">The name of an xml file that stores the configuration information</param>
        public void FromXML(string xmlFile)
        {
            XmlDocument dom = new XmlDocument();
            dom.Load(xmlFile);
            XmlNode xNode = dom.DocumentElement;

            if ((xNode.Name == CONFIGURATION_ELEMENT) && (xNode.HasChildNodes))
            {
                foreach (XmlNode iNode in xNode.ChildNodes)
                {

                    if (iNode.Name == SOFTWARE_ELEMENT)
                    {
                        foreach (XmlAttribute iAttribute in iNode.Attributes)
                            /*if (iAttribute.Name == VERSION_ATTRIBUTE)
                                CurrentWockets._Version = iAttribute.Value;
                            else*/ if (iAttribute.Name == MODE_ATTRIBUTE)
                                this._SoftwareMode = ((String.Compare(iAttribute.Value, SoftwareConfiguration.DEBUG.ToString(), true) == 0) ? SoftwareConfiguration.DEBUG : SoftwareConfiguration.RELEASE);
                            else if (iAttribute.Name == MEMORY_MODE_ATTRIBUTE)
                                this._MemoryMode = ((String.Compare(iAttribute.Value, MemoryConfiguration.NON_SHARED.ToString(), true) == 0) ? MemoryConfiguration.NON_SHARED : MemoryConfiguration.SHARED);
                    }
                    else if (iNode.Name == FEATURES_ELEMENT)
                    {
                        foreach (XmlAttribute iAttribute in iNode.Attributes)
                            if (iAttribute.Name == FFT_INTERPOLATION_POWER_ATTRIBUTE)
                                this._FFTInterpolationPower = Convert.ToInt32(iAttribute.Value);
                            else if (iAttribute.Name == FFT_MAX_FREQUENCIES_ATTRIBUTE)
                                this._FFTMaximumFrequencies = Convert.ToInt32(iAttribute.Value);
                            else if (iAttribute.Name == SMOOTH_WINDOW_ATTRIBUTE)
                                this._SmoothWindowCount = Convert.ToInt32(iAttribute.Value);
                            else if (iAttribute.Name == FEATURE_WINDOW_SIZE_ATTRIBUTE)
                                this._FeatureWindowSize= Convert.ToInt32(iAttribute.Value);
                            else if (iAttribute.Name == FEATURE_WINDOW_OVERLAP_ATTRIBUTE)
                                this._FeatureWindowOverlap = Convert.ToDouble(iAttribute.Value);
                            else if (iAttribute.Name == ERROR_WINDOW_SIZE_ATTRIBUTE)
                                this._ErrorWindowSize = Convert.ToInt32(iAttribute.Value);
                            else if (iAttribute.Name == MAXIMUM_CONSECUTIVE_PACKET_LOSS_ATTRIBUTE)
                                this._MaximumConsecutivePacketLoss = Convert.ToInt32(iAttribute.Value);
                            else if (iAttribute.Name == MAXIMUM_NONCONSECUTIVE_PACKET_LOSS_ATTRIBUTE)
                                this._MaximumNonconsecutivePacketLoss = Convert.ToDouble(iAttribute.Value);
                    }
                }
            }
        }
Exemplo n.º 13
0
        public ScriptManager(LoggingProvider logger, SoftwareConfiguration configuration)
        {
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }


            for (int i = 0; i < 8; i++)
            {
                channels.Add(new VolumeChannel("XXX", "XXX", logger));
            }


            try
            {
                // TODO: consider using the advice in https://github.com/Microsoft/ClearScript/issues/65 instead of using WeakReferences.

                WeakReference <List <Channel> > weakChannelList = new WeakReference <List <Channel> >(channels);

                _engine.AddHostObject("host", new ExtendedHostFunctions());

                _engine.AddHostObject("AddVolumeChannel", (Func <int, String, String, int>)((int c, String displayName, String exeSuffix) => {
                    List <Channel> localChannels;
                    if (weakChannelList.TryGetTarget(out localChannels))
                    {
                        localChannels[c] = new VolumeChannel(displayName, exeSuffix, logger);
                    }
                    return(0);
                }));

                _engine.AddHostType("ScriptChannelCallback", typeof(ScriptChannelCallback));
                _engine.AddHostObject("AddScriptChannelInternal", (Func <int, ScriptChannelCallback, ScriptChannel>)((int c, ScriptChannelCallback config) => {
                    ScriptChannel nc;
                    ScriptChannel dv = ScriptChannel.ConstructForScript(config, out nc);
                    List <Channel> localChannels;
                    if (weakChannelList.TryGetTarget(out localChannels))
                    {
                        localChannels[c] = nc;
                    }
                    return(dv);
                }));

                _engine.Execute("builtin.js", Software.Properties.Resources.BuiltInScript);

                if (!File.Exists(configuration.ConfigFilePath))
                {
                    File.WriteAllText(configuration.ConfigFilePath, Software.Properties.Resources.DefaultConfigScript);
                }

                _engine.Execute(configuration.ConfigFilePath, File.ReadAllText(configuration.ConfigFilePath));
            }
            catch (ScriptEngineException e)
            {
                MessageBox.Show(e.ErrorDetails, "Error executing config.js", MessageBoxButtons.OK);
                throw e;
            }
        }