public void can_create() { var time = TimeSpan.FromSeconds(90); var gap = new TimeGap(time); Assert.Equal(time, gap.Time); }
private void scanner_Tick(object sender, EventArgs e) { DateTime now = DateTime.Now; if (hour.Text == now.Hour.ToString() && minute.Text == now.Minute.ToString()) { //将当前时间往前推24小时,作为起始时间点 DateTime startTime = timeTool.YYMMDD_hh0000(DateTime.Now).AddHours(-24); //终点为当前时间小时减1秒 DateTime endTime = timeTool.YYMMDD_hh0000(DateTime.Now).AddSeconds(-1); TimeGap timeGap = new TimeGap(startTime, endTime); scanController.setTimeGap(timeGap); Thread scanThread = new Thread(new ThreadStart(scanController.scanTask)); scanThread.IsBackground = true; scanThread.Start(); } }
public void lap_and_time_gap_implement_a_special_comparable_contract_with_each_other() { // A lap gap should always be greater than any time gap. var lapLap = new LapGap(0); var timeGap = new TimeGap(TimeSpan.Zero); Assert.True(lapLap.CompareTo(timeGap) > 0); Assert.True(timeGap.CompareTo(lapLap) < 0); // Given the above, the following should pass. Assert.ComparableContract(Enumerable.Empty<Gap>(), new Gap[] { new LapGap(0), new TimeGap(TimeSpan.Zero), new LapGap(1), new TimeGap(TimeSpan.FromSeconds(1)), new LapGap(2), new TimeGap(TimeSpan.FromSeconds(2)), new LapGap(3), new TimeGap(TimeSpan.FromSeconds(3)), new LapGap(4), new TimeGap(TimeSpan.FromSeconds(4)), new LapGap(5), new TimeGap(TimeSpan.FromSeconds(5)), }); }
private void open_Click(object sender, EventArgs e) { open.Enabled = false; close.Enabled = true; hour.Enabled = false; minute.Enabled = false; scanner.Enabled = true; IRedisClient redis = RedisManager.redis; /*try * { * for(int i = 0; i < 4000; i++) * { * redis.Set<int>(i.ToString(), i); * } * }catch(Exception ex) * { * Console.WriteLine(ex.Message); * } */ //检测定时器启动,马上对前三周数据进行检测 DateTime startTime = timeTool.YYMMDD_hh0000(DateTime.Now).AddDays(-21); //终点为定时时间点前1天 DateTime endTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, Convert.ToInt32(hour.Text), Convert.ToInt32(minute.Text), 0); endTime = endTime.AddDays(-1); TimeGap timeGap = new TimeGap(startTime, endTime); scanController.setTimeGap(timeGap); Thread scanThread = new Thread(new ThreadStart(scanController.scanTask)); scanThread.IsBackground = true; scanThread.Start(); }
private void SetDefaultValue() { base.SetDefaultValue(NetWorkType.GSM); this.MAIO = 0; this.Pwbackff8psk = 0f; this.IsUseDTX = false; this.TRXType = Huawei.UNet.NE.Interface.TRXType.TCH; this.MinPower = 15f; this.TRXPower = 46f; this.TimeGapList = new List<TimeGap>(); for (int i = 0; i < 8; i++) { TimeGap item = new TimeGap(); this.TimeGapList.Add(item); } this.LotTargetUL = -5f; this.HOGate = 5f; this.Average8PSKPowerBackOff = 0f; this.HSN = 0; this.TargetLoad = 0.5f; this.EnableEgprs = true; this.HopMode = HoppingMode.NonHopping; this.MsMaxPower = 33f; this.MAL = string.Empty; this.SynchroRank = 0; this.ULIdealRxCIR = 15f; this.ULIdealRxPwr = -100f; this.Antdivgain = 0f; this.NetworkColourCode = 0; this.BaseStationColourCode = 0; this.RAC = 0; this.LAC = 0; }
private static string GapTime(TimeGap value) { return value.Time > TimeSpan.Zero ? SectorTime(value.Time) : String.Empty; }
public void setTimeGap(TimeGap timeGap) { this.timeGap = timeGap; }
public void GenFile() { string all_str = ""; int num = 1; string sss = ""; string tmp = ""; if (this.TimeGap == 24) { /*最大要素*/ var entity = new HydrologicReader().RetrieveHighestEntity(TimeFrom, TimeTo, Type); foreach (HydrologicEntityItem item in entity.Items) { if (!double.IsNaN(item.Latitude) && !double.IsNaN(item.Longitude)) { MicapsRecord record = new MicapsRecord(); record.Uid = item.Stationid.GetHashCode(); record.Latitude = item.Latitude; record.Longitude = item.Longitude; record.ValueL = item.L; record.ValueQ = item.Q; record.ValueWL1 = item.Wl1; record.ValueWL2 = item.Wl2; ListRecord.Add(record); all_str += num + "\t\t"; num++; all_str += item.Basin + "\t\t"; all_str += item.Administrativeregion + "\t\t"; all_str += item.River + "\t\t"; all_str += item.Name + "\t\t"; all_str += item.Latitude.ToString("F2") + "\t\t"; all_str += item.Longitude.ToString("F2") + "\t\t"; if (double.IsNaN(item.L)) { all_str += "9999\t\t"; } else { all_str += item.L.ToString("F2") + "\t\t"; } if (double.IsNaN(item.Q)) { all_str += "9999\t\t"; } else { all_str += item.Q.ToString("F2") + "\t\t"; } if (double.IsNaN(item.Wl1)) { all_str += "9999\t\t"; } else { all_str += item.Wl1.ToString("F2") + "\t\t"; } if (double.IsNaN(item.Wl2)) { all_str += "9999" + System.Environment.NewLine; } else { all_str += item.Wl2.ToString("F2") + System.Environment.NewLine; } } } if (Type.Equals("河道站")) { sss = "最高水位\t\t最大流量\t\t警戒水位\t\t保证水位" + System.Environment.NewLine; } if (Type.Equals("水库站")) { sss = "最高库水位\t\t最大蓄水量\t\t警戒水位\t\t保证水位" + System.Environment.NewLine; } all_str = "序号\t\t流域\t\t行政区\t\t河名\t\t站名\t\t纬度\t\t经度\t\t" + sss + all_str; /*生成最大全部要素*/ infodir = this.TimeGap + "小时最大全部要素"; tmp = TimeGap.ToString("D3"); this.FilePath = @"D:/products/" + Type + @"/" + tmp + @"/" + this.infodir + @"/" + this.FileName; FileInfo fileInfo = new FileInfo(this.FilePath); if (!fileInfo.Exists) { Directory.CreateDirectory(fileInfo.Directory.FullName); } using (System.IO.StreamWriter file = new System.IO.StreamWriter(FilePath, false, Encoding.Default)) { file.Write(all_str); } /*生成最新要素*/ all_str = ""; num = 1; entity = new HydrologicReader().RetrieveEntity(TimeFrom, TimeTo, Type); foreach (HydrologicEntityItem item in entity.Items) { if (!double.IsNaN(item.Latitude) && !double.IsNaN(item.Longitude)) { MicapsRecord record = new MicapsRecord(); record.Uid = item.Stationid.GetHashCode(); record.Latitude = item.Latitude; record.Longitude = item.Longitude; record.ValueL = item.L; record.ValueQ = item.Q; record.ValueWL1 = item.Wl1; record.ValueWL2 = item.Wl2; ListRecord.Add(record); all_str += num + "\t\t"; num++; all_str += item.Basin + "\t\t"; all_str += item.Administrativeregion + "\t\t"; all_str += item.River + "\t\t"; all_str += item.Name + "\t\t"; all_str += item.Latitude.ToString("F2") + "\t\t"; all_str += item.Longitude.ToString("F2") + "\t\t"; if (double.IsNaN(item.L)) { all_str += "9999\t\t"; } else { all_str += item.L.ToString("F2") + "\t\t"; } if (double.IsNaN(item.Q)) { all_str += "9999\t\t"; } else { all_str += item.Q.ToString("F2") + "\t\t"; } if (double.IsNaN(item.Wl1)) { all_str += "9999\t\t"; } else { all_str += item.Wl1.ToString("F2") + "\t\t"; } if (double.IsNaN(item.Wl2)) { all_str += "9999" + System.Environment.NewLine;; } else { all_str += item.Wl2.ToString("F2") + System.Environment.NewLine; } } } sss = ""; if (Type.Equals("河道站")) { sss = "最新水位\t\t最新流量\t\t警戒水位\t\t保证水位" + System.Environment.NewLine; } if (Type.Equals("水库站")) { sss = "最新库水位\t\t最新蓄水量\t\t警戒水位\t\t保证水位" + System.Environment.NewLine; } all_str = "序号\t\t流域\t\t行政区\t\t河名\t\t站名\t\t纬度\t\t经度\t\t" + sss + all_str; /*生成最新全部要素*/ infodir = this.TimeGap + "小时最新全部要素"; tmp = TimeGap.ToString("D3"); this.FilePath = @"D:/products/" + Type + @"/" + tmp + @"/" + this.infodir + @"/" + this.FileName; fileInfo = new FileInfo(this.FilePath); if (!fileInfo.Exists) { Directory.CreateDirectory(fileInfo.Directory.FullName); } using (System.IO.StreamWriter file = new System.IO.StreamWriter(FilePath, false, Encoding.Default)) { file.Write(all_str); } } if (this.TimeGap == 1) { /*生成最新要素*/ all_str = ""; num = 1; var entity = new HydrologicReader().RetrieveEntity(TimeFrom, TimeTo, Type); foreach (HydrologicEntityItem item in entity.Items) { if (!double.IsNaN(item.Latitude) && !double.IsNaN(item.Longitude)) { MicapsRecord record = new MicapsRecord(); record.Uid = item.Stationid.GetHashCode(); record.Latitude = item.Latitude; record.Longitude = item.Longitude; record.ValueL = item.L; record.ValueQ = item.Q; record.ValueWL1 = item.Wl1; record.ValueWL2 = item.Wl2; ListRecord.Add(record); all_str += num + "\t\t"; num++; all_str += item.Basin + "\t\t"; all_str += item.Administrativeregion + "\t\t"; all_str += item.River + "\t\t"; all_str += item.Name + "\t\t"; all_str += item.Latitude.ToString("F2") + "\t\t"; all_str += item.Longitude.ToString("F2") + "\t\t"; if (double.IsNaN(item.L)) { all_str += "9999\t\t"; } else { all_str += item.L.ToString("F2") + "\t\t"; } if (double.IsNaN(item.Q)) { all_str += "9999\t\t"; } else { all_str += item.Q.ToString("F2") + "\t\t"; } if (double.IsNaN(item.Wl1)) { all_str += "9999\t\t"; } else { all_str += item.Wl1.ToString("F2") + "\t\t"; } if (double.IsNaN(item.Wl2)) { all_str += "9999" + System.Environment.NewLine;; } else { all_str += item.Wl2.ToString("F2") + System.Environment.NewLine; } } } sss = ""; if (Type.Equals("河道站")) { sss = "最新水位\t\t最新流量\t\t警戒水位\t\t保证水位" + System.Environment.NewLine; } if (Type.Equals("水库站")) { sss = "最新库水位\t\t最新蓄水量\t\t警戒水位\t\t保证水位" + System.Environment.NewLine; } all_str = "序号\t\t流域\t\t行政区\t\t河名\t\t站名\t\t纬度\t\t经度\t\t" + sss + all_str; /*生成最新全部要素*/ infodir = this.TimeGap + "小时最新全部要素"; tmp = TimeGap.ToString("D3"); this.FilePath = @"D:/products/" + Type + @"/" + tmp + @"/" + this.infodir + @"/" + this.FileName; FileInfo fileInfo = new FileInfo(this.FilePath); fileInfo = new FileInfo(this.FilePath); if (!fileInfo.Exists) { Directory.CreateDirectory(fileInfo.Directory.FullName); } using (System.IO.StreamWriter file = new System.IO.StreamWriter(FilePath, false, Encoding.Default)) { file.Write(all_str); } } }
public void ctor_throws_if_time_is_not_positive() { Assert.DoesNotThrow(() => { var gap = new TimeGap(TimeSpan.Zero); }); Assert.Throws<ArgumentOutOfRangeException>(() => { var gap = new TimeGap(TimeSpan.FromMilliseconds(-1)); }); }