Esempio n. 1
0
        /// <summary>
        /// Creates a new instance of SyncEngine and initializes it using the specified settings
        /// </summary>
        /// <param name="settings">Synchronization engine settings to use</param>
        public SyncEngine( SyncSettings settings ) : this()
        {
            var sourceFactory = new Sources.SourceFactory();

            sourceFactory.LogLevel = settings.LogLevel;
            sourceFactory.NoUpdates = settings.NoUpdates;

            _primarySource = sourceFactory.Create( settings.SourceSettings[0] );
            _secondarySource = sourceFactory.Create( settings.SourceSettings[1] );
        }
Esempio n. 2
0
		public void Sync(SyncSettings settings)
		{
			ISyncronizationProvider provider = GetProvider(settings.Action);

			if (!provider.InitializeDirectory(settings.DirectoryPath))
			{
				return;
			}

			CloudStorageAccount cloudStorageAccount;
			if (CloudStorageAccount.TryParse(settings.CloudConnectionString, out cloudStorageAccount))
			{
				CloudBlobClient blobClient = cloudStorageAccount.CreateCloudBlobClient();
				CloudBlobContainer blobContainer = blobClient.GetContainerReference(settings.ContainerName);

				blobContainer.CreateIfNotExist();

				this._log.WriteLine(provider.Description);
				this._log.WriteLine("");

				using (var worker = new CreateWorkTaskRunner(_messageBus, _fileSystem, provider, settings.DirectoryPath, blobContainer))
				{
					worker.Start()
						  .Wait();

					using (QueueTaskRunner queueTaskRunner = worker.GetQueueTaskRunner())
					{
						queueTaskRunner
							.Start()
							.Wait();
					}
				}

				this._log.WriteLine("Done...");
			}
			else
			{
				throw new Exception("Invalid cloud connection string '" + settings.CloudConnectionString + "'.");
			}
		}
Esempio n. 3
0
			public static bool NeedsReboot(SyncSettings x, SyncSettings y)
			{
				return !DeepEquality.DeepEquals(x, y);
			}
        //[WebInvoke(Method = "POST", UriTemplate = "/CalculateDependentItems/")]
        public IDictionary <string, IDictionary <Guid, IEnumerable <Guid> > > CalculateDependentItems(SyncSettings settings)
        {
            var request = new RestRequest(this.GetServiceUrl("/CalculateDependentItems/"), Method.POST);

            request.AddParameter("application/json", SerializeObject(settings), ParameterType.RequestBody);

            return(ExecuteRequest <IDictionary <string, IDictionary <Guid, IEnumerable <Guid> > > >(request));
        }
Esempio n. 5
0
 public Sameboy(CoreComm comm, byte[] rom, Settings settings, SyncSettings syncSettings, bool deterministic)
     : this(rom, comm, false, settings, syncSettings, deterministic)
 {
 }
Esempio n. 6
0
 public static bool NeedsReboot(SyncSettings x, SyncSettings y)
 {
     return(!DeepEquality.DeepEquals(x, y));
 }
Esempio n. 7
0
 public NESSyncSettings GetSyncSettings()
 {
     return(SyncSettings.Clone());
 }
Esempio n. 8
0
        public Saturnus(CoreComm comm, IEnumerable <Disc> disks, bool deterministic, Settings settings,
                        SyncSettings syncSettings)
            : base(comm, new Configuration
        {
            MaxSamples    = 8192,
            DefaultWidth  = 320,
            DefaultHeight = 240,
            MaxWidth      = 1024,
            MaxHeight     = 1024,
            SystemId      = "SAT"
        })
        {
            settings     = settings ?? new Settings();
            syncSettings = syncSettings ?? new SyncSettings();

            _disks       = disks.ToArray();
            _diskReaders = disks.Select(d => new DiscSectorReader(d)
            {
                Policy = _diskPolicy
            }).ToArray();
            if (!CheckDisks(_diskReaders))
            {
                throw new InvalidOperationException("Some disks are not valid");
            }
            InitCallbacks();

            _core = PreInit <LibSaturnus>(new PeRunnerOptions
            {
                Filename            = "ss.wbx",
                SbrkHeapSizeKB      = 128,
                SealedHeapSizeKB    = 4096,         // 512KB of bios, 2MB of kof95/ultraman carts
                InvisibleHeapSizeKB = 8 * 1024,     // 4MB of framebuffer
                MmapHeapSizeKB      = 0,            // not used?
                PlainHeapSizeKB     = 24 * 1024,    // up to 16MB of cart ram
                StartAddress        = LibSaturnus.StartAddress
            });

            SetFirmwareCallbacks();
            SetCdCallbacks();

            if (!_core.Init(_disks.Length, syncSettings.ExpansionCart, syncSettings.Region, syncSettings.RegionAutodetect))
            {
                throw new InvalidOperationException("Core rejected the disks!");
            }
            ClearAllCallbacks();

            _controllerDeck = new SaturnusControllerDeck(new[]
            {
                syncSettings.Port1Multitap,
                syncSettings.Port2Multitap
            }, new[]
            {
                syncSettings.Port1,
                syncSettings.Port2,
                syncSettings.Port3,
                syncSettings.Port4,
                syncSettings.Port5,
                syncSettings.Port6,
                syncSettings.Port7,
                syncSettings.Port8,
                syncSettings.Port9,
                syncSettings.Port10,
                syncSettings.Port11,
                syncSettings.Port12
            }, _core);
            ControllerDefinition      = _controllerDeck.Definition;
            ControllerDefinition.Name = "Saturn Controller";
            ControllerDefinition.BoolButtons.AddRange(new[]
            {
                "Power", "Reset", "Previous Disk", "Next Disk"
            });

            _core.SetRtc((long)syncSettings.InitialTime.Subtract(new DateTime(1970, 1, 1)).TotalSeconds,
                         syncSettings.Language);

            PostInit();
            SetCdCallbacks();
            _core.SetDisk(0, false);
            PutSettings(settings);
            _syncSettings          = syncSettings;
            DeterministicEmulation = deterministic || !_syncSettings.UseRealTime;
        }
