//
// BwgBurn - CD-R/CD-RW/DVD-R/DVD-RW burning program for DotNet
//
// Copyright (C) 2006 by Jack W. Griffin (butchg@comcast.net)
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the
//
// Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330,
// Boston, MA 02111-1307 USA
//
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace Bwg.Scsi
{
///
/// This class contains information about event status communicated from the device
/// via the GetEventStatusNotification SCSI command.
///
public class EventStatusNotification : Result
{
#region public types
///
/// This field indicates the type of event
///
public enum EventType
{
///
/// No event was returned
///
NoEvent = 0x00,
///
/// There was an operation change
///
OperationalChange = 0x01,
///
/// There was a change in power management status
///
PowerManagement = 0x02,
///
/// There was an external request to the device
///
ExternalRequest = 0x03,
///
/// The status of the media has changed
///
Media = 0x04,
///
/// There was a change in the multiple initiator device
///
MultipleInitiator = 0x05,
///
/// There was a change in the busy state of the device
///
DeviceBusy = 0x06,
///
/// This value is reserved and should not be returned
///
Reserved = 0x07,
} ;
#endregion
#region public member variables
///
/// This property returns true if an event is available
///
public readonly bool EventAvailable;
///
/// This property is a byte that contains a mask of the supported event classes
///
public readonly byte SupportedEventClasses;
///
/// This property contains the notification class of the specific event that has
/// occurred.
///
public readonly EventType NotificationClass;
///
/// This array contains the specific data returned describing the event. The format of this
/// data is described in the SCSI-3 MMC specification.
///
public readonly byte [] EventData;
#endregion
#region constructor
///
/// This is the contructor for this class which contains information about any events that
/// have occurred in the SCSI device.
///
/// Pointer to a memory area containing the reply from the SCSI device
/// The size of the memory area containing the reply from the SCSI device
public EventStatusNotification(IntPtr buffer, int size) : base(buffer, size)
{
SupportedEventClasses = Marshal.ReadByte(buffer, 3);
byte b = Marshal.ReadByte(buffer, 2);
if ((b & 0x80) != 0)
{
EventAvailable = false;
}
else
{
ushort len = Get16(0);
EventAvailable = true;
NotificationClass = (EventType)(b & 0x03);
EventData = new byte[len];
for (int i = 0; i < len; i++)
EventData[i] = Marshal.ReadByte(buffer, 4 + i);
}
}
#endregion
#region public properties
///
/// This property returns true if Operational Events are supported on this device
///
public bool OperationalChangeEventsSupported { get { return (SupportedEventClasses & 0x02) != 0; } }
///
/// This property returns true if Power Management Events are supported on this device
///
public bool PowerManagementEventsSupported { get { return (SupportedEventClasses & 0x04) != 0; } }
///
/// This property returns true if External Request Events are supported on this device
///
public bool ExternalRequestEventsSupported { get { return (SupportedEventClasses & 0x08) != 0; } }
///
/// This property returns true if Media Events are supported on this device
///
public bool MediaEventsSupported { get { return (SupportedEventClasses & 0x10) != 0; } }
///
/// This property returns true if Multiple Initiator Events are supported on this device
///
public bool MultiInitiatorEventsSupported { get { return (SupportedEventClasses & 0x20) != 0; } }
///
/// This property returns true if Device Busy Events are supported on this device
///
public bool DeviceBusyEventsSupported { get { return (SupportedEventClasses & 0x40) != 0; } }
#endregion
}
}