Esempio n. 1
0
 public System.Collections.Generic.List <DataLogger.DataLog> GetEntries( )
 {
     MDG.DataLogger.DataLogEntities1 _Entity = new DataLogEntities1();
     try
     {
         return(_Entity.DataLogs.Where(x => x.ReadingDate.Day == DateTime.Now.Day).OrderByDescending(log => log.ReadingDate).ToList());
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         _Entity.Dispose();
     }
 }
Esempio n. 2
0
        public int ClearEntries( )
        {
            MDG.DataLogger.DataLogEntities1 _Entity = new DataLogEntities1( );
            try
            {
                int count = 0;
                foreach (var dataLog in _Entity.DataLogs)
                {
                    _Entity.DeleteObject(dataLog);
                    count++;
                }
                _Entity.SaveChanges();

                return(count);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _Entity.Dispose( );
            }
        }
Esempio n. 3
0
        private System.Collections.Generic.List <DataLogger.ModifiedDraftReading> GetFormatedEntries( )
        {
            MDG.DataLogger.DataLogEntities1 _Entity = new DataLogEntities1( );
            try
            {
                var query =
                    _Entity.DataLogs.Where(x => x.ReadingDate.Day == DateTime.Now.Day).OrderByDescending(
                        log => log.ReadingDate).OrderByDescending(logEntry => logEntry.ReadingDate);

                var formattedQuery =
                    from rawLogEntry in query.AsEnumerable()
                    select new ModifiedDraftReading()
                {
                    ReadingDate =
                        string.Format(
                            "{0} : {1} : {2}",
                            rawLogEntry.
                            ReadingDate
                            .Hour,
                            rawLogEntry.
                            ReadingDate
                            .Minute,
                            rawLogEntry.
                            ReadingDate
                            .Second),
                    DayNumber =
                        rawLogEntry.
                        DayNumber,
                    SternAngle =
                        rawLogEntry.
                        SternAngle.ToString
                            ("N2"),
                    SternWaterSideDaft = rawLogEntry.
                                         SternWaterSideDraft.ToFeetAndInches(),
                    SternDockSideDraft = rawLogEntry.SternDockSideDraft.ToFeetAndInches(),
                    BowAngle           =
                        rawLogEntry.
                        BowAngle.ToString(
                            "N2"),
                    BowWaterSideDraft = rawLogEntry.BowWaterSideDraft.ToFeetAndInches(),
                    BowDockSideDraft  = rawLogEntry.BowDockSideDraft.ToFeetAndInches(),
                    AverageDraft      = ((rawLogEntry.SternWaterSideDraft +
                                          rawLogEntry.SternDockSideDraft +
                                          rawLogEntry.BowWaterSideDraft +
                                          rawLogEntry.BowDockSideDraft) / 4).ToFeetAndInches(),
                    LightDraft =
                        rawLogEntry.
                        LightDraft,
                    HeavyDraft =
                        rawLogEntry.
                        HeavyDraft,
                    Depth1 = (float)rawLogEntry.Depth1,
                    Depth2 = (float)rawLogEntry.Depth2
                };
                return(formattedQuery.ToList());
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _Entity.Dispose( );
            }
        }
Esempio n. 4
0
        private void ProcessReadings(double[] registers)
        {
            WaterSideFreeboardForward = ScaleDepth(registers[3], _node2DepthCountsLow, _node2DepthCountsHigh,
                                                   _node2DepthActualLow, _node2DepthActualHigh) - _freeboardOffset;
            //Yellow Box

            WaterSideFreeboardAft = ScaleDepth(registers[0], _node1DepthCountsLow, _node1DepthCountsHigh,
                                               _node1DepthActualLow, _node1DepthActualHigh) - _freeboardOffset;
            //Black box



            RollAngleNode1 =
                (ScaleAngle(registers[1], _node1RollCountsLow, _node1RollCountsHigh, _node1RollActualLow,
                            _node1RollActualHigh) - (TareAngleStern));

            RollAngleNode1 = RollAngleNode1 * -1;

            RollAngleNode2 =
                (ScaleAngle(registers[4], _node2RollCountsLow, _node2RollCountsHigh, _node2RollActualLow,
                            _node2RollActualHigh) - (TareAngleBow));



            RollAngleNode2 = RollAngleNode2 * -1;

            DockSideFreeboardAft = WaterSideFreeboardAft +
                                   CalculateStroke(WaterSideFreeboardAft, RollAngleNode1, BargeWidth * 12);

            DockSideFreeboardForward = WaterSideFreeboardForward +
                                       CalculateStroke(WaterSideFreeboardForward, RollAngleNode2, BargeWidth * 12);

            double avgDraft = (BargeDepth * 12) - CalculateAverageFreeboard();

            HeavyDraftTonnage = TonsPerInch * (avgDraft);
            Payload           = Math.Round((HeavyDraftTonnage - LightDraftTonnage), 0);

            if (_logReadings)
            {
                MDG.DataLogger.DataLogEntities1 logger = null;
                try
                {
                    logger = new DataLogEntities1();

                    DataLog newLogEntry = new DataLog()
                    {
                        ReadingDate         = DateTime.Now,
                        SternAngle          = RollAngleNode1,
                        SternWaterSideDraft = (BargeDepth * 12) - WaterSideFreeboardAft,
                        SternDockSideDraft  = (BargeDepth * 12) - DockSideFreeboardAft,
                        BowAngle            = RollAngleNode2,
                        BowDockSideDraft    = (BargeDepth * 12) - DockSideFreeboardForward,
                        BowWaterSideDraft   = (BargeDepth * 12) - WaterSideFreeboardForward,
                        LightDraft          = LightDraft,
                        HeavyDraft          = HeavyDraft,
                        DayNumber           = logCount++,
                        Depth1 = registers[3],
                        Depth2 = registers[0]
                    };
                    logger.AddToDataLogs(newLogEntry);
                    logger.SaveChanges();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    if (logger != null)
                    {
                        logger.Dispose();
                    }
                }
            }
        }