//
// HostIOReading.cs
//
// Author:
//       Carsten Sonne Larsen <cs@innolan.dk>
//
// Copyright (c) 2013-2016 Carsten Sonne Larsen
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

using System;

namespace Ntp.Analyzer.Objects
{
    public sealed class HostIoReading : Reading
    {
        public HostIoReading(
            int id,
            DateTime time,
            Host host,
            int timeSinceReset,
            int receiveBuffers,
            int freeReceiveBuffers,
            int usedReceiveBuffers,
            int lowWaterRefills,
            int droppedPackets,
            int ignoredPackets,
            int receivedPackets,
            int packetsSent,
            int packetsNotSent,
            int interruptsHandled,
            int receivedByInt)
            : base(id, time, host, null)
        {
            this.timeSinceReset = timeSinceReset;
            this.receiveBuffers = ReceiveBuffers;
            this.freeReceiveBuffers = freeReceiveBuffers;
            this.usedReceiveBuffers = usedReceiveBuffers;
            this.lowWaterRefills = lowWaterRefills;
            this.droppedPackets = droppedPackets;
            this.ignoredPackets = ignoredPackets;
            this.receivedPackets = receivedPackets;
            this.packetsSent = packetsSent;
            this.packetsNotSent = packetsNotSent;
            this.interruptsHandled = interruptsHandled;
            this.receivedByInt = receivedByInt;
        }

        public HostIoReading(
            Host host,
            IoStatsEntry entry,
            ReadingBulk bulk
            )
            : base(host, bulk)
        {
            timeSinceReset = entry.TimeSinceReset;
            receiveBuffers = entry.ReceiveBuffers;
            freeReceiveBuffers = entry.FreeReceiveBuffers;
            usedReceiveBuffers = entry.UsedReceiveBuffers;
            lowWaterRefills = entry.LowWaterRefills;
            droppedPackets = entry.DroppedPackets;
            ignoredPackets = entry.IgnoredPackets;
            receivedPackets = entry.ReceivedPackets;
            packetsSent = entry.PacketsSent;
            packetsNotSent = entry.PacketsNotSent;
            interruptsHandled = entry.InterruptsHandled;
            receivedByInt = entry.ReceivedByInt;
        }

        private readonly int droppedPackets;
        private readonly int freeReceiveBuffers;
        private readonly int ignoredPackets;
        private readonly int interruptsHandled;
        private readonly int lowWaterRefills;
        private readonly int packetsNotSent;
        private readonly int packetsSent;
        private readonly int receiveBuffers;
        private readonly int receivedByInt;
        private readonly int receivedPackets;
        private readonly int timeSinceReset;
        private readonly int usedReceiveBuffers;

        public int TimeSinceReset
        {
            get { return timeSinceReset; }
        }

        public int ReceiveBuffers
        {
            get { return receiveBuffers; }
        }

        public int FreeReceiveBuffers
        {
            get { return freeReceiveBuffers; }
        }

        public int UsedReceiveBuffers
        {
            get { return usedReceiveBuffers; }
        }

        public int LowWaterRefills
        {
            get { return lowWaterRefills; }
        }

        public int DroppedPackets
        {
            get { return droppedPackets; }
        }

        public int IgnoredPackets
        {
            get { return ignoredPackets; }
        }

        public int ReceivedPackets
        {
            get { return receivedPackets; }
        }

        public int PacketsSent
        {
            get { return packetsSent; }
        }

        public int PacketsNotSent
        {
            get { return packetsNotSent; }
        }

        public int InterruptsHandled
        {
            get { return interruptsHandled; }
        }

        public int ReceivedByInt
        {
            get { return receivedByInt; }
        }
    }
}