Exemplo n.º 1
0
        public DeviceSettingsDialog()
        {
            m_synchronization_context = SynchronizationContext.Current;

            // copy current settings
            m_current_settings = new SettingsFileBase();
            m_current_settings.CopySettingsFrom(FrameworkSettingsFile.Default);

            m_dialog_settings = m_current_settings.GetSettings <DeviceSettinsgDialogSettings>();

            m_device_settings = new ParserDeviceSettings();
            m_device_settings.SetValueChangedCallback(OnDeviceSettingValueChanged);

            InitializeComponent();
            DataContext = this;

            gFileTransferIndicator.Visibility      = Visibility.Visible;
            gFileTransferErrorIndicator.Visibility = Visibility.Hidden;
            gSettings.Visibility = Visibility.Hidden;

            FormManager.RealtimeObjectProviderAdd(this);

            // start file download
            m_current_file_index = 0;
            OnPropertyChanged("TotalFileCount");
            OnPropertyChanged("CurrentFileIndex");

            CommunicationManager.Default.FileTransfer.FileDownloadStart(m_files_info[m_current_file_index].Name, OnFileReadOperationFinished);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            m_file_names = new ParserDeviceSettings.GeneratedFileNames();

            // display title
            Console.Write(ParserDeviceSettingsStringConstants.ProgramTitle);

            // process command line
            CommandLineParser command_line = new CommandLineParser();

            if (!command_line.ProcessCommandLine(args))
            {
                Console.Write(command_line.ErrorMessage);
                Console.ReadKey();
                return;
            }

            // display help text
            if (command_line.IsHelpRequested() || command_line.Parameters.Length == 0)
            {
                Console.WriteLine(ParserDeviceSettingsStringConstants.Usage);

                return;
            }

            // use command line switches
            if (!ProcessCommandLineSwitches(command_line))
            {
                return;
            }

            // process command line file names
            ParserDeviceSettings parser = new ParserDeviceSettings();

            parser.ParseXMLFile("/Settings/*", m_file_names.ConfigFileName);

            if (string.IsNullOrEmpty(parser.ErrorMessage))
            {
                // generate file names
                string config_file_name_without_extension;
                config_file_name_without_extension = Path.Combine(Path.GetDirectoryName(Path.GetFullPath(m_file_names.ConfigFileName)), Path.GetFileNameWithoutExtension(m_file_names.ConfigFileName));

                if (m_file_names.HeaderFileName == null)
                {
                    m_file_names.HeaderFileName = config_file_name_without_extension + ".h";
                }

                if (m_file_names.DefaultDataFileName == null)
                {
                    m_file_names.DefaultDataFileName = config_file_name_without_extension + "_default.inl";
                }

                if (m_file_names.XmlDataFileName == null)
                {
                    m_file_names.XmlDataFileName = config_file_name_without_extension + "_xml.inl";
                }

                if (m_file_names.ValueInfoFileName == null)
                {
                    m_file_names.ValueInfoFileName = config_file_name_without_extension + "_info.inl";
                }
            }

            // Generate output files
            if (string.IsNullOrEmpty(parser.ErrorMessage))
            {
                // update value offsets
                parser.GenerateBinaryValueOffset();

                // files
                parser.CreateFiles(m_file_names, m_use_offsets);
            }


            if (!string.IsNullOrEmpty(parser.ErrorMessage))
            {
                Console.WriteLine(parser.ErrorMessage + " at line:" + parser.ErrorLine);
                Console.ReadKey();
                return;
            }
        }