Esempio n. 9
0
        private PicoDrive(CoreComm comm, GameInfo game, byte[] rom, Disc cd, bool deterministic, SyncSettings syncSettings)
            : base(comm, new Configuration
        {
            MaxSamples    = 2048,
            DefaultWidth  = 320,
            DefaultHeight = 224,
            MaxWidth      = 320,
            MaxHeight     = 480,
            SystemId      = "GEN"
        })
        {
            var biosg      = comm.CoreFileProvider.GetFirmware("32X", "G", false);
            var biosm      = comm.CoreFileProvider.GetFirmware("32X", "M", false);
            var bioss      = comm.CoreFileProvider.GetFirmware("32X", "S", false);
            var has32xBios = biosg != null && biosm != null && bioss != null;

            if (deterministic && !has32xBios)
            {
                throw new InvalidOperationException("32X BIOS files are required for deterministic mode");
            }
            deterministic |= has32xBios;

            _syncSettings = syncSettings ?? new SyncSettings();

            _cdcallback = CDRead;

            _core = PreInit <LibPicoDrive>(new WaterboxOptions
            {
                Filename                   = "picodrive.wbx",
                SbrkHeapSizeKB             = 64,
                SealedHeapSizeKB           = 18 * 1024,
                InvisibleHeapSizeKB        = 1024,
                MmapHeapSizeKB             = 4096,
                PlainHeapSizeKB            = 64,
                SkipCoreConsistencyCheck   = comm.CorePreferences.HasFlag(CoreComm.CorePreferencesFlags.WaterboxCoreConsistencyCheck),
                SkipMemoryConsistencyCheck = comm.CorePreferences.HasFlag(CoreComm.CorePreferencesFlags.WaterboxMemoryConsistencyCheck),
            }, new Delegate[] { _cdcallback });

            if (has32xBios)
            {
                _exe.AddReadonlyFile(biosg, "32x.g");
                _exe.AddReadonlyFile(biosm, "32x.m");
                _exe.AddReadonlyFile(bioss, "32x.s");
                Console.WriteLine("Using supplied 32x BIOS files");
            }
            if (cd != null)
            {
                _exe.AddReadonlyFile(comm.CoreFileProvider.GetFirmware("GEN", "CD_BIOS_EU", true), "cd.eu");
                _exe.AddReadonlyFile(comm.CoreFileProvider.GetFirmware("GEN", "CD_BIOS_US", true), "cd.us");
                _exe.AddReadonlyFile(comm.CoreFileProvider.GetFirmware("GEN", "CD_BIOS_JP", true), "cd.jp");
                _exe.AddReadonlyFile(gpgx.GPGX.GetCDData(cd), "toc");
                _cd       = cd;
                _cdReader = new DiscSectorReader(_cd);
                _core.SetCDReadCallback(_cdcallback);
                DriveLightEnabled = true;
            }
            else
            {
                _exe.AddReadonlyFile(rom, "romfile.md");
            }

            var regionAutoOrder = (LibPicoDrive.Region)(
                (int)_syncSettings.FirstChoice |
                (int)_syncSettings.SecondChoice << 4 |
                    (int)_syncSettings.ThirdChoice << 8);

            if (!_core.Init(cd != null, game["32X"], regionAutoOrder, _syncSettings.RegionOverride))
            {
                throw new InvalidOperationException("Core rejected the file!");
            }

            if (cd != null)
            {
                _exe.RemoveReadonlyFile("cd.eu");
                _exe.RemoveReadonlyFile("cd.us");
                _exe.RemoveReadonlyFile("cd.jp");
                _exe.RemoveReadonlyFile("toc");
                _core.SetCDReadCallback(null);
            }
            else
            {
                _exe.RemoveReadonlyFile("romfile.md");
            }
            if (has32xBios)
            {
                _exe.RemoveReadonlyFile("32x.g");
                _exe.RemoveReadonlyFile("32x.m");
                _exe.RemoveReadonlyFile("32x.s");
            }

            PostInit();
            ControllerDefinition   = PicoDriveController;
            DeterministicEmulation = deterministic;
            _core.SetCDReadCallback(_cdcallback);

            _isPal           = _core.IsPal();
            VsyncNumerator   = _isPal ? 53203424 : 53693175;
            VsyncDenominator = _isPal ? 3420 * 313 : 3420 * 262;

            Is32XActive = game["32X"];
        }
