/// <summary> 用重启信息生成新重启数据(只包含主文件,初始化文件和生产文件) </summary> public EclipseData ChangeRestartModel(EclipseData mainData, RestartInfoModel model) { // 不读取INCLUDE部分数据 EclipseData data = new EclipseData(mainData.FilePath, null, l => false); var incs = data.Key.FindAll <INCLUDE>(); // 设置所有INCLUDE都不生成文件 incs.ForEach(l => l.IsCreateFile = false); // 保存主文件 SOLUTION sl = data.Key.Find <SOLUTION>(); SCHEDULE sc = data.Key.Find <SCHEDULE>(); // 替换数据 sl.ExChangeData(model.Solution); sc.ExChangeData(model.Schedule); // 设置保存部分数据 List <INCLUDE> slIncludes = sl.FindAll <INCLUDE>(); slIncludes.ForEach(l => l.IsCreateFile = true); List <INCLUDE> scIncludes = sc.FindAll <INCLUDE>(); scIncludes.ForEach(l => l.IsCreateFile = true); // 保存主文件(目前没用) //model.MainData = data; return(data); }
/// <summary> 快速获取所有井名(只读取schedule部分的Include关键字) </summary> public static List <string> GetAllWell(string dataFile) { List <string> strs = new List <string>(); EclipseData eclData = null; Thread thread = new Thread(() => eclData = new EclipseData(dataFile, null, l => l.IsMatchParent <SCHEDULE>()), 4194304);// 4mb栈 thread.Start(); while (true) { if (thread.ThreadState == ThreadState.Stopped) { break; } } SCHEDULE sch = eclData.Key.Find <SCHEDULE>(); List <WELSPECS> ws = sch.FindAll <WELSPECS>(); ws.ForEach(l => { l.Items.ForEach(k => { strs.Add(k.jm0); }); }); eclData.Dispose(); return(strs.Distinct().ToList()); }
void InitConstruct() { RUNSPEC runspec = new RUNSPEC("RUNSPEC"); this.Key.Add(runspec); GRID grid = new GRID("GRID"); this.Key.Add(grid); EDIT edit = new EDIT("EDIT"); this.Key.Add(edit); PROPS props = new PROPS("PROPS"); this.Key.Add(props); REGIONS regions = new REGIONS("REGIONS"); this.Key.Add(regions); SOLUTION solution = new SOLUTION("SOLUTION"); this.Key.Add(solution); SUMMARY summary = new SUMMARY("SUMMARY"); this.Key.Add(summary); SCHEDULE schedule = new SCHEDULE("SCHEDULE"); this.Key.Add(schedule); }
/// <summary> 增加重启时间 </summary> public static DATES AddSchDates(this SCHEDULE schDate, DateTime startTime, DateTime pTime) { BaseKey findKey = null; DateTime nowTime = startTime; if (nowTime > pTime) { throw new ArgumentException("插入的时间不能小于案例的起始时间!"); } schDate.Foreach( l => { if (l is DATES) { DATES date = l as DATES; nowTime = date.DateTime; // 记录比当前时间小的 if (nowTime < pTime) { findKey = l; } } //else if (l is TSTEP) //{ // TSTEP step = l as TSTEP; // int dayCount = step.DataCount; // nowTime.AddDays(dayCount); // // 记录比当前时间小的 // if (nowTime <= pTime) // { // findKey = l; // } //} } ); DATES insertDate = new DATES("DATES"); insertDate.SetDateTime(pTime); // 没有找到 = 插入END前面 if (findKey == null) { END endKey = schDate.Find <END>(); schDate.InsertBefore(endKey, insertDate); } // 找到了 = 插入指定关键字前面 else { schDate.InsertAfter(findKey, insertDate); } return(insertDate); }
/// <summary> 获取所有井名 </summary> public static List <WELSPECS> GetAllWellModel(this EclipseData eclData) { SCHEDULE sch = eclData.Key.Find <SCHEDULE>(); List <WELSPECS> ws = sch.FindAll <WELSPECS>(); return(ws); }
public SCHEDULE getScheduleByID(int ID) { var schedules = basedao.getSchedule(ID, null, null, null, null, null); SCHEDULE result = null; try { result = schedules.First(); } catch (System.InvalidOperationException e) { Console.WriteLine(e); return(null); } catch (System.ArgumentNullException e) { Console.WriteLine(e); return(null); } catch (Exception e) { Console.WriteLine(e); return(null); } return(result); }
public SCHEDULE GetSCHEDULEFromReader(IDataReader reader) { try { SCHEDULE sCHEDULE = new SCHEDULE ( (int)reader["SCHEDULEID"], (int)reader["EMP_ID"], (DateTime)reader["STDT"], (DateTime)reader["ENDDT"], reader["MON"].ToString(), reader["TUE"].ToString(), reader["WED"].ToString(), reader["THS"].ToString(), reader["FRI"].ToString(), reader["SAT"].ToString(), reader["SUN"].ToString() ); return(sCHEDULE); } catch (Exception ex) { return(null); } }
/// <summary> 返回生产信息中 指定时间之前(包含当前时间)总共重启个数 </summary> public int RestartCount(SCHEDULE sch, DateTime time) { //List<TIME> ts = sch.FindAll<TIME>(l => l.Find<HeBianGu.Product.SimalorManager.RegisterKeys.SimON.STEPRST>() != null && l.Date.Date <= time.Date); List <TIME> ts = sch.FindAll <TIME>(l => l.Date.Date <= time.Date); return(ts.Count - 1); }
public static SCHEDULE GetSCHEDULEByID(int id) { SCHEDULE sCHEDULE = new SCHEDULE(); SqlSCHEDULEProvider sqlSCHEDULEProvider = new SqlSCHEDULEProvider(); sCHEDULE = sqlSCHEDULEProvider.GetSCHEDULEByID(id); return(sCHEDULE); }
public ActionResult DeleteConfirmed(decimal id, decimal idsch) { SCHEDULE sCHEDULE = db.SCHEDULEs.Find(id, idsch); db.SCHEDULEs.Remove(sCHEDULE); db.SaveChanges(); return(RedirectToAction("Index")); }
/// <summary> 增加重启时间 </summary> public static DATES AddSchDates(this EclipseData eclData, DateTime pTime) { SCHEDULE schDate = eclData.Key.Find <SCHEDULE>(); START startDate = eclData.Key.Find <START>(); DateTime nowTime = startDate.StartTime; return(schDate.AddSchDates(nowTime, pTime)); }
public ActionResult Edit([Bind(Include = "ROUTEID,TRAINID,DEPARTURETIME,ARRIVALTIME")] SCHEDULE sCHEDULE) { if (ModelState.IsValid) { db.Entry(sCHEDULE).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ROUTEID = new SelectList(db.ROUTEs, "ROUTEID", "ROUTEID", sCHEDULE.ROUTEID); ViewBag.TRAINID = new SelectList(db.TRAINs, "TRAINID", "TRAINID", sCHEDULE.TRAINID); return(View(sCHEDULE)); }
// GET: Schedules/Details/5 public ActionResult Details(decimal id, decimal idsch) { if (id == null && idsch == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SCHEDULE sCHEDULE = db.SCHEDULEs.Find(id, idsch); if (sCHEDULE == null) { return(HttpNotFound()); } return(View(sCHEDULE)); }
// GET: Schedules/Edit/5 public ActionResult Edit(decimal id, decimal idsch) { if (id == null && idsch == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SCHEDULE sCHEDULE = db.SCHEDULEs.Find(id, idsch); if (sCHEDULE == null) { return(HttpNotFound()); } ViewBag.ROUTEID = new SelectList(db.ROUTEs, "ROUTEID", "ROUTEID", sCHEDULE.ROUTEID); ViewBag.TRAINID = new SelectList(db.TRAINs, "TRAINID", "TRAINID", sCHEDULE.TRAINID); return(View(sCHEDULE)); }
/// <summary> 从文件读取生产信息 </summary> public SCHEDULE RefreshRestartSchdule(RestartInfoModel restart) { // 创建关键字 SCHEDULE schedule = new SCHEDULE("SCHEDULE"); if (restart.SchPath != null && File.Exists(restart.SchPath)) { INCLUDE include = FileFactoryService.Instance.ThreadLoadFromFile(restart.SchPath); schedule.Add(include); } else { return(restart.Schedule); } return(schedule); }
/// <summary> 获取所有井名 </summary> public static List <string> GetAllWell(this EclipseData eclData) { SCHEDULE sch = eclData.Key.Find <SCHEDULE>(); List <WELSPECS> ws = sch.FindAll <WELSPECS>(); List <string> strs = new List <string>(); ws.ForEach(l => { l.Items.ForEach(k => { strs.Add(k.jm0); }); }); return(strs.Distinct().ToList()); }
/// <summary> 通关生产数据创建生产数据 </summary> public SCHEDULE InitRestartSchdule(SCHEDULE sch, RestartInfoModelSimON model, string name, DateTime time) { // 创建关键字 SCHEDULE schedule = new SCHEDULE("SCHEDULE"); INCLUDE include = new INCLUDE("INCLUDE"); include.FileName = name + "_SCH.DAT"; include.FilePath = Path.GetDirectoryName(model.ResultFilePath) + "//" + include.FileName; model.SchPath = include.FilePath; schedule.Add(include); //int findIndex = ds.FindIndex(l => (l.Date.Date - time.Date).TotalDays == 0); //if (findIndex == -1) //{ // throw new Exception("SimalorManager.InitRestartSchdule:没有对应日期的时间步:" + time.ToShortDateString()); //} sch.DeleteAll <TIME>(l => l.Date.Date < time.Date); List <VFPINJ> Vins = sch.FindAll <VFPINJ>(); List <VFPPROD> Vpns = sch.FindAll <VFPPROD>(); //ds.RemoveRange(0, findIndex); if (Vins.Count > 0) { include.AddRange(Vins); } if (Vpns.Count > 0) { include.AddRange(Vpns); } // 处理井数据 List <TIME> ds = sch.FindAll <TIME>(); include.AddRange(ds); return(schedule); }
/// <summary> 获取所有井组名 </summary> public static List <string> GetAllWellGroup(this EclipseData eclData) { SCHEDULE sch = eclData.Key.Find <SCHEDULE>(); List <GRUPTREE> ws = sch.FindAll <GRUPTREE>(); List <string> strs = new List <string>(); ws.ForEach(l => { l.Items.ForEach(k => { strs.Add(k.zjzm0); strs.Add(k.fjzm1); }); }); return(strs.Distinct().ToList()); }
public bool UpdateSCHEDULE(SCHEDULE sCHEDULE) { using (SqlConnection connection = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand("AbiMatuEnterprise_UpdateSCHEDULE", connection); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@SCHEDULEID", SqlDbType.Int).Value = sCHEDULE.SCHEDULEID; cmd.Parameters.Add("@EMP_ID", SqlDbType.Int).Value = sCHEDULE.EMP_ID; cmd.Parameters.Add("@STDT", SqlDbType.DateTime).Value = sCHEDULE.STDT; cmd.Parameters.Add("@ENDDT", SqlDbType.DateTime).Value = sCHEDULE.ENDDT; cmd.Parameters.Add("@MON", SqlDbType.VarChar).Value = sCHEDULE.MON; cmd.Parameters.Add("@TUE", SqlDbType.VarChar).Value = sCHEDULE.TUE; cmd.Parameters.Add("@WED", SqlDbType.VarChar).Value = sCHEDULE.WED; cmd.Parameters.Add("@THS", SqlDbType.VarChar).Value = sCHEDULE.THS; cmd.Parameters.Add("@FRI", SqlDbType.VarChar).Value = sCHEDULE.FRI; cmd.Parameters.Add("@SAT", SqlDbType.VarChar).Value = sCHEDULE.SAT; cmd.Parameters.Add("@SUN", SqlDbType.VarChar).Value = sCHEDULE.SUN; connection.Open(); int result = cmd.ExecuteNonQuery(); return(result == 1); } }
/// <summary> /// Get PMS socket(first socket) schedule /// </summary> public void GetPMSSchedule(deviceClass device) { if (device.devicePtr == IntPtr.Zero) { Console.WriteLine("No device found. Use \"Get device list\" button to find device.\n"); return; } int socket = 0; //socket number from 0 to 3 int bres = 0; String sCurEntry = String.Empty; //check device type switch ((DeviceType)Device.m_DeviceType) { case DeviceType.DT_PMS_USB: case DeviceType.DT_PMS_LAN: case DeviceType.DT_PMS_WLAN: case DeviceType.DT_PMS2_LAN: case DeviceType.DT_PMS2_WLAN: //allocate memory for schedule structure received from device SCHEDULE schedule = new SCHEDULE(); schedule.entries = new ENTRY_T[16 /*16 is MAX entries count*/]; int s = Marshal.SizeOf(schedule); //allocated unmanaged memory pointer for the databatch structure IntPtr pPointer = Marshal.AllocHGlobal(Marshal.SizeOf(schedule)); //call dll proc bres = GetSocketSchedule(device.devicePtr, socket, pPointer); //if all ok if (bres > 0) { schedule = (SCHEDULE)Marshal.PtrToStructure(pPointer, typeof(SCHEDULE)); string sch = ""; for (int i = 0; i < schedule.nEntryCount; i++) { sch += String.Format("#{0}: switch={1}, time={2:d/M/yyyy HH:mm:ss}\n", i + 1, schedule.entries[i].bSwitchState, CTimeToDate(schedule.entries[i].tTime)); } switch (schedule.nCurrentEntry) { case 0: sCurEntry = "1st entry"; break; case 1: sCurEntry = "2nd entry"; break; case 2: sCurEntry = "3rd entry"; break; case 3: sCurEntry = "4th entry"; break; case 4: sCurEntry = "5th entry"; break; case 5: sCurEntry = "6th entry"; break; case 6: sCurEntry = "7th entry"; break; case 7: sCurEntry = "8th entry"; break; case 8: sCurEntry = "9th entry"; break; case 9: sCurEntry = "10th entry"; break; case 10: sCurEntry = "11th entry"; break; case 11: sCurEntry = "12th entry"; break; case 12: sCurEntry = "13th entry"; break; case 13: sCurEntry = "14th entry"; break; case 14: sCurEntry = "15th entry"; break; case 15: sCurEntry = "16th entry"; break; case -1: sCurEntry = "not set"; break; default: sCurEntry = "error"; break; } //report actual schedule size and current entry Console.WriteLine(String.Format("Socket {0} has {1} schedule entries, current entry is {2}, \n{3}, schedule has {4}{5} loop\n", socket, schedule.nEntryCount, sCurEntry, sch, (schedule.nLoopTime == -1) ? "no" : schedule.nLoopTime.ToString(), schedule.nLoopTime == -1 ? "" : ((Device.m_DeviceType == 7 || Device.m_DeviceType == 8) ? "seconds" : "minutes"))); } else { Exception ex = new Exception("Dll function returned error "); throw (ex); } break; default: Console.WriteLine("No PMS Device is in use\n"); return; //return if wrong type } }
/// <summary> /// Set PMS socket (first socket) schedule /// schedule consists of two entries /// one switches socket on, another switches it off in 1 minute /// schedule is looped for 5 minutes /// </summary> public void SetPMSSchedule(deviceClass device) { if (device.devicePtr == IntPtr.Zero) { Exception ex = new Exception(" No device found. Use \"Get device list\" button to find device. "); throw (ex); } int socket = 0; //socket number from 0 to 3, use 0 for first socket int bres = 0; //check device type switch ((DeviceType)Device.m_DeviceType) { case DeviceType.DT_PMS_USB: case DeviceType.DT_PMS_LAN: case DeviceType.DT_PMS_WLAN: case DeviceType.DT_PMS2_LAN: case DeviceType.DT_PMS2_WLAN: //allocate memory for schedule structure SCHEDULE schedule = new SCHEDULE(); schedule.entries = new ENTRY_T[16]; //create schedule of two entries schedule.entries[0] = new ENTRY_T(DateTime.Now.AddMinutes(2), true, false); schedule.entries[1] = new ENTRY_T(DateTime.Now.AddMinutes(3), false, false); schedule.nCurrentEntry = 0; if (Device.m_DeviceType == 7 || Device.m_DeviceType == 8) //loop time in seconds { schedule.nLoopTime = 5 * 60; //5 minutes// set "-1" for no loop; } else //loop time in minutes { schedule.nLoopTime = 5; //5 minutes// set "-1" for no loop; } schedule.nEntryCount = 2; //two enties schedule.nTimeLeft = -1; //this is filled by device int s = Marshal.SizeOf(schedule); //allocated unmanaged memory pointer for the databatch structure IntPtr pPointer = Marshal.AllocHGlobal(Marshal.SizeOf(schedule)); //put schedule to unmanaged memory Marshal.StructureToPtr(schedule, pPointer, true); bres = SetSocketSchedule(device.devicePtr, socket, pPointer); //if all ok if (bres > 0) { Console.WriteLine(String.Format("Schedule set for socket {0}\n", socket)); } else { Exception ex = new Exception("Dll function returned error "); throw (ex); } break; default: Console.WriteLine("No PMS Device is in use\n"); return; //return if wrong type } }
public static bool UpdateSCHEDULE(SCHEDULE sCHEDULE) { SqlSCHEDULEProvider sqlSCHEDULEProvider = new SqlSCHEDULEProvider(); return(sqlSCHEDULEProvider.UpdateSCHEDULE(sCHEDULE)); }
/// <summary> /// GUI→Frontに設定を反映 /// </summary> private void SaveSetting() { // 登録ポート一覧からスケジュールとFrontに設定を反映 //Frontにはカンマ区切りに直して設定する clmSchedulePort.Items.Clear(); Front.Gui.PortList.Clear(); using (StringReader sr = new StringReader(optPortList.Text)) { while (sr.Peek() > 0) { string s = sr.ReadLine(); if (s.Length > 0) { try { int i = int.Parse(s); Front.Gui.PortList.Add(i); clmSchedulePort.Items.Add(s); } catch { } } } } // スケジュール設定のポートリストに「ALL」を追加 clmSchedulePort.Items.Add("ALL"); #region 基本設定 //自動再試行 Front.Retry.InRetryInterval = (uint)optInSecond.Value; Front.Retry.InRetryTime = (uint)optInTime.Value; Front.Retry.OutRetryInterval = (uint)optOutSecond.Value; Front.Retry.OutRetryTime = (uint)optOutTime.Value; //帯域制限 if (Front.BandStopTypeString[optBandType.SelectedIndex] == "ポート毎に個別設定") { // 個別設定 if (Front.BandStopTypeString[Front.BndWth.BandStopMode] != "ポート毎に個別設定") { //旧:個別設定以外→新:個別設定に変更になった場合 //設定された制限値をすべての起動中鏡に設定 foreach (Kagami _k in Front.KagamiList) { _k.Status.GUILimitUPSpeed = (int)optBandValue.Value; _k.Status.LimitUPSpeed = Front.CnvLimit((int)optBandValue.Value, optBandUnit.SelectedIndex); } } } else { // 個別設定以外 } Front.BndWth.BandStopMode = (uint)optBandType.SelectedIndex; Front.BndWth.BandStopValue = (uint)optBandValue.Value; Front.BndWth.BandStopUnit = (uint)optBandUnit.SelectedIndex; Front.BndWth.BandStopResv = optBandReserve.Checked; //連打キック Front.Kick.KickCheckSecond = (uint)optKickSecond.Value; Front.Kick.KickCheckTime = (uint)optKickTime.Value; Front.Kick.KickDenyTime = (uint)optKickDenyTime.Value; //ログ出力 Front.Log.KagamiLogFile = optKagamiLogFile.Text; Front.Log.LogDetail = optKagamiDetailLog.Checked; Front.Log.HpLogFile = optHpLogFile.Text; //最小化時 Front.Form.EnableTrayIcon = optMinTray.Checked; #endregion #region 鏡置き場 //エントランス Front.Hp.UseHP = optUseHP.Checked; Front.Hp.IpHTTP = optHPAddr.Text; Front.Hp.PublicDir = optHPDir.Text; try { Front.Hp.PortHTTP = uint.Parse(optHPPort.Text); } catch { MessageBox.Show("HP公開ポート番号が異常です。\r\n65535以下の数値を設定してください。", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } //エントランス接続制限 using (StringReader sr = new StringReader(optHPDenyList.Text)) { try { string str = ""; Front.Acl.HpDenyRemoteHost.Clear(); while (sr.Peek() > 0) { str = sr.ReadLine(); if (str.Length > 0 && Front.Acl.HpDenyRemoteHost.IndexOf(str) == -1) { Front.Acl.HpDenyRemoteHost.Add(str); } } } catch { } } //インポート接続制限 using (StringReader sr = new StringReader(optDenyList.Text)) { try { string str = ""; Front.Acl.DenyImportURL.Clear(); while (sr.Peek() > 0) { str = sr.ReadLine(); if (str.Length > 0 && Front.Acl.DenyImportURL.IndexOf(str) == -1) { Front.Acl.DenyImportURL.Add(str); } } } catch { } } ///同一インポートURL接続制限 if (optSameImportIPKick.Checked) { Front.Acl.LimitSameImportURL = (uint)optSameImportIPNum.Value; } else { Front.Acl.LimitSameImportURL = 0; } ///長時間インポート接続制限 if (optImportKick.Checked) { Front.Acl.ImportOutTime = (uint)optImportOutTime.Value; } else { Front.Acl.ImportOutTime = 0; } ///クライアント数制限 if (optClientTimeKick.Checked) { Front.Acl.ClientOutCheck = true; Front.Acl.ClientOutNum = (uint)optClientNum.Value; Front.Acl.ClientOutTime = (uint)optClientOutTime.Value; Front.Acl.ClientNotIPCheck = optClientNotIPEnable.Checked; } else { Front.Acl.ClientOutCheck = false; Front.Acl.ClientOutNum = 0; Front.Acl.ClientOutTime = 10; Front.Acl.ClientNotIPCheck = false; } ///待機中ポートがあれば自動解放しない Front.Acl.PortFullOnlyCheck = optPortFullOnly.Checked; ///インポートURLと設定者IPの一致チェック Front.Acl.SetUserIpCheck = optSetUserIpCheck.Checked; #endregion #region 詳細設定 //通信関連 Front.Sock.SockConnTimeout = (uint)optConnTimeOut.Value; Front.Sock.SockRecvTimeout = (uint)optRecvTimeOut.Value; Front.Sock.SockSendTimeout = (uint)optSendTimeOut.Value; Front.Sock.SockSendQueueSize = (uint)optSendQueueSize.Value; Front.Sock.SockCloseDelay = (uint)optSockCloseDelay.Value; //その他詳細 Front.Opt.BalloonTip = optBalloonTip.Checked; Front.Opt.BrowserView = optBrowser.Checked; Front.Opt.BrowserViewMode = optBrowserHtmlMode.Checked; Front.Opt.PriKagamiexe = optPriKagamiexe.Checked; Front.Opt.PriKagamin = optPriKagamin.Checked; Front.Acl.LimitSameClient = optSameClientKick.Checked ? (uint)optSameClientNum.Value : 0; Front.Opt.EnablePush = optEnablePush.Checked; if (!optEnablePush.Checked) { foreach (Kagami _k in Front.KagamiList) { _k.Status.DisablePull = false; } } Front.Opt.EnableInfo = optEnableInfo.Checked; Front.Opt.EnableAdmin = optEnableAdmin.Checked; Front.Opt.AdminPass = optAdminPass.Text; Front.Opt.SndConnOkFile = optSndConnOK.Text; Front.Opt.SndConnNgFile = optSndConnNG.Text; Front.Opt.SndDiscFile = optSndDisc.Text; #endregion #region スケジュール起動 Front.ScheduleItem.Clear(); for (int _num = 0; _num < scheduleDataView.Rows.Count - 1; _num++) { // 入力チェック if (//scheduleDataView[clmScheduleWeek.DisplayIndex, _num].Value == null || //scheduleDataView[clmScheduleHour.DisplayIndex, _num].Value == null || //scheduleDataView[clmScheduleMin.DisplayIndex, _num].Value == null || scheduleDataView[clmScheduleEvent.DisplayIndex, _num].Value == null) { continue; } // ポート入力必須のイベントは、ポート番号の入力チェック string _port; switch (scheduleDataView[clmScheduleEvent.DisplayIndex, _num].Value.ToString()) { case "強制切断": case "ポート待受開始": case "ポート待受停止": case "接続枠数変更": if (scheduleDataView[clmSchedulePort.DisplayIndex, _num].Value == null) { continue; } _port = (string)scheduleDataView[clmSchedulePort.DisplayIndex, _num].Value; break; default: // とりあえずALLで登録しておく _port = "ALL"; break; } // データ追加 SCHEDULE _item = new SCHEDULE(); if (scheduleDataView[clmScheduleEnable.DisplayIndex, _num].Value != null) { _item.Enable = (bool)scheduleDataView[clmScheduleEnable.DisplayIndex, _num].Value; } else { _item.Enable = false; } _item.Event = (uint)clmScheduleEvent.Items.IndexOf(scheduleDataView[clmScheduleEvent.DisplayIndex, _num].Value); if (_port == "ALL") { _item.Port = 0; } else { _item.Port = uint.Parse(_port); } string[] _str = scheduleDataView[clmScheduleData.DisplayIndex, _num].Value.ToString().Split(','); if (_str.Length == 9) { _item.StartType = uint.Parse(_str[0]); _item.Week = uint.Parse(_str[1]); _item.Hour = uint.Parse(_str[2]); _item.Min = uint.Parse(_str[3]); _item.TrfType = uint.Parse(_str[4]); _item.TrfValue = uint.Parse(_str[5]); _item.TrfUnit = uint.Parse(_str[6]); _item.ExecTrf = false; _item.Conn = uint.Parse(_str[7]); _item.Resv = uint.Parse(_str[8]); } else { throw new Exception("illigal schedule data"); } Front.ScheduleItem.Add(_item); } #endregion }
/// <summary> 清理父节点 </summary> public void InitParentKey(bool isCoal = false) { this.Key.Clear(); this.Key.CreateSingle <SIMSET>("SIMSET"); GRID grid = this.Key.CreateSingle <GRID>("GRID"); if (grid != null) { // 增加屏显 ECHO_OFF echo_off = new ECHO_OFF("ECHO_OFF"); grid.Add(echo_off); INCLUDE include = new INCLUDE("INCLUDE"); include.FileName = this.FileName.GetFileNameWithoutExtension() + "_REG.DAT"; include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; grid.Add(include); include = new INCLUDE("INCLUDE"); include.FileName = this.FileName.GetFileNameWithoutExtension() + "_GPRO.DAT"; include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; grid.Add(include); include = new INCLUDE("INCLUDE"); include.FileName = this.FileName.GetFileNameWithoutExtension() + "_GGO.DAT"; include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; grid.Add(include); include = new INCLUDE("INCLUDE"); include.FileName = this.FileName.GetFileNameWithoutExtension() + "_GOTH.DAT"; include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; grid.Add(include); // 关闭屏显 ECHO_ON echo_on = new ECHO_ON("ECHO_ON"); grid.Add(echo_on); } this.Key.CreateSingle <MODIFY>("MODIFY"); WELL well = this.Key.CreateSingle <WELL>("WELL"); USE_TF use_tf = new USE_TF("USE_TF"); if (well != null) { well.Add(use_tf); INCLUDE include = new INCLUDE("INCLUDE"); include.FileName = this.FileName.GetFileNameWithoutExtension() + "_WELL.DAT"; include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; well.Add(include); } PROPS props = this.Key.CreateSingle <PROPS>("PROPS"); if (props != null) { INCLUDE include = new INCLUDE("INCLUDE"); include.FileName = this.FileName.GetFileNameWithoutExtension() + "_SAT.DAT"; include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; props.Add(include); include = new INCLUDE("INCLUDE"); include.FileName = this.FileName.GetFileNameWithoutExtension() + "_PVT.DAT"; include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; props.Add(include); } if (isCoal) { ADSORB adsorb = this.Key.CreateSingle <ADSORB>("ADSORB"); INCLUDE include = new INCLUDE("INCLUDE"); include.FileName = this.FileName.GetFileNameWithoutExtension() + "_ADS.DAT"; include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; adsorb.Add(include); } SOLUTION solution = this.Key.CreateSingle <SOLUTION>("SOLUTION"); if (solution != null) { INCLUDE include = new INCLUDE("INCLUDE"); include.FileName = this.FileName.GetFileNameWithoutExtension() + "_INI.DAT"; include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; solution.Add(include); include = new INCLUDE("INCLUDE"); include.FileName = this.FileName.GetFileNameWithoutExtension() + "_AQU.DAT"; include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; solution.Add(include); } TUNESET tuneset = this.Key.CreateSingle <TUNESET>("TUNESET"); SOLVECTRL solvectrl = new SOLVECTRL("SOLVECTRL"); tuneset.Add(solvectrl); //if (solvectrl != null) //{ // INCLUDE include = new INCLUDE("INCLUDE"); // include.FileName = this.FileName.GetFileNameWithoutExtension() + "_TUN.DAT"; // include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; // solvectrl.Add(include); //} //SUMMARY summary = this.Key.CreateSingle<SUMMARY>("SUMMARY"); //if (summary != null) //{ // INCLUDE include = new INCLUDE("INCLUDE"); // include.FileName = this.FileName.GetFileNameWithoutExtension() + "_sum.inc"; // include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; // summary.Add(include); // //if (include.Keys.Count == 0) // //{ // // ALL all = new ALL("ALL"); // // include.Add(all); // //} //} SCHEDULE schedule = this.Key.CreateSingle <SCHEDULE>("SCHEDULE"); if (schedule != null) { INCLUDE include = new INCLUDE("INCLUDE"); include.FileName = this.FileName.GetFileNameWithoutExtension() + "_SCH.DAT"; include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; schedule.Add(include); } //END end = this.Key.CreateSingle<END>("END"); // 输出关键字 OUTSCHED rptsched = new OUTSCHED("RPTSCHED"); this.Key.Add(rptsched); }
/// <summary> 清理父节点 </summary> public void InitParentKey() { RUNSPEC runspec = this.Key.CreateSingle <RUNSPEC>("RUNSPEC"); GRID grid = this.Key.CreateSingle <GRID>("GRID"); if (grid != null) { INCLUDE include = new INCLUDE("INCLUDE"); include.FileName = this.FileName.GetFileNameWithoutExtension() + "_grid.inc"; include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; grid.Add(include); INCLUDE include1 = new INCLUDE("INCLUDE"); include1.FileName = this.FileName.GetFileNameWithoutExtension() + "_faults.inc"; include1.FilePath = this.FilePath.GetDirectoryName() + "\\" + include1.FileName; grid.Add(include1); INCLUDE include2 = new INCLUDE("INCLUDE"); include2.FileName = this.FileName.GetFileNameWithoutExtension() + "_aquifer.inc"; include2.FilePath = this.FilePath.GetDirectoryName() + "\\" + include1.FileName; grid.Add(include2); } EDIT edit = this.Key.Find <EDIT>(); if (edit != null) { INCLUDE include = new INCLUDE("INCLUDE"); include.FileName = this.FileName.GetFileNameWithoutExtension() + "_edit.inc"; include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; edit.Add(include); } PROPS props = this.Key.CreateSingle <PROPS>("PROPS"); if (props != null) { INCLUDE include = new INCLUDE("INCLUDE"); include.FileName = this.FileName.GetFileNameWithoutExtension() + "_pvt.inc"; include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; props.Add(include); include = new INCLUDE("INCLUDE"); include.FileName = this.FileName.GetFileNameWithoutExtension() + "_rp.inc"; include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; props.Add(include); } SOLUTION solution = this.Key.CreateSingle <SOLUTION>("SOLUTION"); if (solution != null) { INCLUDE include = new INCLUDE("INCLUDE"); include.FileName = this.FileName.GetFileNameWithoutExtension() + "_init.inc"; include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; solution.Add(include); } REGIONS region = this.Key.CreateSingle <REGIONS>("REGIONS"); if (region != null) { INCLUDE include = new INCLUDE("INCLUDE"); include.FileName = this.FileName.GetFileNameWithoutExtension() + "_regs.inc"; include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; region.Add(include); } SUMMARY summary = this.Key.CreateSingle <SUMMARY>("SUMMARY"); if (summary != null) { INCLUDE include = new INCLUDE("INCLUDE"); include.FileName = this.FileName.GetFileNameWithoutExtension() + "_sum.inc"; include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; summary.Add(include); //if (include.Keys.Count == 0) //{ // ALL all = new ALL("ALL"); // include.Add(all); //} } SCHEDULE schedule = this.Key.CreateSingle <SCHEDULE>("SCHEDULE"); if (schedule != null) { INCLUDE include = new INCLUDE("INCLUDE"); include.FileName = this.FileName.GetFileNameWithoutExtension() + "_sch.inc"; include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName; schedule.Add(include); } END end = this.Key.CreateSingle <END>("END"); }
/// <summary> 将Eclipse数模文件转换成SimON数模文件 </summary> public SimONData ConvertToSimON(EclipseData ecl) { // Todo :Eclipse里面的修改参数没有解析成SimON中修改参数 ecl.RunModify(); RUNSPEC runspec = ecl.Key.Find <RUNSPEC>(); GRID grid = ecl.Key.Find <GRID>(); SOLUTION solution = ecl.Key.Find <SOLUTION>(); SUMMARY summary = ecl.Key.Find <SUMMARY>(); SCHEDULE schedule = ecl.Key.Find <SCHEDULE>(); REGIONS regions = ecl.Key.Find <REGIONS>(); PROPS props = ecl.Key.Find <PROPS>(); SimONData simon = new SimONData(); simon.FileName = ecl.FileName; simon.FilePath = ecl.FilePath; simon.MmfDirPath = ecl.MmfDirPath; simon.InitConstruct(); simon.X = ecl.X; simon.Y = ecl.Y; simon.Z = ecl.Z; // 模型定义 #region - 起始时间 - SOLVECTRL tuning = new SOLVECTRL("TUNING"); tuning.Date = ecl.Key.Find <START>().StartTime; simon.Key.Add(tuning); #endregion #region - 维数定义 - RSVSIZE rsvsize = new RSVSIZE("RSVSIZE"); DIMENS dimens = ecl.Key.Find <DIMENS>(); rsvsize.X = dimens.X; rsvsize.Y = dimens.Y; rsvsize.Z = dimens.Z; simon.Key.Add(rsvsize); #endregion #region - 单位类型 - UnitType unitType = UnitType.METRIC; // 读到METRIC公制单位 METRIC metric = ecl.Key.Find <METRIC>(); if (metric != null) { simon.Key.Add(metric); unitType = UnitType.METRIC; } // 单位类型 FIELD field = ecl.Key.Find <FIELD>(); if (field != null) { simon.Key.Add(field); unitType = UnitType.FIELD; } #endregion #region - 流体类型 - MODELTYPE modeltype = new MODELTYPE("MODELTYPE"); // 流体类型 OIL oil = runspec.Find <OIL>(); WATER water = runspec.Find <WATER>(); GAS gas = runspec.Find <GAS>(); DISGAS disgas = runspec.Find <DISGAS>(); VAPOIL vapoil = runspec.Find <VAPOIL>(); // 黑油 if (oil != null && water != null && gas != null && disgas != null && vapoil == null) { modeltype.MetricType = MetricType.BLACKOIL; } // 油水 else if (oil != null && water != null && gas == null && disgas == null && vapoil == null) { modeltype.MetricType = MetricType.OILWATER; } // 气水 else if (oil == null && water != null && gas != null && disgas == null && vapoil == null) { modeltype.MetricType = MetricType.GASWATER; } // 挥发油 else if (oil != null && water != null && gas != null && disgas != null && vapoil != null) { modeltype.MetricType = MetricType.HFOIL; } else { modeltype.MetricType = MetricType.BLACKOIL; } simon.Key.Add(modeltype); #endregion #region - 分区维数 - EQUILREG equilreg = new EQUILREG("EQUILREG"); FIPREG fipreg = new FIPREG("FIPREG"); ROCKREG rockreg = new ROCKREG("ROCKREG"); SATREG satreg = new SATREG("SATREG"); PVTREG pvtreg = new PVTREG("PVTREG"); simon.Key.Add(equilreg); simon.Key.Add(fipreg); simon.Key.Add(rockreg); simon.Key.Add(satreg); simon.Key.Add(pvtreg); TABDIMS tabdims = runspec.Find <TABDIMS>(); if (tabdims != null) { fipreg.X = tabdims.Fipfqzds4.ToString(); rockreg.X = tabdims.Yslxgs12.ToString(); satreg.X = tabdims.Bhdbs0.ToString(); pvtreg.X = tabdims.Pvtbs1.ToString(); //fipreg.X = "1"; //rockreg.X = "1"; //satreg.X = "1"; //pvtreg.X = "1"; } EQLDIMS eqldims = runspec.Find <EQLDIMS>(); if (eqldims != null) { //equilreg.X = "1"; equilreg.X = eqldims.Phfqs0.ToString(); } OVERBURD overburd = props.Find <OVERBURD>(); if (overburd != null) { //rockreg.X = overburd.Regions.Count.ToString(); } EQUILMAP equilmap = new EQUILMAP("EQUILMAP"); FIPMAP fipmap = new FIPMAP("FIPMAP"); ROCKMAP rockmap = new ROCKMAP("ROCKMAP"); SATMAP satmap = new SATMAP("SATMAP"); PVTMAP pvtmap = new PVTMAP("PVTMAP"); if (regions != null) { EQLNUM eqlnum = regions.Find <EQLNUM>(); if (eqlnum != null) { equilmap = eqlnum.ToTableKey <EQUILMAP>(); solution.Add(equilmap); eqlnum.Delete(); eqlnum.Dispose(); } // Todo :非平衡初始化压力需要转换 var pressure = solution.Find <PRESSURE>(); if (pressure != null) { POIL poil = pressure.ToTableKey <POIL>(); solution.Add(poil); pressure.Delete(); pressure.Dispose(); } if (regions != null) { FIPNUM fipnum = regions.Find <FIPNUM>(); if (fipnum != null) { fipmap = fipnum.ToTableKey <FIPMAP>(); grid.Add(fipmap); fipnum.Delete(); fipnum.Dispose(); } ROCKNUM rocknum = regions.Find <ROCKNUM>(); if (rocknum != null) { rockmap = rocknum.TransToTableKeyByName("ROCKMAP", true) as ROCKMAP; grid.Add(rockmap); rocknum.Delete(); rocknum.Dispose(); } SATNUM satnum = regions.Find <SATNUM>(); if (satnum != null) { satmap = satnum.ToTableKey <SATMAP>(); grid.Add(satmap); satnum.Delete(); satnum.Dispose(); } PVTNUM pvtnum = regions.Find <PVTNUM>(); if (pvtnum != null) { pvtmap = pvtnum.ToTableKey <PVTMAP>(); grid.Add(pvtmap); pvtnum.Delete(); pvtnum.Dispose(); } } } #endregion #region - 地质模型 - simon.Key.Add(grid); #endregion #region - 断层 - //var eclFaults = grid.FindAll<OPT.Product.SimalorManager.RegisterKeys.Eclipse.FAULTS>(); //foreach (var v in eclFaults) //{ //grid.AddRange(this.ConvertToSimON(v)); //v.Delete(); //} #endregion #region - 水体 - //AQUFETP AQUFETP= // Todo :Fetkovich水体数据转换 var ct = solution.Find <OPT.Product.SimalorManager.RegisterKeys.Eclipse.AQUCT>(); if (ct != null) { var newFetp = this.ConvertToSimON(ct); solution.Add(newFetp); ct.Delete(); } // Todo :Fetkovich水体数据转换 var fetp = solution.Find <OPT.Product.SimalorManager.RegisterKeys.Eclipse.AQUFETP>(); if (fetp != null) { var newFetp = this.ConvertToSimON(fetp); solution.Add(newFetp); fetp.Delete(); } // Todo :水体连接数据转换 var aquancon = solution.Find <OPT.Product.SimalorManager.RegisterKeys.Eclipse.AQUANCON>(); if (aquancon != null) { var newFetp = this.ConvertToSimON(aquancon); solution.Add(newFetp); aquancon.Delete(); } #endregion #region - 流体模型 岩石模型- GRAVITY gravity = ecl.Key.Find <GRAVITY>(); if (gravity != null) { // Todo :SimON只解析绝对密度 DENSITY density = this.ConvertTo(gravity, unitType); gravity.ParentKey.Add(density); gravity.Delete(); } List <IRegionInterface> regSoltionKeys = solution.FindAll <IRegionInterface>(); regSoltionKeys.ForEach(l => l.TransToSimONRegion()); simon.Key.Add(solution); // List <IRegionInterface> regPropsKeys = props.FindAll <IRegionInterface>(); regPropsKeys.ForEach(l => l.TransToSimONRegion()); //// Todo :SGWFN 需要特殊转换为 SWGF //SGWFN sgwfn = props.Find<SGWFN>(); //if (sgwfn != null) //{ // //props.AddRange(sgwfn.ConvertTo()); // simon.Key.AddRange<SWGF>(sgwfn.ConvertTo()); //} simon.Key.Add(props); #endregion #region - 初始化模型 - List <EQUIL> equil = solution.FindAll <EQUIL>(); foreach (var item in equil) { EQUILPAR equilpar = new EQUILPAR("EQUILPAR"); EQUIL.Item it = item.GetSingleRegion().GetSingleItem(); equilpar.Szstzdhs0 = it.cksd0; equilpar.Szstljs1 = it.ckyl1; equilpar.Ctstyxhs2 = it.ysjmsd2; equilpar.Ctstyxzdhs3 = it.ysjmcmgyl3.ToDefalt("0"); //equilpar.Jxstzds4 = it.yqjmsd4; equilpar.E100wgzds5 = it.yqjmsd4; equilpar.E300jxstzds6 = it.yqjmcmgyl5; item.ParentKey.Add(equilpar); item.Delete(); } #endregion #region - 生产模型 - WELL well = new WELL("WELL"); // Todo :添加完井数据 (注意要放到生产模型前面) simon.Key.Add(well); // 生产模型 simon.Key.Add(this.ConvertToSimON(schedule, well, ecl.Key.Find <START>().StartTime, simon.HistoryData)); #endregion // Todo :转换修正关键字 List <ModifyKey> modifys = ecl.Key.FindAll <ModifyKey>(); grid.AddRange(modifys); return(simon); }
/// <summary> 通关生产数据创建生产数据(目前只应用在FieldGoal案例重启) </summary> public SCHEDULE InitRestartSchduleRestartCase(SCHEDULE sch, RestartInfoModelSimON model, string name, DateTime time, DateTime endtime, Dictionary <string, double> wellProducts, int datype) { // 创建关键字 SCHEDULE schedule = new SCHEDULE("SCHEDULE"); INCLUDE include = new INCLUDE("INCLUDE"); include.FileName = name + "_SCH.DAT"; include.FilePath = Path.GetDirectoryName(model.ResultFilePath) + "//" + include.FileName; model.SchPath = include.FilePath; schedule.Add(include); include.Add(new USESTARTTIME("USESTARTTIME")); include.Add(new RECURRENT("WELLSCHED")); TIME start = new TIME("TIME", time); foreach (var item in wellProducts) { WELLCTRL well = new WELLCTRL("WELLCTRL"); well.WellName0 = item.Key; well.ProType = datype == 0 ? SimONProductType.GRAT : datype == 1? SimONProductType.ORAT: SimONProductType.LRAT; well.Jcyblxz2 = item.Value.ToString(); start.Add(well); } TIME startAdd = new TIME("TIME", time.AddDays(1)); TIME end = new TIME("TIME", endtime); end.Add(new RegisterKeys.SimON.STEPRST("STEPRST")); List <VFPINJ> Vins = sch.FindAll <VFPINJ>(); List <VFPPROD> Vpns = sch.FindAll <VFPPROD>(); if (Vins.Count > 0) { include.AddRange(Vins); } if (Vpns.Count > 0) { include.AddRange(Vpns); } include.Add(start); if (startAdd.Date < end.Date) { include.Add(startAdd); } if (end.Date.Date == start.Date.Date) { include.Add(startAdd); } else { include.Add(end); } // HTodo :保存生产文件 include.Save(); return(schedule); // HTodo :示例如下 //USESTARTTIME //WELLSCHED //TIME 20140209D // WELL 'PROD1' 4 9000 1500 // WELL 'INIJ1' 5 6000 NA //TIME 20140210D //TIME 20140309D //RESTART }
/// <summary> 用重启信息生成新重启数据(只包含主文件,初始化文件和生产文件) </summary> public SimONData ChangeRestartModel(string mainFilePath, RestartInfoModelSimON model) { // 不读取INCLUDE部分数据 只读取SCHEDLE中INCLUDE SimONData data = FileFactoryService.Instance.ThreadLoadFunc <SimONData>(() => new SimONData(mainFilePath, null, l => l.GetParentKey() is SCHEDULE)); // HTodo :传递输出参数 需要测试 OUTSCHED rptsched = data.Key.Find <OUTSCHED>(); RPTSUM rptsum = data.Key.Find <RPTSUM>(); var incs = data.Key.FindAll <INCLUDE>(); // 设置所有INCLUDE都不生成文件 incs.ForEach(l => l.IsCreateFile = false); // 保存主文件 SOLUTION sl = data.Key.Find <SOLUTION>(); SCHEDULE sc = data.Key.Find <SCHEDULE>(); WELLCTRL well = data.Key.Find <WELLCTRL>(); // 更改起始时间 SOLVECTRL tuning = data.Key.Find <SOLVECTRL>(); // Todo :主文件没有在solotion中找 if (tuning == null) { tuning = sl.Find <SOLVECTRL>(); } tuning.Date = model.RestartTime; model.Solution.Add(tuning); // 替换数据 sl.ExChangeData(model.Solution); sc.ExChangeData(model.Schedule); well.ExChangeData(model.Well); // // 设置保存部分数据 List <INCLUDE> slIncludes = sl.FindAll <INCLUDE>(); slIncludes.ForEach(l => l.IsCreateFile = true); List <INCLUDE> scIncludes = sc.FindAll <INCLUDE>(); scIncludes.ForEach(l => l.IsCreateFile = true); List <INCLUDE> wellIncludes = well.FindAll <INCLUDE>(); wellIncludes.ForEach(l => l.IsCreateFile = true); // 保存主文件(目前没用) //model.MainData = data; if (rptsched != null) { data.Key.Add(rptsched); } if (rptsum != null) { data.Key.Add(rptsum); } //// Todo :插入标识到第二个关键字 //HeBianGu.Product.SimalorManager.RegisterKeys.SimON.STEPRST restart = new HeBianGu.Product.SimalorManager.RegisterKeys.SimON.STEPRST("STEPRST"); //data.Key.InsertKey(1, restart); return(data); }
/// <summary> 将Eclipse生产数据转换成SimON生产数据 </summary> public SCHEDULE ConvertToSimON(SCHEDULE sch, WELL location, DateTime startTime, BaseFile history) { // Todo :保存SCH SCHEDULE schedule = new SCHEDULE("SCHEDULE"); List <string> wellNames = new List <string>(); List <WELSPECS> ws = sch.FindAll <WELSPECS>(); // Todo :查找所有井名 ws.ForEach(l => wellNames.AddRange(l.Items.Select(k => k.jm0))); List <NAME> histNames = new List <NAME>(); // Todo :初始化名称 生产_historyproduction.dat wellNames.ForEach(l => histNames.Add(new NAME("NAME") { WellName = l })); histNames.ForEach(l => history.Key.Add(l)); // Todo :初始化完井WELL数据 List <NAME> names = new List <NAME>(); wellNames.ForEach(l => names.Add(new NAME("NAME") { WellName = l })); names.ForEach(l => location.Add(l)); List <DATES> ds = sch.FindAll <DATES>(); string format = "井名:{0} ({1},{2})"; // Todo :添加起始信息到时间步 DATES start = new DATES("DATES", startTime); sch.DeleteAll <DATES>(); start.AddRange <BaseKey>(sch.Keys); ds.Insert(0, start); List <PERF> comAllTemp = new List <PERF>(); foreach (DATES d in ds) { // Todo :对缓存中完井井名去重复取最后一条 var distincts = comAllTemp.GroupBy(l => l.WellName + l.I0 + l.J1 + l.K12).ToList(); comAllTemp.Clear(); foreach (var item in distincts) { comAllTemp.Add(item.Last()); } // 创建SimON日期 TIME time = new TIME("TIME"); time.Date = d.DateTime; schedule.Add(time); var wconprod = d.FindAll <WCONPROD>(); var wconhist = d.FindAll <WCONHIST>(); var wconinje = d.FindAll <WCONINJE>(); var wconinjh = d.FindAll <WCONINJH>(); // 完井数据(考虑到排序) List <BaseKey> compdats = d.FindAll <BaseKey>(l => l is COMPDAT || l is WELOPEN); List <WPIMULT> wpimult = d.FindAll <WPIMULT>(); List <WELOPEN> welopen = d.FindAll <WELOPEN>(); #region - 添加没有生产信息的完井 - // 添加完井数据 foreach (BaseKey c in compdats) { if (c is COMPDAT) { COMPDAT com = c as COMPDAT; foreach (COMPDAT.Item citem in com.Items) { // Todo :过滤有生产数据的,用后面方法处理 if (wconprod.Exists(l => l.Items.Exists(k => k.jm0 == citem.jm0))) { continue; } if (wconhist.Exists(l => l.Items.Exists(k => k.wellName0 == citem.jm0))) { continue; } if (wconinje.Exists(l => l.Items.Exists(k => k.jm0 == citem.jm0))) { continue; } if (wconinjh.Exists(l => l.Items.Exists(k => k.jm0 == citem.jm0))) { continue; } WELLCTRL well = time.Find <WELLCTRL>(l => l.WellName0 == citem.jm0); if (well == null) { // Todo :创建一个空的生产信息 well = new WELLCTRL("WELLCTRL"); well.ProType = SimONProductType.NA; well.WellName0 = citem.jm0; time.Add(well); } NAME name = names.Find(l => l.WellName == well.WellName0); #region - SCh数据 - PERF perf = new PERF("PERF"); perf.WellName = well.WellName0; perf.I0 = citem.i1; perf.J1 = citem.j2; perf.K12 = citem.swg3; perf.K23 = citem.xwg4; perf.Kgbs4 = citem.kgbz5; perf.Jzs6 = citem.ljyz7; perf.WjfxX7 = citem.skfx12 == "X" ? "DX" : "0"; perf.WjfxY8 = citem.skfx12 == "Y" ? "DY" : "0"; perf.WjfxZ9 = citem.skfx12 == "Z" ? "DZ" : "0"; perf.Bp10 = citem.bpxs10; // Todo :查找井指数乘子 foreach (WPIMULT wp in wpimult) { var v = wp.Items.Find(l => l.jm0 == well.WellName0); if (v != null) { perf.Jzscz5 = v.jzscz1; break; } } // Todo :增加前先删除存在的重复数据 well.DeleteAll <PERF>(l => l.I0 == perf.I0 && l.J1 == perf.J1 && l.K12 == perf.K12); well.Add(perf); #endregion #region - WELL数据 - NAME.Item nameItem = new NAME.Item(); nameItem.i0 = citem.i1; nameItem.j1 = citem.j2; nameItem.k12 = citem.swg3; nameItem.k23 = citem.xwg4; nameItem.kgbz4 = citem.kgbz5; //nameItem.wi5 = "NA";// v.Value.skin.Value.Value.ToString(); //nameItem.dx6 = v.Value.wellIndex.Value.GetValue(v.Value.wellIndex.GetUnitValue(_ecl)).ToString(); //nameItem.dy7 = v.Value.wellDirection.Value.Value == "X" ? "0" : v.Value.wellDirection.Value.Value == "Y" ? "1" : "2"; nameItem.bpxs9 = citem.bpxs10; nameItem.jj10 = (citem.jtnj8.ToDouble() / 2).ToString(); name.Items.Add(nameItem); #endregion comAllTemp.Add(perf); } } else if (c is WELOPEN) { WELOPEN wp = c as WELOPEN; foreach (var v in wp.Items) { // Todo :过滤有生产数据的,用后面方法处理 if (wconprod.Exists(l => l.Items.Exists(k => k.jm0 == v.jm0))) { continue; } if (wconhist.Exists(l => l.Items.Exists(k => k.wellName0 == v.jm0))) { continue; } if (wconinje.Exists(l => l.Items.Exists(k => k.jm0 == v.jm0))) { continue; } if (wconinjh.Exists(l => l.Items.Exists(k => k.jm0 == v.jm0))) { continue; } // WELOPEN //'G13' 'SHUT' 0 0 0 2 * / // / // Todo :查找之前所有完井 var coms = comAllTemp.FindAll(l => l.WellName == v.jm0); Predicate <PERF> match = l => true; // Todo :0 或 *表示默认值全都取 if (v.i2 != KeyConfiger.EclipseDefalt && v.i2 != "0") { match += l => l.I0 == v.i2; } if (v.j3 != KeyConfiger.EclipseDefalt && v.j3 != "0") { match += l => l.J1 == v.j3; } if (v.k4 != KeyConfiger.EclipseDefalt && v.k4 != "0") { match += l => l.K12 == v.k4; } var findComs = coms.FindAll(match); WELLCTRL well = time.Find <WELLCTRL>(l => l.WellName0 == v.jm0); if (well == null) { // Todo :创建一个空的生产信息 well = new WELLCTRL("WELLCTRL"); well.ProType = SimONProductType.NA; well.WellName0 = v.jm0; time.Add(well); } // Todo :增加WELOPEN控制的完井 foreach (var fitem in findComs) { PERF perf = fitem.Copy(); perf.Kgbs4 = v.jz1; // Todo :增加前先删除存在的重复数据 well.DeleteAll <PERF>(l => l.I0 == fitem.I0 && l.J1 == fitem.J1 && l.K12 == fitem.K12); well.Add(perf); } } } //this.ConvertCompadat(well, names, compdats, wpimult, comAllTemp); } #endregion foreach (var item in wconprod) { foreach (WCONPROD.ItemHY it in item.Items) { // 生产数据 WELLCTRL well = new WELLCTRL("WELLCTRL"); well.WellName0 = it.jm0; well = this.ConvertToSimON(it, d, histNames); if (well != null) { this.ConvertCompadat(well, names, compdats, wpimult, comAllTemp); time.Add(well); } } } foreach (var item in wconhist) { foreach (WCONHIST.Item it in item.Items) { // 生产数据 WELLCTRL well = new WELLCTRL("WELLCTRL"); well.WellName0 = it.wellName0; well = this.ConvertToSimON(it, d, histNames); this.ConvertCompadat(well, names, compdats, wpimult, comAllTemp); time.Add(well); } } foreach (var item in wconinje) { foreach (WCONINJE.ItemHY it in item.Items) { // 生产数据 WELLCTRL well = new WELLCTRL("WELLCTRL"); well.WellName0 = it.jm0; well = this.ConvertToSimON(it, d, histNames); this.ConvertCompadat(well, names, compdats, wpimult, comAllTemp); time.Add(well); } } foreach (var item in wconinjh) { foreach (WCONINJH.Item it in item.Items) { // 生产数据 WELLCTRL well = new WELLCTRL("WELLCTRL"); well.WellName0 = it.jm0; well = this.ConvertToSimON(it, d, histNames); this.ConvertCompadat(well, names, compdats, wpimult, comAllTemp); time.Add(well); } } //// Todo :将之前的完井信息都加入到缓存中 //foreach (var item in compdats) //{ // comAllTemp.AddRange(item.Items); //} } return(schedule); }
/// <summary> 获取所有重启时间步 </summary> public List <TIME> GetAllRestartTime(SCHEDULE sch) { return(sch.FindAll <TIME>(l => l.Find <HeBianGu.Product.SimalorManager.RegisterKeys.SimON.STEPRST>() != null)); }