public TrainingSegment GetSegment(int segmentNum) { if (Segments != null && Segments.Count() > segmentNum) { return(Segments.ElementAt(segmentNum)); } return(null); }
/// <summary>Removes last segment.</summary> /// <remarks>If there is no <paramref name="predicate" /> provided, last segment is removed by default.</remarks> /// <param name="predicate">Optional predicate used determine which segments to remove.</param> /// <returns>New <see cref="IpUrl" /> instance with segment removed.</returns> public virtual IpUrl RemoveSegment(Func <string, int, bool> predicate = null) { if (!SupportsSegmentOperations) { throw new InvalidOperationException(String.Format("Url of type '{0}' does not support segment operations.", GetType())); } int count = Segments.Count(); return(count == 0 ? this : CreateInstance(predicate == null ? Segments.TakeWhile((segment, index) => index < count - 1) : Segments.Where((segment, index) => !predicate(segment, index)))); }
void AddSegment(TruckerLog pinStart, TruckerLog logStart, TruckerLog logStop) { var segLogs = TruckerLogs.Where(x => x.TimeStamp >= logStart.TimeStamp && x.TimeStamp <= logStop.TimeStamp).ToList(); var segment = new Segment { PinStart = pinStart, LogStart = logStart, LogStop = logStop, StartTime = logStart.TimeStamp, StopTime = logStop.TimeStamp, TravelTime = logStop.TimeStamp - logStart.TimeStamp, Points = segLogs.Count(), MaxSpeed = segLogs.Max(m => m.Speed), AvgSpeed = segLogs.Average(m => m.Speed), MaxSpeedBreaks = segLogs.Where(x => x.Speed > Manager.MaxSpeed).Count(), MaxAccelBreaks = segLogs.Where(x => x.Acceleration > Manager.MaxAccel).Count(), Delay = Segments.Count() > 0 ? (logStart.TimeStamp - pinStart.TimeStamp) : null, TruckerID = Trucker.ID }; Segments.Add(segment); }
/// <summary> /// Get the segment count. /// </summary> /// <param name="keySegmentAsDepth">A bool value indicating whether to count key segment or not.</param> /// <returns>The count.</returns> public int GetCount(bool keySegmentAsDepth) { return(Segments.Count(c => keySegmentAsDepth ? true : !(c is ODataKeySegment))); }
public override string ToString() { return(String.Format("Loop(Id={0},ParentId={1},Level={2},ChildLoops={3}, ChildSegments={4})", Id, ParentId, LevelCode, Loops.Count(), Segments.Count())); }
internal virtual int CountTotalSegments() { return(1 + Segments.Count() + TrailerSegments.Count()); }
//METHODS public void InitializeRecipeSegments() { /************************************************************************************************************** * -> Method : InitializeRecipeSegments * -> Event : When Commit load is clicked * -> Description: This method is used to initialize the chosen recipe by binding all of the properties to the UI. * The list of type Segment_Details called "Segments" holds all segments in the recipe and allows * to skip between the segments. **************************************************************************************************************/ //1-instantiate separate OPC connection on separate thread //with each new segment, need to write on PLC the desired target value, then need to monitor every x amount seconds // need to constantly monitor the values of the PLC for the running segment(maybe on separate thread?, and maybe on separate OPC instance, unsure) //readOPCThread = new Thread(new ThreadStart(() => //{ // OPCReadValues = new OPCUtil(); // if (OPCReadValues.Connect()) // { // MessageBox.Show("Connected!"); // _eventAggregator.GetEvent<UpdatedSourceEvent>().Publish(new OPCObject("Set_Pt", newResult.ToString())); // } //})); //readOPCThread.Start(); //2-Get recipe segments that will be written onto the PLC(Need to access DB) and store as segment objects in list "Segments" using (OracleConnection connection = new OracleConnection(connectionString)) { //string queryString = String.Format("SELECT * FROM RECIPESEGMENT INNER JOIN segment ON RECIPESEGMENT.ID_segment = segment.id INNER JOIN recipe ON RECIPESEGMENT.ID_recipe = recipe.id where recipe.recipe_name = '{0}' order by segment.segment_number", RecipeName); string queryString = String.Format("SELECT * FROM SEGMENTS INNER JOIN RECIPES on SEGMENTS.ID_recipe = recipes.id where recipes.recipe_name = '{0}' order by segment_number", RecipeName); OracleCommand command = new OracleCommand(queryString, connection); connection.Open(); try { using (OracleDataReader reader = command.ExecuteReader()) { DataTable dataTable = new DataTable(); dataTable.Load(reader); for (int i = 0; i < dataTable.Rows.Count; ++i) { Segments.Add(new Segment_Details { ID = Convert.ToInt32(dataTable.Rows[i][0]), Segment_Number = dataTable.Rows[i][2].ToString(), RAMP_SP = dataTable.Rows[i][3].ToString(), MIN_RAMP = dataTable.Rows[i][4].ToString(), MAX_RAMP = dataTable.Rows[i][5].ToString(), SOAK_SP = dataTable.Rows[i][6].ToString(), MIN_SOAK = dataTable.Rows[i][7].ToString(), MAX_SOAK = dataTable.Rows[i][8].ToString(), SOAK_TIME = dataTable.Rows[i][9].ToString(), LOW_TEMP_MODE_SP = dataTable.Rows[i][10].ToString(), ALARM_TEMP_TH = dataTable.Rows[i][11].ToString(), LOW_TEMP_MODE_EN = Convert.ToChar(dataTable.Rows[i][12]), }); } //3-Update Running Segment fields NbSegments = Segments.Count().ToString(); CurrentRunningSegment = Segments[0]; RunningNb = CurrentRunningSegment.Segment_Number; RunningRemSegments = (Int32.Parse(NbSegments) - Int32.Parse(RunningNb)).ToString(); RunningRampHrUI = Segments[0].MAX_RAMP; RunningRampMinUI = Segments[0].MAX_RAMP; SetPt = Segments[0].RAMP_SP; RunningSoak = Segments[0].SOAK_TIME; RunningSegmentStatus purge = RunningSegmentStatus.Purge; RunningStatusUI = purge.Description(); SegmentSummaryStates testEnCours = SegmentSummaryStates.CycleEnCours; TitleMenuStatus = testEnCours.Description(); //4-Update Next Segment Fields NextNb = (Int32.Parse(RunningNb) + 1).ToString(); if (Segments.Count > 1) { NextRampHr = Segments[1].MAX_RAMP; NextRampMin = Segments[1].MIN_RAMP; NextSetPt = Segments[1].RAMP_SP; NextSoak = Segments[1].SOAK_SP; } else { RunningRemSegments = "0"; NextNb = "NULL"; NextRampHr = "NULL"; NextRampMin = "NULL"; NextSetPt = "NULL"; NextSoak = "NULL"; } } } catch (Exception Ex) { MessageBox.Show(Ex.Message); } finally { connection.Close(); } } }
public int Size() { return(Segments.Count()); }
public string ToString(int segment) { if (segment < 0 || segment >= Segments.Count()) { throw new ArgumentException("Invalid segment", "segment"); } StringBuilder ParamChain = new StringBuilder(); for (int i = 0; i < 66; i++) { if (i > 0) { ParamChain.Append("|"); } ParamChain.Append("{"); ParamChain.Append(i); ParamChain.Append("}"); } MediaEncoderDeshakerSegmentSettings s = Segments[segment]; return(string.Format(ParamChain.ToString(), Version, Pass, s.BlockSize, s.DifferentialSearchRange, SourcePixelAspectRatio, SourcePixelAspectSelection, DestinationPixelAspectValue, DestinationPixelAspectSelection, DestinationWidth, DestinationHeight, (int)s.Scale, (int)s.UsePixels, MotionSmoothPanX, MotionSmoothPanY, MotionSmoothRotation, MotionSmoothZoom, s.DiscardMotion, VideoOutput, (int)EdgeCompensation, Resampling, s.SkipBadFrame, s.InitialSearchRange, s.DiscardBadMotion, s.DiscardBadMotion2, LogFile, AppendToFile ? 1 : 0, s.IgnoreOutside ? 1 : 0, s.IgnoreOutsideLeft, s.IgnoreOutsideRight, s.IgnoreOutsideTop, s.IgnoreOutsideBottom, s.IgnoreInside ? 1 : 0, s.IgnoreInsideLeft, s.IgnoreInsideRight, s.IgnoreInsideTop, s.IgnoreInsideBottom, Interlaced ? 1 : 0, InterlacedUpperFieldFirst ? 1 : 0, ExtraZoomFactor, MaxPanX, MaxPanY, MaxRotation, MaxZoom, FillBordersWithPreviousFrames ? 1 : 0, FillBordersWithFutureFrames ? 1 : 0, FillBordersWithPreviousFramesCount, FillBordersWithFutureFramesCount, IgnoreOutsideLetAreaFollowMotion ? 1 : 0, s.DeepAnalysis, s.RollingShutter ? 1 : 0, GenerateInterlacedProgressiveVideo ? 1 : 0, UseSourceProperties ? 1 : 0, SoftBorders ? 1 : 0, ExtrapolateColorsIntoBorder ? 1 : 0, SoftBorderEdgeTransitionWidth, s.DiscardAbsoluteMotion, s.RememberDiscardedAreasToNextFrame ? 1 : 0, s.RollingShutterAmount, s.DetectRotation ? 1 : 0, s.DetectZoom ? 1 : 0, s.DetectScenesTreshold, AdaptiveZoomSmoothness, AdaptiveZoomAmount, s.DiscardMotionDiff, s.DetectScenes ? 1 : 0, UseColorMask ? 1 : 0, MaskColor)); }