public override void Execute(Slb.Ocean.Petrel.Contexts.Context context) { //TODO: Add command execution logic here //测试通过按钮加载SCAL及PVT数据 string[] files; object[] objs; FileFormat format = PetrelSystem.FileFormats.WellKnownFileFormats.EclipseSCAL; //从文件加载到Petrel PetrelSystem.FileFormats.ShowImportDialog(format, "d:\\", SimulationRoot.Get(PetrelProject.PrimaryProject).RockPhysicsCollection.RockPhysicsCollections.First(), out files, out objs); //新建一个SCAL并赋值 using (ITransaction trans = DataManager.NewTransaction()) { trans.Lock(SimulationRoot.Get(PetrelProject.PrimaryProject).RockPhysicsCollection .RockPhysicsCollections.First()); SaturationFunction sf = SimulationRoot.Get(PetrelProject.PrimaryProject).RockPhysicsCollection .RockPhysicsCollections.First().CreateSaturationFunction("test"); List <SaturationFunction.CapillaryPressure.Curve.Record> cpRecords = new List <SaturationFunction.CapillaryPressure.Curve.Record>(); for (int i = 0; i < 5; i++) { double m = 0.5 + ((double)i / 10); cpRecords.Add(new SaturationFunction.CapillaryPressure.Curve.Record(m, 10 - i)); } sf.CapillaryPressures.GasWater.Enable(); sf.CapillaryPressures.GasWater.Records = cpRecords; trans.Commit(); } }
public bool Initialize(SimulationRoot simulationRoot, int playerServerId, List <ITAlertPlayer> players) { try { SimulationRoot = simulationRoot; Players = players; LogProxy.Warning($"Initializing Director for simulation Instance {InstanceId}"); //TODO: get rid of this hacky sack PlayerCommands.Director = this; ItemPanel = transform.FindComponent <ItemPanel>("Canvas/ItemPanel"); _queuedMessages = new Queue <TickMessage>(); ResetDirector(); // all of this must happen after reset // TODO: this should probably be pushed into the ECS if (SimulationRoot.ECS.TryGetSystem <ICommandSystem>(out var commandSystem) == false) { throw new SimulationIntegrationException("Could not locate command processing system"); } CommandSystem = commandSystem; CalculateNetworkOffset(); CreateInitialEntities(); SetupPlayers(players, playerServerId); // item panel must come after players GetComponentsInChildren <Canvas>(true).ToList().ForEach(c => c.gameObject.SetActive(true)); ItemPanel.Initialize(); ItemPanel.ExplicitUpdate(); SimulationRoot.ECS.EntityRegistry.EntityDestroyed += EntityRegistryOnEntityDestroyed; if (SimulationRoot.ECS.TryGetSystem(out _endGameSystem) == false) { throw new SimulationIntegrationException("Could not locate end game system"); } CultureInfo.CurrentCulture = new CultureInfo("en"); _updatethread = new Thread(ThreadWorker) { IsBackground = true }; _updatethread.Start(); return(true); } catch (Exception ex) { LogProxy.Error($"Error initializing Director: {ex}"); throw; } }