public void Load(ReadFilePath path) { using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read)) { var deserializationResult = serializer.TryDeserialize <string>(stream, out var version); if (deserializationResult != DeserializationResult.OK) { throw new RecoverableException($"There was an error when deserializing the emulation: {deserializationResult}\n Underlying exception: {serializer.LastException.Message}\n{serializer.LastException.StackTrace}"); } deserializationResult = serializer.TryDeserialize <Emulation>(stream, out var emulation); if (deserializationResult != DeserializationResult.OK) { throw new RecoverableException($"There was an error when deserializing the emulation: {deserializationResult}\n Underlying exception: {serializer.LastException.Message}\n{serializer.LastException.StackTrace}"); } CurrentEmulation = emulation; CurrentEmulation.BlobManager.Load(stream); if (version != VersionString) { Logger.Log(LogLevel.Warning, "Version of deserialized emulation ({0}) does not match current one {1}. Things may go awry!", version, VersionString); } } }
public PausedState(Emulation emulation) { emulation.MasterTimeSource.Stop(); machineStates = emulation.Machines.Select(x => x.ObtainPausedState()).ToArray(); emulation.ExternalsManager.Pause(); this.emulation = emulation; }
private EmulationManager() { var settings = new Antmicro.Migrant.Customization.Settings(Antmicro.Migrant.Customization.Method.Generated, Antmicro.Migrant.Customization.Method.Generated, Antmicro.Migrant.Customization.VersionToleranceLevel.AllowGuidChange, disableTypeStamping: true); serializer = new Serializer(settings); serializer.ForObject <PythonDictionary>().SetSurrogate(x => new PythonDictionarySurrogate(x)); serializer.ForSurrogate <PythonDictionarySurrogate>().SetObject(x => x.Restore()); currentEmulation = new Emulation(); ProgressMonitor = new ProgressMonitor(); stopwatch = new Stopwatch(); }
public void Load(string path) { string version; using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read)) { version = serializer.Deserialize <string>(stream); CurrentEmulation = serializer.Deserialize <Emulation>(stream); CurrentEmulation.BlobManager.Load(stream); } if (version != VersionString) { Logger.Log(LogLevel.Warning, "Version of deserialized emulation ({0}) does not match current one {1}. Things may go awry!", version, VersionString); } }
public void Clear() { CurrentEmulation = new Emulation(); }