コード例 #1
0
        public void Main(string argument)
        {
            //First ensure the system is able to process commands
            //-if necessary, perform first time setup
            //-if necessary or requested, initialise the system
            if (!status.initialised || argument == command_Initialise)
            {
                //if we cannot initialise, end here
                if (!Initialise())
                {
                    return;
                }
            }
            if (argument == command_Initialise)
            {
                Echo("resetting.");
                status.Initialise();
            }
            else if (!Validate())
            {
                //if saved state is not valid, try re-initialising
                //if we cannot initialise, end here
                if (!Initialise())
                {
                    return;
                }
            }

            //Read any control commands
            busCommand.BeginRead();
            ReadCommands();
            busCommand.EndRead();

            //Perform main processing
            Update();

            //Save status back if required
            if (status.modified)
            {
                Save();
                status.modified = false;
            }
        }