Esempio n. 10
0
 public PicoDrive(CoreComm comm, GameInfo game, byte[] rom, bool deterministic, SyncSettings syncSettings)
     : this(comm, game, rom, null, deterministic, syncSettings)
 {
 }
Esempio n. 11
0
 public static extern void bizswan_saveramclearhacky(IntPtr core, [In] ref SyncSettings settings);
Esempio n. 12
0
 public static extern bool bizswan_load(IntPtr core, byte[] data, int length, [In] ref SyncSettings settings, ref bool IsRotated);
Esempio n. 13
0
 public static bool NeedsReboot(SyncSettings x, SyncSettings y)
 {
     // the core can handle dynamic plugging and unplugging, but that changes
     // the controllerdefinition, and we're not ready for that
     return(!DeepEquality.DeepEquals(x, y));
 }
Esempio n. 14
0
 public SmsSyncSettings GetSyncSettings() => SyncSettings.Clone();
Esempio n. 15
0
		public bool PutSyncSettings(object o)
		{
			var newsettings = (SyncSettings)o;
			bool ret = SyncSettings.NeedsReboot(newsettings, _SyncSettings);
			_SyncSettings = newsettings;
			return ret;
		}
Esempio n. 16
0
 public A2600SyncSettings GetSyncSettings()
 {
     return(SyncSettings.Clone());
 }
Esempio n. 17
0
 public NeoGeoPort(CoreComm comm, byte[] rom, SyncSettings syncSettings, bool deterministic)
     : this(comm, rom, syncSettings, deterministic, PeRunner.CanonicalStart)
 {
 }
Esempio n. 18
0
		private static bool ParseSettings(string[] args, out SyncSettings settings)
		{
			settings = null;
			var parsedSettings = new SyncSettings();
			bool actionOk = false;
			string actionValue = null;

			var options = new OptionSet();
			options.Add("h|help", "Shows help page", v => ShowHelp(options))
					.Add("c|connectionString=", "Storage account connection string", v => parsedSettings.CloudConnectionString = v)
					.Add("b|blobContainer=", "Azure blob container name", v => parsedSettings.ContainerName = v)
					.Add("d|directory=", "Absolute path to directory to synchronize", v => parsedSettings.DirectoryPath = v)
					.Add("a|action=", "Action to perform", v =>
						{
							actionValue = v;
							SyncAction action;
							if (Enum.TryParse<SyncAction>(v, true, out action))
							{
								parsedSettings.Action = action;
								actionOk = true;
							}
						});

			try
			{
				options.Parse(args);
			}
			catch (OptionException e)
			{
				System.Console.WriteLine(e.Message);
				ShowTryMessage();
				System.Console.ReadKey();
				return false;
			}

			bool hasError = false;

			if (string.IsNullOrEmpty(parsedSettings.CloudConnectionString))
			{
				System.Console.WriteLine("Missing argument 'c|connectionString'.");
				hasError = true;
			}

			if (string.IsNullOrEmpty(parsedSettings.ContainerName))
			{
				System.Console.WriteLine("Missing argument 'b|blobContainer'.");
				hasError = true;
			}

			if (string.IsNullOrEmpty(parsedSettings.DirectoryPath))
			{
				System.Console.WriteLine("Missing argument 'd|directory'.");
				hasError = true;
			}

			if (!actionOk)
			{
				System.Console.WriteLine("Invalid action '" + actionValue + "'.");
				System.Console.WriteLine("Valid values are [" + Enum.GetNames(typeof(SyncAction)).ToSeparatedString(n => n, "|") + "].");
				hasError = true;
			}

			if (hasError)
			{
				ShowTryMessage();
				System.Console.ReadKey();
				return false;
			}

			settings = parsedSettings;

			return true;
		}
 public IntvSyncSettings GetSyncSettings()
 {
     return(SyncSettings.Clone());
 }