Example #1
0
        public MainServer()
        {
            _cbList = new BoardList();

            _logger.UseMemLog      = true;
            _logger.LogMethodNames = true;
            _logger.OpenLogFile(Settings.ApplicationPath + Defs.LOG_FILE_NAME);

            _logger.WriteLine("");
            _logger.WriteLine("****************************************************************************************");
            _logger.WriteLine("*                                                                                      *");
            _logger.WriteLine("*                                 Application started                                  *");
            _logger.WriteLine("*                                    Board Control                                     *");
            _logger.WriteLine("*                                                                                      *");
            _logger.WriteLine("****************************************************************************************");
            _logger.WriteLine("");
            _logger.WriteLine("Application Name: " + AppHelper.GetApplicationName() + ".exe ver. " + AppHelper.GetApplicationVersionInfo().ProductVersion);
            _logger.WriteLine("Run Path: " + AppHelper.GetApplicationPath());
            _logger.WriteLine("");


            _iniFile = new INIFile(AppHelper.GetApplicationPath() + Defs.INI_FILE_NAME, false, true);
        }
Example #2
0
        }                             // prevent to call default constructor

        public ControlBitParam(string configFile)
        {
            _controlBitArray = new ControlBit[NUMBER_OF_CONTROL_BITS];

            using (INIFile iniFile = new INIFile(configFile, false, true))
            {
                // we need to load all related info from ini file
                for (int bitNumber = 0; bitNumber < NUMBER_OF_CONTROL_BITS; bitNumber++)
                {
                    _controlBitArray[bitNumber] = new ControlBit();

                    for (int verNumber = 0; verNumber < Settings.BoardVersions.Length; verNumber++)
                    {
                        string sectionNumber = PARAMINFO_INI_SECTION_CONTROL_BITS_PREFIX + (verNumber + 1);
                        string bitPrefix     = "Bit" + bitNumber + "_";

                        int bitPosition = iniFile.GetValue(sectionNumber, bitPrefix + PARAMINFO_INI_KEY_BIT_POSITION, INI_SECTION_NOT_AVAILABLE_VERIFIER);

                        if (bitPosition == INI_SECTION_NOT_AVAILABLE_VERIFIER)
                        {
                            _logger.WriteLine(LogLevel.Error, $"Can't fill Control RParam Info - Section [{sectionNumber}] is not available");
                            continue;
                        }

                        string   description  = iniFile.GetValue(sectionNumber, bitPrefix + PARAMINFO_INI_KEY_DESCRIPTION, "INI Loading Error");
                        int      bitsUsed     = iniFile.GetValue(sectionNumber, bitPrefix + PARAMINFO_INI_KEY_BITS_USED, 1);
                        bool     visible      = iniFile.GetValue(sectionNumber, bitPrefix + PARAMINFO_INI_KEY_VISIBLE, false);
                        int      defaultValue = iniFile.GetValue(sectionNumber, bitPrefix + PARAMINFO_INI_KEY_DEFAULT_VALUE, 0);
                        string[] valuesInfo   = iniFile.GetValue(sectionNumber, bitPrefix + PARAMINFO_INI_KEY_VALUES_INFO, "INI Loading Error").Split(',');

                        ControlBitInfo controlBitInfo = new ControlBitInfo(description, bitPosition, bitsUsed, visible, defaultValue, valuesInfo);

                        _controlBitArray[bitNumber].SetControlBitInfo(verNumber, controlBitInfo);
                    }
                }
            }
        }
Example #3
0
        /// <summary>
        /// Load App and Counter Board settings
        /// </summary>
        private void LoadSettings()
        {
            // Let's load all available Board Versions

            List <string> boardVersions = new List <string>();

            using (INIFile iniFile = new INIFile(Settings.ApplicationPath + Defs.PARAMINFO_INI_FILE_NAME, false, true))
            {
                for (byte loop = 0; loop < Defs.MAX_BOARD_VERSIONS; loop++)
                {
                    string verName = iniFile.GetValue(Defs.PARAMINFO_INI_SECTION_PARAM_VERSIONS, Defs.PARAMINFO_INI_KEY_PARAM_VERSIONS_PREFIX + (loop + 1), "");
                    if (verName != "")
                    {
                        boardVersions.Add(verName);
                        _logger.WriteLine(LogLevel.Info, $"Added board ver.{loop + 1} [{verName}]");
                    }
                }
            }

            Settings.BoardVersions = boardVersions.ToArray();

            // Let's try to load all available counter board entries

            int boardsLoaded = 0;

            for (byte loop = 0; loop < Defs.MAX_BOARDS; loop++)
            {
                string sectionNumber = Defs.INI_SECT_CB_PREFIX_NAME + loop.ToString();
                bool   isAvailable   = _iniFile.GetValue(sectionNumber, Defs.INI_KEY_CB_IS_AVAILABLE_FOR_REUSE, true);

                if (!isAvailable) // ini entry exists and not available for reuse
                {
                    boardsLoaded++;

                    Board board = new Board
                    {
                        IniPosition        = loop,
                        IsAvailableToReuse = false,
                        IsEnabled          = _iniFile.GetValue(sectionNumber, Defs.INI_KEY_CB_IS_ENABLED, true),
                        Name          = _iniFile.GetValue(sectionNumber, Defs.INI_KEY_CB_NAME, "Board #" + boardsLoaded.ToString()),
                        ComPortNumber = _iniFile.GetValue(sectionNumber, Defs.INI_KEY_CB_COMPORT_NUMBER, 0)
                    };

                    _logger.WriteLine(LogLevel.Info, $"Added info about board [{boardsLoaded}] - " + board.Name);

                    int boardVersion = _iniFile.GetValue(sectionNumber, Defs.INI_KEY_CB_FW_VERSION, 0);

                    if (boardVersion >= 0 && boardVersion < Settings.BoardVersions.Length)
                    {
                        board.BoardVersion = boardVersion;
                    }
                    else
                    {
                        _logger.WriteLine(LogLevel.Error, $"Board protocol version [{boardVersion}] is not valid; Using default version [{Defs.CB_DEFAULT_BOARD_VERSION}]");
                        board.BoardVersion = Defs.CB_DEFAULT_BOARD_VERSION;
                    }

                    _cbList.Add(board);
                }
            }

            _logger.WriteLine("Settings loaded");
        }