Esempio n. 1
0
        /// <summary>
        /// Download and play a program on a Locutus board.
        /// </summary>
        /// <param name="device">The Locutus device to send the program to.</param>
        /// <param name="program">The program to send.</param>
        internal static void DownloadAndPlay(Device device, INTV.Core.Model.Program.ProgramDescription program)
        {
            var rom             = program.GetRom();
            var canPlayOnDevice = rom.CanExecuteOnDevice(device.UniqueId);

            if (!canPlayOnDevice)
            {
                var message = string.Format(Resources.Strings.DownloadAndPlayCommand_IncompatibleRom_Message_Format, program.Name);
                canPlayOnDevice = OSMessageBox.Show(message, Resources.Strings.DownloadAndPlayCommand_IncompatibleRom_Title, OSMessageBoxButton.YesNo) == OSMessageBoxResult.Yes;
            }
            if (canPlayOnDevice)
            {
                device.DownloadAndPlay(rom, program.Name, (m, e) => DownloadAndPlayErrorHandler(m, e, program.Name));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Create a copy of the object.
        /// </summary>
        /// <returns>A copy of this instance.</returns>
        /// <remarks>Note that the underlying ROM is not deep copied.</remarks>
        public ProgramDescription Copy()
        {
            var description = new ProgramDescription(Crc, Rom, ProgramInformation);

            description._name    = _name;
            description._xmlName = new MetadataString()
            {
                Text = _name
            };
            description._shortName    = _shortName;
            description._xmlShortName = new MetadataString()
            {
                Text = _shortName
            };
            description._programFiles = _programFiles.Copy();
            return(description);
        }
        /// <summary>
        /// Gets the ROM to use from a <see cref="ProgramDescription"/> for deployment to a device, e.g. Intellicart, CC3, LTO Flash!, emulator, et. al.
        /// </summary>
        /// <param name="programDescription">A <see cref="ProgramDescription"/> that wraps a specific <see cref="IRom"/>.</param>
        /// <returns>The specific <see cref="IRom"/> to use for deployment.</returns>
        /// <remarks>A specific <see cref="IRom"/> may refer to a file that is not presently accessible, e.g. a ROM on a CD-ROM drive, network volume, or other
        /// non-fixed-disk location. In such a case, if the <paramref name="programDescription"/> supplies alternative location(s), the first suitable alternative
        /// location that can be accessed will be used to return a viable <see cref="IRom"/> that, hopefully, is the equivalent of the original.</remarks>
        public static IRom GetRom(this ProgramDescription programDescription)
        {
            var rom     = programDescription.Rom;
            var usesCfg = !string.IsNullOrEmpty(rom.ConfigPath);

            if (!StreamUtilities.FileExists(rom.RomPath) || (usesCfg && !StreamUtilities.FileExists(rom.ConfigPath)))
            {
                var alternateRomPaths = programDescription.Files.AlternateRomImagePaths.ToList();
                var alternateCfgPaths = programDescription.Files.AlternateRomConfigurationFilePaths.ToList();

                if (usesCfg && (alternateRomPaths.Count != alternateCfgPaths.Count))
                {
                    throw new InvalidOperationException(Resources.Strings.ProgramDescription_MissingAlternateCfgFile);
                }

                var    foundAlternate = false;
                string romPath        = null;
                string cfgPath        = null;
                for (var i = 0; (i < alternateRomPaths.Count) && !foundAlternate; ++i)
                {
                    if (StreamUtilities.FileExists(alternateRomPaths[i]))
                    {
                        romPath = alternateRomPaths[i];
                        if (usesCfg)
                        {
                            if (StreamUtilities.FileExists(alternateCfgPaths[i]))
                            {
                                // This code assumes (but cannot check -- silly PCL has no Path API) that the .cfg and ROM are in the same directory for the same index.
                                cfgPath        = alternateCfgPaths[i];
                                foundAlternate = true;
                            }
                        }
                        else
                        {
                            foundAlternate = true;
                        }
                    }
                }
                if (foundAlternate)
                {
                    rom = new AlternateRom(romPath, cfgPath, rom);
                }
            }
            return(rom);
        }
Esempio n. 4
0
        /// <summary>
        /// Validate the program configuration.
        /// </summary>
        /// <param name="program">The program for which validation is performed.</param>
        /// <param name="peripherals">The peripherals attached to the system, used for compatibility checks.</param>
        /// <param name="connectedPeripheralsHistory">The peripherals that have been attached to the system over time.</param>
        /// <param name="reportMessagesChanged">If <c>true</c>, report whether any new messages should be immediately reported.</param>
        /// <returns>If the program's configuration is valid, return <c>true</c>, otherwise <c>false</c>.</returns>
        public static bool Validate(ProgramDescription program, IEnumerable <IPeripheral> peripherals, IEnumerable <IPeripheral> connectedPeripheralsHistory, bool reportMessagesChanged)
        {
            bool validSettings    = false;
            var  supportFileState = program.Files.ValidateSupportFile(ProgramFileKind.Rom, program.Crc, program, peripherals, connectedPeripheralsHistory, true);

            switch (supportFileState)
            {
            case ProgramSupportFileState.New:
            case ProgramSupportFileState.PresentAndUnchanged:
            case ProgramSupportFileState.PresentButModified:
            case ProgramSupportFileState.RequiredPeripheralAvailable:
                validSettings = true;
                break;

            default:
                break;
            }
            return(validSettings);
        }