Exemple #1
0
        public void putImage(int x, int y, int zoom, Modes mode, Bitmap img)
        {
            int older = 0, i;
            bool encontrado = false;
            try
            {
                if (img != null && img.Height * img.Width > 0)
                {
                    for (i = 0; i < cacheSize && !encontrado; i++)
                    {
                        if (cachelastaccess[i] < cachelastaccess[older])
                            older = i;
                        if (cacheQuery[i].x == x && cacheQuery[i].y == y && cacheQuery[i].zoom == zoom && cacheQuery[i].mode.Equals(mode))
                        {
                            cachelastaccess[i] = cachetimer;
                            cacheImage[i] = img;
                            encontrado = true;
                        }
                    }

                    if (!encontrado)
                    {
                        cacheImage[older] = img;
                        cachelastaccess[older] = cachetimer;

                        cacheQuery[older].x = x;
                        cacheQuery[older].y = y;
                        cacheQuery[older].zoom = zoom;
                        cacheQuery[older].mode = mode;
                    }
                }
            }
            catch (Exception) { Console.WriteLine("Rafa"); }
        }
Exemple #2
0
 public HardMode(Modes mode, Random rnd, City[] cities)
 {
     this.mode = mode;
     this.rnd = rnd;
     this.cities = cities;
     this.removedEdges = new HashSet<Edge>();
 }
        private static void ReadArguments(string[] args)
        {
            if (args.Length >= 3 && args[0] == "refill")
              {
            _mode = Modes.Refill;
            _refillName = args[1];
            _refillAmount = args[2];
              }
              else if (args.Length > 0 && args[0] == "spend")
              {
            _mode = Modes.Spend;
              }
              else
              {
            Console.Error.WriteLine(@"Usage:
            refill <name> <amount>
            Reader will save name and amount to any cards inserted.

            spend
            Once a card is inserted, ""<name>/<amount>"" is sent to stdout.
            The reader waits for a line on stdin - if this line has the form ""charge/<amount>"", the amount is charged from the card.
            No validation is performed; this must be done on the client side.");

            Environment.Exit(2);
              }
        }
Exemple #4
0
        protected override string getInternetURL(int x, int y, int zoom, Modes mode, int server_balance)
        {
            string url;
            int max = 1 << zoom;

            switch (mode)
            {
                case Modes.MAP: // Microsoft MAP http://r2.ortho.tiles.virtualearth.net/tiles/r033110?g=81&shading=hill
                    url = "http://r"+server_balance+".ortho.tiles.virtualearth.net/tiles/r";
                    url += Pos2StrMicrosoft(x, y, zoom) + ".png?g=81&shading=hill";
                    break;
                case Modes.SAT: // Microsoft SAT http://a2.ortho.tiles.virtualearth.net/tiles/a0.jpeg?g=81
                    url = "http://a" + server_balance + ".ortho.tiles.virtualearth.net/tiles/a";
                    url += Pos2StrMicrosoft(x, y, zoom) + ".jpeg?g=81";
                    break;
                case Modes.MAP_SAT: // Microsoft MAP+OVL! http://h2.ortho.tiles.virtualearth.net/tiles/h0.jpeg?g=81
                    url = "http://h" + server_balance + ".ortho.tiles.virtualearth.net/tiles/h";
                    url += Pos2StrMicrosoft(x, y, zoom) + ".jpeg?g=81";
                    break;
                default:
                    url = "";
                    break;
            }


            return url;

        }
Exemple #5
0
 public ImageQuery(int x, int y, int zoom, Modes mode)
 {
     this.x = x;
     this.y = y;
     this.zoom = zoom;
     this.mode = mode;
 }
Exemple #6
0
        public Editor(Viewport view, ContentManager content, int screenWidth, int screenHeight)
        {
            mode = Modes.View;

            currentLevel = new Level(new Vector2(100, 100), "");
            currentLevel.populateWithGrid(content);

            Width = 32 * 100;
            Height = 32 * 100;

            EditorCamera = new EditorCamera(view, Width, Height, 1.0f);

            Margin = 2;     // MAGIC NUMBERS YAY
            Layer = 2;

            initDialogBoxes(content, screenWidth, screenHeight);

            CursorPosition = Vector2.Zero;

            TileText = new InfoText(content, "Tilesheet", new Vector2(370, -315));  // again, MAGIC NUMBERS!

            SelectedTile = null;

            HelpDiag = false;
        }
        private static Modes GetModeChanges(string[] parameterWords)
        {
            var modes = new Modes();
            var modeWord = parameterWords[0];

            var currentModifier = modeWord[0];

            for (var i = 1; i < modeWord.Length; i++)
            {
                if (modeWord[i] == '+' || modeWord[i] == '-')
                {
                    if (modeWord[i] != currentModifier)
                    {
                        currentModifier = modeWord[i];
                    }
                }

                else
                {
                    var isOn = currentModifier == '+';
                    var mode = new Mode() { Identifier = modeWord[i].ToString(), IsOn = isOn };
                    modes.Add(mode);
                }
            }
            return modes;
        }
Exemple #8
0
        /**
         * Constructor.
         */
        public Streaming()
        {
            log.Trace("Creating streaming server");
            this.livePublishingPoint = null;
            this.onDemandPublishingPoint = null;
            this.onDemandState = State.Stopped;
            this.liveState = State.Stopped;
            this.mode = Modes.None;

            this.wmServer = new WMSServerClass();

            // Remove existing publishing points
            for (int i = 0; i < this.wmServer.PublishingPoints.length; ++i)
            {
                log.Trace("Existing publishing points = " + this.wmServer.PublishingPoints.length);
                if (this.wmServer.PublishingPoints[i].Type == WMS_PUBLISHING_POINT_TYPE.WMS_PUBLISHING_POINT_TYPE_BROADCAST ||
                    this.wmServer.PublishingPoints[i].Type == WMS_PUBLISHING_POINT_TYPE.WMS_PUBLISHING_POINT_TYPE_ON_DEMAND)
                {
                    try
                    {
                        this.wmServer.PublishingPoints.Remove(i);
                        i--;
                    }
                    catch (Exception e)
                    {
                        log.ErrorException("Exception raised while removing publishing point: " + e.Message, e);
                    }
                }
            }
        }
Exemple #9
0
        private void Configure()
        {
            var validLabels = new Regex("^(data|css):");

            if (validLabels.IsMatch(Parameters[0]))
            {
                string[] subParm = Parameters[0].Split(':');
                string methodName = subParm[0];

                if (methodName == "data")
                {
                    Mode = Modes.Data;
                }
                else if (methodName == "css")
                {
                    Mode = Modes.Css;
                }
                else
                {
                    throw new ArgumentException("Unknown mode for regex pseudoselector.");
                }
                Property = subParm[1];
            }
            else
            {
                Mode = Modes.Attr;
                Property = Parameters[0];
            }

            // The expression trims whitespace the same way as the original
            // Trim() would work just as well but left this way to demonstrate
            // the CsQuery "RegexReplace" extension method

            Expression = new Regex(Parameters[1].RegexReplace(@"^\s+|\s+$", ""), RegexOptions.IgnoreCase | RegexOptions.Multiline);
        }
Exemple #10
0
 public bool hasMode(Modes m)
 {
     Modes[] modos = getModes();
     for (int i = 0; i < modos.Length; i++)
         if (modos[i] == m)
             return true;
     return false;
 }
        public EbayBaseRepository(IUnitOfWork context, Modes mode, SiteCodeType siteCode)
            : base(context)
        {
            if (context == null) { throw new NotImplementedException("IUnitOfWork"); }

            _mode = mode;
            _siteCode = siteCode;
        }
 /// <summary>
 /// value is relative to unit's position
 /// </summary>
 /// <param name="RelativeUnit">unit to be used as a pivot</param>
 /// <param name="Angle">angle between pivot.forward and direction from pivot to this vector</param>
 /// <param name="Dist">dist from pivot to this vector</param>
 public RelativeVector(IUnit RelativeUnit, float Angle, float Dist)
 {
     relativeUnit1 = RelativeUnit;
     dist = Dist;
     angle = Angle;
     rotationOnAngle = Matrix.CreateRotation(angle);
     mode = Modes.UnitsSideAndDist;
 }
 public void RequestModeChange(Modes requestedMode, IView viewRegisterRequest)
 {
     if (this.registeredViews != null && this.registeredViews.Contains(viewRegisterRequest))
     {
         modeChangeRequest = true;
         modeRequested = requestedMode;
     }
 }
Exemple #14
0
 private void NotificationBattle(Modes.BattleResult battleResult)
 {
     AMing.Plugins.Core.GenericMessager.Current.SendToNotification(new Plugins.Core.Models.MessageItem
     {
         Title = string.Format("战斗结束  {0}", battleResult.WinRank),
         Content = battleResult.GetShip == null ? "没有捞到船" : string.Format("捕获到野生的 {0}", battleResult.GetShip.Name)
     });
 }
Exemple #15
0
 public ScriptEngine()
 {
     _inDo = false;
     _mode = Modes.Simple;
     ExecutionMode = ExecutionModes.Normal;
     CurrentScript = new Script();
     CurrentDecision = new DecisionOrList();
 }
        // Start the specified game mode
        public void StartMode(Modes.Mode mode)
        {
            m_CurrentMode = mode;

            GridMainMenu.Visibility = Visibility.Collapsed;
            GridGameScreen.Visibility = Visibility.Visible;

            mode.StartMode();
        }
Exemple #17
0
 // -----------------------------------------------------
 // switch camera
 private void ChangeCam()
 {
     if(currentCam != Modes.mAligned){ // if different than last one
         currentCam++;
     }
     else{
         currentCam = 0;
     }
 }
        // Constructor
        public AzureFileSystem(String userName, String password, String containerName, Modes mode)
        {
            _userName = userName;
            _password = password;

            // Set container name (if none specified, specify the development container default)
            _containerName = !String.IsNullOrEmpty(containerName) ? containerName : "DevelopmentContainer";
            _provider = new AzureBlobStorageProvider(containerName);
        }
	public override void OnInspectorGUI()
	{
		HouseController hc = (HouseController) target;
		DrawDefaultInspector();
		GUILayout.Label("Cells: "+hc.EditorGetCellCount());
		GUILayout.Label("House price: "+hc.EditorGetCellCount()*hc.LevelConditions.PricePerCell);

		if(GUILayout.Button(state!=Modes.Idle? "Disable editor": "Enable editor"))
		{
			if(state!=Modes.Idle)
				state = Modes.Idle;
			else
			{
				state = Modes.PlaceCell;

				hc.EditorCheckCells();
			}	
		}

		if(state!=Modes.Idle)
		{
			GUILayout.Label("Current mode: "+System.Enum.GetName(typeof(Modes),state));

			if(GUILayout.Button("Place cells"))
			{
				state = Modes.PlaceCell;
			}
			if(GUILayout.Button("Delete cell"))
			{
				state = Modes.RemoveCell;
			}
			if(GUILayout.Button("Place thick walls"))
			{
				state = Modes.PlaceThickWall;
			}
			if(GUILayout.Button("Place windows"))
			{
				state = Modes.PlaceWindow;
			}
			if(GUILayout.Button("Place entrance"))
			{
				state = Modes.PlaceEntrance;
			}
			if(GUILayout.Button("Place garage"))
			{
				state = Modes.PlaceGarage;
			}
			if(GUILayout.Button("Clear Level"))
			{

				if(EditorUtility.DisplayDialog("Clear Level?","Everything will be removed (no undo)","Ok","Cancel"))
					hc.EditorRemoveAll();
			}

		}
	}
 public static void SubtractModeQuantitie(Modes  mode)
 {
     ModesQuantities[mode]--;
     PlayerData dt = ScoreModule.GetPlayerData();
     if (dt != null)
     {
         dt.PlayerModes = ModesQuantities;
         ScoreModule.SavePlayerData(dt);
     }
 }
	// Update is called once per frame
	void Update () {
		if(state==Modes.Moving)
		{
			transform.position = Vector3.MoveTowards(transform.position,newTargetPos,
			                                         moveSpeed*Time.smoothDeltaTime);
			if(transform.position==newTargetPos)
				state = Modes.Idle;
		}

	}
        //классификация цели
        public void Classification(Target target)
        {
            //по результатам классификации,
            //targ.SetNotTrue(); //если цель настоящая, или
            // targ.isTrue = false; //если цель ложная

            if (target.isTrue = false)    //проверка на истинность по итогам классификации
            {                           //если цель ложная, то
                mode_ = Modes.AS;  //переход в режим ПДО
            }
        }
        private static Modes CombineModeChangesToUserNames(Modes modeChanges, List<string> userNames)
        {
            var modifiedModeChanges = modeChanges;

            for (var i = 0; i < modifiedModeChanges.Count; i++)
            {
                modifiedModeChanges[i].UserName = userNames[i];
            }

            return modifiedModeChanges;
        }
        public override void Calculate()
        {
            if (mode == Modes.Flying)
            {
                if (X > Game1.SWidth / 2 - 100)
                {
                    X -= rand.Next(4, 9);
                    pos = new Vector2(X,Y);
                }
                else
                {
                    Speed = 10;
                    mode = Modes.Atacking;
                    TargetX = GameController.Player.X + GameController.Player.Width/2;
                    TargetY = GameController.Player.Y + GameController.Player.Height/2;
                    pos = new Vector2(X,Y);
                    dest = new Vector2(TargetX, TargetY);
                }
                if (Y < Game1.TopLimit) Y = Game1.TopLimit;
                if (Y > Game1.BLimit - Height) Y = Game1.BLimit - Height;

                if (GameController.Player.Y + GameController.Player.Height > Y && GameController.Player.Y < Y + Height)
                {
                    if ((DateTime.Now - LastShoot).TotalMilliseconds > 1500)
                    {
                        WeaponList.Add(new EBullet(X, Y + Width / 2, 10));
                        LastShoot = DateTime.Now;
                    }
                }
            }
            else
            {
                if (Math.Abs(X - TargetX) < 6 && Math.Abs(Y - TargetY) < 6)
                {

                    TargetX = GameController.Player.X + GameController.Player.Width / 2;
                    TargetY = GameController.Player.Y + GameController.Player.Height / 2;

                    dest = new Vector2(TargetX, TargetY);
                }

                dir = dest - pos;
                dir.Normalize();

                pos += dir * Speed;
                X = (int)pos.X;
                Y = (int)pos.Y;
                Angle = ((float)Math.Atan2(
                     (double)dir.Y,
                     (double)dir.X));
            }
        }
Exemple #25
0
    public CFController(Modes modes)
    {
        if ((modes & Modes.ANGLE_MODE)!=0)
        {
        }

        roll = new CtrlChannel(4500, 5000, 5, 0.0f, 0.5f, 0.0f, 0f);
        pitch = new CtrlChannel(4500, 5000, 5, 0.0f, 0.5f, 0.0f, 0f);
        yaw = new CtrlChannel(4500, 5000, 5, 2.0f, 1.0f, 0.0f, 0.0f);

        armed = true;
        contCyclesBeforeArmUnarm = 0;
    }
        public LongPollServerRequest(string server, string key, Int64 ts, Modes mode,
            Action<UpdatesResponse> successHandler, Action<int> failHandler)
        {
            if (string.IsNullOrEmpty(server) || string.IsNullOrEmpty(key) || ts <= 0)
                Debug.Assert(false);

            _server = server;
            _key = key;
            _ts = ts;
            _mode = mode;
            _successHandler = successHandler;
            _failHandler = failHandler;
        }
 public void ChangeActiveMode(Modes newMode, IViewController updater)
 {
     //Set the modes status to Requested;
     if (this.registeredControllers.Contains(updater))
     {
         this.ActiveMode = newMode;
         this.Status = ExecutionStatus.Requested;
     }
     else
     {
         throw new UICtrlNotRegisteredException("UI controller " + updater.ToString() +" not registerd");
     }
 }
Exemple #28
0
        public Bitmap getImage(int x, int y, int zoom, Modes mode)
        {
            int i;
            cachetimer++;

            for (i = 0; i < cacheSize; i++)
                if (cacheQuery[i].x == x && cacheQuery[i].y == y && cacheQuery[i].zoom == zoom && cacheQuery[i].mode.Equals(mode))
                {
                    cachelastaccess[i] = cachetimer;
                    return cacheImage[i];
                }
            return null;
        }
        private static Modes CombineModeChangesToChannel(Modes modeChanges, string message)
        {
            var modifiedModeChanges = modeChanges;

            var channel = message.GetIrcChannel();

            for (var i = 0; i < modifiedModeChanges.Count; i++)
            {
                modifiedModeChanges[i].UserName = channel.Name;
            }

            return modifiedModeChanges;
        }
 /// <param name="appid">Application ID</param>
 /// <param name="devid"> DevID</param>
 /// <param name="authCert"> CertID</param>
 /// <param name="token">Access token</param>
 /// <param name="runname">App Name</param>
 /// <param name="sandboxToken">Sandbox Token</param>
 /// <param name="mode">Live/Test Environment</param>
 /// <param name="siteCode">Site code for ebay</param>
 public EbayProperties(string appid, string devid, string authCert, string token, 
     string runname, string sandboxToken, Modes mode, SiteCodeType siteCode)
 {
     SiteId = siteCode;
     AppId = appid;
     DevId = devid;
     AuthCert = authCert;
     Token = token;
     RunName = runname;
     SandboxToken = sandboxToken;
     Mode = mode;
     WarningLevel = WarningLevelCodeType.Low;
     EntriesPerRequest = 200;
 }
        public static void PrintImageInfo(IMediaImage imageFormat)
        {
            DicConsole.WriteLine("Image information:");
            if (!string.IsNullOrWhiteSpace(imageFormat.Info.Version))
            {
                DicConsole.WriteLine("Format: {0} version {1}", imageFormat.Format, imageFormat.Info.Version);
            }
            else
            {
                DicConsole.WriteLine("Format: {0}", imageFormat.Format);
            }
            if (!string.IsNullOrWhiteSpace(imageFormat.Info.Application) &&
                !string.IsNullOrWhiteSpace(imageFormat.Info.ApplicationVersion))
            {
                DicConsole.WriteLine("Was created with {0} version {1}", imageFormat.Info.Application,
                                     imageFormat.Info.ApplicationVersion);
            }
            else if (!string.IsNullOrWhiteSpace(imageFormat.Info.Application))
            {
                DicConsole.WriteLine("Was created with {0}", imageFormat.Info.Application);
            }
            DicConsole.WriteLine("Image without headers is {0} bytes long", imageFormat.Info.ImageSize);
            DicConsole.WriteLine("Contains a media of {0} sectors with a maximum sector size of {1} bytes (if all sectors are of the same size this would be {2} bytes)",
                                 imageFormat.Info.Sectors, imageFormat.Info.SectorSize,
                                 imageFormat.Info.Sectors * imageFormat.Info.SectorSize);
            if (!string.IsNullOrWhiteSpace(imageFormat.Info.Creator))
            {
                DicConsole.WriteLine("Created by: {0}", imageFormat.Info.Creator);
            }
            if (imageFormat.Info.CreationTime != DateTime.MinValue)
            {
                DicConsole.WriteLine("Created on {0}", imageFormat.Info.CreationTime);
            }
            if (imageFormat.Info.LastModificationTime != DateTime.MinValue)
            {
                DicConsole.WriteLine("Last modified on {0}", imageFormat.Info.LastModificationTime);
            }
            DicConsole.WriteLine("Contains a media of type {0} and XML type {1}", imageFormat.Info.MediaType,
                                 imageFormat.Info.XmlMediaType);
            DicConsole.WriteLine("{0} partitions", imageFormat.Info.HasPartitions ? "Has" : "Doesn't have");
            DicConsole.WriteLine("{0} sessions", imageFormat.Info.HasSessions ? "Has" : "Doesn't have");
            if (!string.IsNullOrWhiteSpace(imageFormat.Info.Comments))
            {
                DicConsole.WriteLine("Comments: {0}", imageFormat.Info.Comments);
            }
            if (imageFormat.Info.MediaSequence != 0 && imageFormat.Info.LastMediaSequence != 0)
            {
                DicConsole.WriteLine("Media is number {0} on a set of {1} medias", imageFormat.Info.MediaSequence,
                                     imageFormat.Info.LastMediaSequence);
            }
            if (!string.IsNullOrWhiteSpace(imageFormat.Info.MediaTitle))
            {
                DicConsole.WriteLine("Media title: {0}", imageFormat.Info.MediaTitle);
            }
            if (!string.IsNullOrWhiteSpace(imageFormat.Info.MediaManufacturer))
            {
                DicConsole.WriteLine("Media manufacturer: {0}", imageFormat.Info.MediaManufacturer);
            }
            if (!string.IsNullOrWhiteSpace(imageFormat.Info.MediaModel))
            {
                DicConsole.WriteLine("Media model: {0}", imageFormat.Info.MediaModel);
            }
            if (!string.IsNullOrWhiteSpace(imageFormat.Info.MediaSerialNumber))
            {
                DicConsole.WriteLine("Media serial number: {0}", imageFormat.Info.MediaSerialNumber);
            }
            if (!string.IsNullOrWhiteSpace(imageFormat.Info.MediaBarcode))
            {
                DicConsole.WriteLine("Media barcode: {0}", imageFormat.Info.MediaBarcode);
            }
            if (!string.IsNullOrWhiteSpace(imageFormat.Info.MediaPartNumber))
            {
                DicConsole.WriteLine("Media part number: {0}", imageFormat.Info.MediaPartNumber);
            }
            if (!string.IsNullOrWhiteSpace(imageFormat.Info.DriveManufacturer))
            {
                DicConsole.WriteLine("Drive manufacturer: {0}", imageFormat.Info.DriveManufacturer);
            }
            if (!string.IsNullOrWhiteSpace(imageFormat.Info.DriveModel))
            {
                DicConsole.WriteLine("Drive model: {0}", imageFormat.Info.DriveModel);
            }
            if (!string.IsNullOrWhiteSpace(imageFormat.Info.DriveSerialNumber))
            {
                DicConsole.WriteLine("Drive serial number: {0}", imageFormat.Info.DriveSerialNumber);
            }
            if (!string.IsNullOrWhiteSpace(imageFormat.Info.DriveFirmwareRevision))
            {
                DicConsole.WriteLine("Drive firmware info: {0}", imageFormat.Info.DriveFirmwareRevision);
            }
            if (imageFormat.Info.Cylinders > 0 && imageFormat.Info.Heads > 0 &&
                imageFormat.Info.SectorsPerTrack > 0 &&
                imageFormat.Info.XmlMediaType != XmlMediaType.OpticalDisc &&
                (!(imageFormat is ITapeImage tapeImage) || !tapeImage.IsTape))
            {
                DicConsole.WriteLine("Media geometry: {0} cylinders, {1} heads, {2} sectors per track",
                                     imageFormat.Info.Cylinders, imageFormat.Info.Heads,
                                     imageFormat.Info.SectorsPerTrack);
            }

            if (imageFormat.Info.ReadableMediaTags != null && imageFormat.Info.ReadableMediaTags.Count > 0)
            {
                DicConsole.WriteLine("Contains {0} readable media tags:", imageFormat.Info.ReadableMediaTags.Count);
                foreach (MediaTagType tag in imageFormat.Info.ReadableMediaTags.OrderBy(t => t))
                {
                    DicConsole.Write("{0} ", tag);
                }
                DicConsole.WriteLine();
            }

            if (imageFormat.Info.ReadableSectorTags != null && imageFormat.Info.ReadableSectorTags.Count > 0)
            {
                DicConsole.WriteLine("Contains {0} readable sector tags:", imageFormat.Info.ReadableSectorTags.Count);
                foreach (SectorTagType tag in imageFormat.Info.ReadableSectorTags.OrderBy(t => t))
                {
                    DicConsole.Write("{0} ", tag);
                }
                DicConsole.WriteLine();
            }

            DicConsole.WriteLine();
            PeripheralDeviceTypes scsiDeviceType = PeripheralDeviceTypes.DirectAccess;

            byte[] scsiVendorId = null;

            if (imageFormat.Info.ReadableMediaTags != null &&
                imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.SCSI_INQUIRY))
            {
                byte[] inquiry = imageFormat.ReadDiskTag(MediaTagType.SCSI_INQUIRY);

                scsiDeviceType = (PeripheralDeviceTypes)(inquiry[0] & 0x1F);
                if (inquiry.Length >= 16)
                {
                    scsiVendorId = new byte[8];
                    Array.Copy(inquiry, 8, scsiVendorId, 0, 8);
                }

                DicConsole.WriteLine("SCSI INQUIRY contained in image:");
                DicConsole.Write("{0}", Inquiry.Prettify(inquiry));
                DicConsole.WriteLine();
            }

            if (imageFormat.Info.ReadableMediaTags != null &&
                imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.ATA_IDENTIFY))
            {
                byte[] identify = imageFormat.ReadDiskTag(MediaTagType.ATA_IDENTIFY);

                DicConsole.WriteLine("ATA IDENTIFY contained in image:");
                DicConsole.Write("{0}", Identify.Prettify(identify));
                DicConsole.WriteLine();
            }

            if (imageFormat.Info.ReadableMediaTags != null &&
                imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.ATAPI_IDENTIFY))
            {
                byte[] identify = imageFormat.ReadDiskTag(MediaTagType.ATAPI_IDENTIFY);

                DicConsole.WriteLine("ATAPI IDENTIFY contained in image:");
                DicConsole.Write("{0}", Identify.Prettify(identify));
                DicConsole.WriteLine();
            }

            if (imageFormat.Info.ReadableMediaTags != null &&
                imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.SCSI_MODESENSE_10))
            {
                byte[]            modeSense10 = imageFormat.ReadDiskTag(MediaTagType.SCSI_MODESENSE_10);
                Modes.DecodedMode?decMode     = Modes.DecodeMode10(modeSense10, scsiDeviceType);

                if (decMode.HasValue)
                {
                    DicConsole.WriteLine("SCSI MODE SENSE (10) contained in image:");
                    PrintScsiModePages.Print(decMode.Value, scsiDeviceType, scsiVendorId);
                    DicConsole.WriteLine();
                }
            }
            else if (imageFormat.Info.ReadableMediaTags != null &&
                     imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.SCSI_MODESENSE_6))
            {
                byte[]            modeSense6 = imageFormat.ReadDiskTag(MediaTagType.SCSI_MODESENSE_6);
                Modes.DecodedMode?decMode    = Modes.DecodeMode6(modeSense6, scsiDeviceType);

                if (decMode.HasValue)
                {
                    DicConsole.WriteLine("SCSI MODE SENSE (6) contained in image:");
                    PrintScsiModePages.Print(decMode.Value, scsiDeviceType, scsiVendorId);
                    DicConsole.WriteLine();
                }
            }
            else if (imageFormat.Info.ReadableMediaTags != null &&
                     imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.SCSI_MODEPAGE_2A))
            {
                byte[] mode2A = imageFormat.ReadDiskTag(MediaTagType.SCSI_MODEPAGE_2A);

                DicConsole.Write("{0}", Modes.PrettifyModePage_2A(mode2A));
                DicConsole.WriteLine();
            }

            if (imageFormat.Info.ReadableMediaTags != null &&
                imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.CD_FullTOC))
            {
                byte[] toc = imageFormat.ReadDiskTag(MediaTagType.CD_FullTOC);

                if (toc.Length > 0)
                {
                    ushort dataLen = Swapping.Swap(BitConverter.ToUInt16(toc, 0));
                    if (dataLen + 2 != toc.Length)
                    {
                        byte[] tmp = new byte[toc.Length + 2];
                        Array.Copy(toc, 0, tmp, 2, toc.Length);
                        tmp[0] = (byte)((toc.Length & 0xFF00) >> 8);
                        tmp[1] = (byte)(toc.Length & 0xFF);
                        toc    = tmp;
                    }

                    DicConsole.WriteLine("CompactDisc Table of Contents contained in image:");
                    DicConsole.Write("{0}", FullTOC.Prettify(toc));
                    DicConsole.WriteLine();
                }
            }

            if (imageFormat.Info.ReadableMediaTags != null &&
                imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.CD_PMA))
            {
                byte[] pma = imageFormat.ReadDiskTag(MediaTagType.CD_PMA);

                if (pma.Length > 0)
                {
                    ushort dataLen = Swapping.Swap(BitConverter.ToUInt16(pma, 0));
                    if (dataLen + 2 != pma.Length)
                    {
                        byte[] tmp = new byte[pma.Length + 2];
                        Array.Copy(pma, 0, tmp, 2, pma.Length);
                        tmp[0] = (byte)((pma.Length & 0xFF00) >> 8);
                        tmp[1] = (byte)(pma.Length & 0xFF);
                        pma    = tmp;
                    }

                    DicConsole.WriteLine("CompactDisc Power Management Area contained in image:");
                    DicConsole.Write("{0}", PMA.Prettify(pma));
                    DicConsole.WriteLine();
                }
            }

            if (imageFormat.Info.ReadableMediaTags != null &&
                imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.CD_ATIP))
            {
                byte[] atip = imageFormat.ReadDiskTag(MediaTagType.CD_ATIP);

                uint dataLen = Swapping.Swap(BitConverter.ToUInt32(atip, 0));
                if (dataLen + 4 != atip.Length)
                {
                    byte[] tmp = new byte[atip.Length + 4];
                    Array.Copy(atip, 0, tmp, 4, atip.Length);
                    tmp[0] = (byte)((atip.Length & 0xFF000000) >> 24);
                    tmp[1] = (byte)((atip.Length & 0xFF0000) >> 16);
                    tmp[2] = (byte)((atip.Length & 0xFF00) >> 8);
                    tmp[3] = (byte)(atip.Length & 0xFF);
                    atip   = tmp;
                }

                DicConsole.WriteLine("CompactDisc Absolute Time In Pregroove (ATIP) contained in image:");
                DicConsole.Write("{0}", ATIP.Prettify(atip));
                DicConsole.WriteLine();
            }

            if (imageFormat.Info.ReadableMediaTags != null &&
                imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.CD_TEXT))
            {
                byte[] cdtext = imageFormat.ReadDiskTag(MediaTagType.CD_TEXT);

                uint dataLen = Swapping.Swap(BitConverter.ToUInt32(cdtext, 0));
                if (dataLen + 4 != cdtext.Length)
                {
                    byte[] tmp = new byte[cdtext.Length + 4];
                    Array.Copy(cdtext, 0, tmp, 4, cdtext.Length);
                    tmp[0] = (byte)((cdtext.Length & 0xFF000000) >> 24);
                    tmp[1] = (byte)((cdtext.Length & 0xFF0000) >> 16);
                    tmp[2] = (byte)((cdtext.Length & 0xFF00) >> 8);
                    tmp[3] = (byte)(cdtext.Length & 0xFF);
                    cdtext = tmp;
                }

                DicConsole.WriteLine("CompactDisc Lead-in's CD-Text contained in image:");
                DicConsole.Write("{0}", CDTextOnLeadIn.Prettify(cdtext));
                DicConsole.WriteLine();
            }

            if (imageFormat.Info.ReadableMediaTags != null &&
                imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.CD_MCN))
            {
                byte[] mcn = imageFormat.ReadDiskTag(MediaTagType.CD_MCN);

                DicConsole.WriteLine("CompactDisc Media Catalogue Number contained in image: {0}",
                                     Encoding.UTF8.GetString(mcn));
                DicConsole.WriteLine();
            }

            if (imageFormat.Info.ReadableMediaTags != null &&
                imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.DVD_PFI))
            {
                byte[] pfi = imageFormat.ReadDiskTag(MediaTagType.DVD_PFI);

                DicConsole.WriteLine("DVD Physical Format Information contained in image:");
                DicConsole.Write("{0}", PFI.Prettify(pfi));
                DicConsole.WriteLine();
            }

            if (imageFormat.Info.ReadableMediaTags != null &&
                imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.DVDRAM_DDS))
            {
                byte[] dds = imageFormat.ReadDiskTag(MediaTagType.DVDRAM_DDS);

                DicConsole.WriteLine("DVD-RAM Disc Definition Structure contained in image:");
                DicConsole.Write("{0}", DDS.Prettify(dds));
                DicConsole.WriteLine();
            }

            if (imageFormat.Info.ReadableMediaTags != null &&
                imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.DVDR_PFI))
            {
                byte[] pfi = imageFormat.ReadDiskTag(MediaTagType.DVDR_PFI);

                DicConsole.WriteLine("DVD-R Physical Format Information contained in image:");
                DicConsole.Write("{0}", PFI.Prettify(pfi));
                DicConsole.WriteLine();
            }

            if (imageFormat.Info.ReadableMediaTags != null &&
                imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.BD_DI))
            {
                byte[] di = imageFormat.ReadDiskTag(MediaTagType.BD_DI);

                DicConsole.WriteLine("Bluray Disc Information contained in image:");
                DicConsole.Write("{0}", DI.Prettify(di));
                DicConsole.WriteLine();
            }

            if (imageFormat.Info.ReadableMediaTags != null &&
                imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.BD_DDS))
            {
                byte[] dds = imageFormat.ReadDiskTag(MediaTagType.BD_DDS);

                DicConsole.WriteLine("Bluray Disc Definition Structure contained in image:");
                DicConsole.Write("{0}", Decoders.Bluray.DDS.Prettify(dds));
                DicConsole.WriteLine();
            }

            if (imageFormat.Info.ReadableMediaTags != null &&
                imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.PCMCIA_CIS))
            {
                byte[] cis = imageFormat.ReadDiskTag(MediaTagType.PCMCIA_CIS);

                DicConsole.WriteLine("PCMCIA CIS:");
                Tuple[] tuples = CIS.GetTuples(cis);
                if (tuples != null)
                {
                    foreach (Tuple tuple in tuples)
                    {
                        switch (tuple.Code)
                        {
                        case TupleCodes.CISTPL_NULL:
                        case TupleCodes.CISTPL_END: break;

                        case TupleCodes.CISTPL_DEVICEGEO:
                        case TupleCodes.CISTPL_DEVICEGEO_A:
                            DicConsole.WriteLine("{0}", CIS.PrettifyDeviceGeometryTuple(tuple));
                            break;

                        case TupleCodes.CISTPL_MANFID:
                            DicConsole.WriteLine("{0}", CIS.PrettifyManufacturerIdentificationTuple(tuple));
                            break;

                        case TupleCodes.CISTPL_VERS_1:
                            DicConsole.WriteLine("{0}", CIS.PrettifyLevel1VersionTuple(tuple));
                            break;

                        case TupleCodes.CISTPL_ALTSTR:
                        case TupleCodes.CISTPL_BAR:
                        case TupleCodes.CISTPL_BATTERY:
                        case TupleCodes.CISTPL_BYTEORDER:
                        case TupleCodes.CISTPL_CFTABLE_ENTRY:
                        case TupleCodes.CISTPL_CFTABLE_ENTRY_CB:
                        case TupleCodes.CISTPL_CHECKSUM:
                        case TupleCodes.CISTPL_CONFIG:
                        case TupleCodes.CISTPL_CONFIG_CB:
                        case TupleCodes.CISTPL_DATE:
                        case TupleCodes.CISTPL_DEVICE:
                        case TupleCodes.CISTPL_DEVICE_A:
                        case TupleCodes.CISTPL_DEVICE_OA:
                        case TupleCodes.CISTPL_DEVICE_OC:
                        case TupleCodes.CISTPL_EXTDEVIC:
                        case TupleCodes.CISTPL_FORMAT:
                        case TupleCodes.CISTPL_FORMAT_A:
                        case TupleCodes.CISTPL_FUNCE:
                        case TupleCodes.CISTPL_FUNCID:
                        case TupleCodes.CISTPL_GEOMETRY:
                        case TupleCodes.CISTPL_INDIRECT:
                        case TupleCodes.CISTPL_JEDEC_A:
                        case TupleCodes.CISTPL_JEDEC_C:
                        case TupleCodes.CISTPL_LINKTARGET:
                        case TupleCodes.CISTPL_LONGLINK_A:
                        case TupleCodes.CISTPL_LONGLINK_C:
                        case TupleCodes.CISTPL_LONGLINK_CB:
                        case TupleCodes.CISTPL_LONGLINK_MFC:
                        case TupleCodes.CISTPL_NO_LINK:
                        case TupleCodes.CISTPL_ORG:
                        case TupleCodes.CISTPL_PWR_MGMNT:
                        case TupleCodes.CISTPL_SPCL:
                        case TupleCodes.CISTPL_SWIL:
                        case TupleCodes.CISTPL_VERS_2:
                            DicConsole.DebugWriteLine("Device-Info command", "Found undecoded tuple ID {0}",
                                                      tuple.Code);
                            break;

                        default:
                            DicConsole.DebugWriteLine("Device-Info command", "Found unknown tuple ID 0x{0:X2}",
                                                      (byte)tuple.Code);
                            break;
                        }
                    }
                }
                else
                {
                    DicConsole.DebugWriteLine("Device-Info command", "Could not get tuples");
                }
            }

            if (imageFormat.Info.ReadableMediaTags != null &&
                imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.SD_CID))
            {
                byte[] cid = imageFormat.ReadDiskTag(MediaTagType.SD_CID);

                DicConsole.WriteLine("SecureDigital CID contained in image:");
                DicConsole.Write("{0}", Decoders.SecureDigital.Decoders.PrettifyCID(cid));
                DicConsole.WriteLine();
            }

            if (imageFormat.Info.ReadableMediaTags != null &&
                imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.SD_CSD))
            {
                byte[] csd = imageFormat.ReadDiskTag(MediaTagType.SD_CSD);

                DicConsole.WriteLine("SecureDigital CSD contained in image:");
                DicConsole.Write("{0}", Decoders.SecureDigital.Decoders.PrettifyCSD(csd));
                DicConsole.WriteLine();
            }

            if (imageFormat.Info.ReadableMediaTags != null &&
                imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.SD_SCR))
            {
                byte[] scr = imageFormat.ReadDiskTag(MediaTagType.SD_SCR);

                DicConsole.WriteLine("SecureDigital SCR contained in image:");
                DicConsole.Write("{0}", Decoders.SecureDigital.Decoders.PrettifySCR(scr));
                DicConsole.WriteLine();
            }

            if (imageFormat.Info.ReadableMediaTags != null &&
                imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.SD_OCR))
            {
                byte[] ocr = imageFormat.ReadDiskTag(MediaTagType.SD_OCR);

                DicConsole.WriteLine("SecureDigital OCR contained in image:");
                DicConsole.Write("{0}", Decoders.SecureDigital.Decoders.PrettifyOCR(ocr));
                DicConsole.WriteLine();
            }

            if (imageFormat.Info.ReadableMediaTags != null &&
                imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.MMC_CID))
            {
                byte[] cid = imageFormat.ReadDiskTag(MediaTagType.MMC_CID);

                DicConsole.WriteLine("MultiMediaCard CID contained in image:");
                DicConsole.Write("{0}", Decoders.MMC.Decoders.PrettifyCID(cid));
                DicConsole.WriteLine();
            }

            if (imageFormat.Info.ReadableMediaTags != null &&
                imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.MMC_CSD))
            {
                byte[] csd = imageFormat.ReadDiskTag(MediaTagType.MMC_CSD);

                DicConsole.WriteLine("MultiMediaCard CSD contained in image:");
                DicConsole.Write("{0}", Decoders.MMC.Decoders.PrettifyCSD(csd));
                DicConsole.WriteLine();
            }

            if (imageFormat.Info.ReadableMediaTags != null &&
                imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.MMC_ExtendedCSD))
            {
                byte[] ecsd = imageFormat.ReadDiskTag(MediaTagType.MMC_ExtendedCSD);

                DicConsole.WriteLine("MultiMediaCard ExtendedCSD contained in image:");
                DicConsole.Write("{0}", Decoders.MMC.Decoders.PrettifyExtendedCSD(ecsd));
                DicConsole.WriteLine();
            }

            if (imageFormat.Info.ReadableMediaTags != null &&
                imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.MMC_OCR))
            {
                byte[] ocr = imageFormat.ReadDiskTag(MediaTagType.MMC_OCR);

                DicConsole.WriteLine("MultiMediaCard OCR contained in image:");
                DicConsole.Write("{0}", Decoders.MMC.Decoders.PrettifyOCR(ocr));
                DicConsole.WriteLine();
            }

            if (imageFormat.Info.ReadableMediaTags != null &&
                imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.Xbox_PFI))
            {
                byte[] xpfi = imageFormat.ReadDiskTag(MediaTagType.Xbox_PFI);

                DicConsole.WriteLine("Xbox Physical Format Information contained in image:");
                DicConsole.Write("{0}", PFI.Prettify(xpfi));
                DicConsole.WriteLine();
            }

            if (imageFormat.Info.ReadableMediaTags != null &&
                imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.Xbox_DMI))
            {
                byte[] xdmi = imageFormat.ReadDiskTag(MediaTagType.Xbox_DMI);

                if (DMI.IsXbox(xdmi))
                {
                    DMI.XboxDMI?xmi = DMI.DecodeXbox(xdmi);
                    if (xmi.HasValue)
                    {
                        DicConsole.WriteLine("Xbox DMI contained in image:");
                        DicConsole.Write("{0}", DMI.PrettifyXbox(xmi));
                        DicConsole.WriteLine();
                    }
                }

                if (DMI.IsXbox360(xdmi))
                {
                    DMI.Xbox360DMI?xmi = DMI.DecodeXbox360(xdmi);
                    if (xmi.HasValue)
                    {
                        DicConsole.WriteLine("Xbox 360 DMI contained in image:");
                        DicConsole.Write("{0}", DMI.PrettifyXbox360(xmi));
                        DicConsole.WriteLine();
                    }
                }
            }

            if (imageFormat.Info.ReadableMediaTags != null &&
                imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.Xbox_SecuritySector))
            {
                byte[] toc = imageFormat.ReadDiskTag(MediaTagType.Xbox_SecuritySector);

                DicConsole.WriteLine("Xbox Security Sectors contained in image:");
                DicConsole.Write("{0}", SS.Prettify(toc));
                DicConsole.WriteLine();
            }

            if (imageFormat is IOpticalMediaImage opticalImage)
            {
                try
                {
                    if (opticalImage.Sessions != null && opticalImage.Sessions.Count > 0)
                    {
                        DicConsole.WriteLine("Image sessions:");
                        DicConsole.WriteLine("{0,-9}{1,-13}{2,-12}{3,-12}{4,-12}", "Session", "First track",
                                             "Last track", "Start", "End");
                        DicConsole.WriteLine("=========================================================");
                        foreach (Session session in opticalImage.Sessions)
                        {
                            DicConsole.WriteLine("{0,-9}{1,-13}{2,-12}{3,-12}{4,-12}", session.SessionSequence,
                                                 session.StartTrack, session.EndTrack, session.StartSector,
                                                 session.EndSector);
                        }
                        DicConsole.WriteLine();
                    }
                }
                catch
                {
                    // ignored
                }

                try
                {
                    if (opticalImage.Tracks != null && opticalImage.Tracks.Count > 0)
                    {
                        DicConsole.WriteLine("Image tracks:");
                        DicConsole.WriteLine("{0,-7}{1,-17}{2,-6}{3,-8}{4,-12}{5,-8}{6,-12}{7,-12}", "Track", "Type",
                                             "Bps", "Raw bps", "Subchannel", "Pregap", "Start", "End");
                        DicConsole
                        .WriteLine("=================================================================================");
                        foreach (Track track in opticalImage.Tracks)
                        {
                            DicConsole.WriteLine("{0,-7}{1,-17}{2,-6}{3,-8}{4,-12}{5,-8}{6,-12}{7,-12}",
                                                 track.TrackSequence, track.TrackType, track.TrackBytesPerSector,
                                                 track.TrackRawBytesPerSector, track.TrackSubchannelType,
                                                 track.TrackPregap, track.TrackStartSector, track.TrackEndSector);
                        }
                        DicConsole.WriteLine();
                    }
                }
                catch
                {
                    // ignored
                }
            }

            if (imageFormat.DumpHardware == null)
            {
                return;
            }

            const string MANUFACTURER_STRING = "Manufacturer";
            const string MODEL_STRING        = "Model";
            const string SERIAL_STRING       = "Serial";
            const string SOFTWARE_STRING     = "Software";
            const string VERSION_STRING      = "Version";
            const string OS_STRING           = "Operating system";
            const string START_STRING        = "Start";
            const string END_STRING          = "End";
            int          manufacturerLen     = MANUFACTURER_STRING.Length;
            int          modelLen            = MODEL_STRING.Length;
            int          serialLen           = SERIAL_STRING.Length;
            int          softwareLen         = SOFTWARE_STRING.Length;
            int          versionLen          = VERSION_STRING.Length;
            int          osLen     = OS_STRING.Length;
            int          sectorLen = START_STRING.Length;

            foreach (DumpHardwareType dump in imageFormat.DumpHardware)
            {
                if (dump.Manufacturer?.Length > manufacturerLen)
                {
                    manufacturerLen = dump.Manufacturer.Length;
                }
                if (dump.Model?.Length > modelLen)
                {
                    modelLen = dump.Model.Length;
                }
                if (dump.Serial?.Length > serialLen)
                {
                    serialLen = dump.Serial.Length;
                }
                if (dump.Software?.Name?.Length > softwareLen)
                {
                    softwareLen = dump.Software.Name.Length;
                }
                if (dump.Software?.Version?.Length > versionLen)
                {
                    versionLen = dump.Software.Version.Length;
                }
                if (dump.Software?.OperatingSystem?.Length > osLen)
                {
                    osLen = dump.Software.OperatingSystem.Length;
                }
                foreach (ExtentType extent in dump.Extents)
                {
                    if ($"{extent.Start}".Length > sectorLen)
                    {
                        sectorLen = $"{extent.Start}".Length;
                    }
                    if ($"{extent.End}".Length > sectorLen)
                    {
                        sectorLen = $"{extent.End}".Length;
                    }
                }
            }

            manufacturerLen += 2;
            modelLen        += 2;
            serialLen       += 2;
            softwareLen     += 2;
            versionLen      += 2;
            osLen           += 2;
            sectorLen       += 2;
            sectorLen       += 2;

            char[] separator = new char[manufacturerLen + modelLen + serialLen + softwareLen + versionLen + osLen +
                                        sectorLen + sectorLen];
            for (int i = 0; i < separator.Length; i++)
            {
                separator[i] = '=';
            }
            string format =
                $"{{0,-{manufacturerLen}}}{{1,-{modelLen}}}{{2,-{serialLen}}}{{3,-{softwareLen}}}{{4,-{versionLen}}}{{5,-{osLen}}}{{6,-{sectorLen}}}{{7,-{sectorLen}}}";

            DicConsole.WriteLine("Dump hardware information:");
            DicConsole.WriteLine(format, MANUFACTURER_STRING, MODEL_STRING, SERIAL_STRING, SOFTWARE_STRING,
                                 VERSION_STRING, OS_STRING, START_STRING, END_STRING);
            DicConsole.WriteLine(new string(separator));
            foreach (DumpHardwareType dump in imageFormat.DumpHardware)
            {
                foreach (ExtentType extent in dump.Extents)
                {
                    DicConsole.WriteLine(format, dump.Manufacturer, dump.Model, dump.Serial, dump.Software.Name,
                                         dump.Software.Version, dump.Software.OperatingSystem, extent.Start,
                                         extent.End);
                }
            }

            DicConsole.WriteLine();
        }
        internal void LoadData(byte[] scsiInquiryData, Inquiry.SCSIInquiry?scsiInquiry,
                               Dictionary <byte, byte[]> scsiEvpdPages, Modes.DecodedMode?scsiMode,
                               PeripheralDeviceTypes scsiType, byte[] scsiModeSense6,
                               byte[] scsiModeSense10,
                               byte[] mmcConfiguration)
        {
            inquiryData   = scsiInquiryData;
            inquiry       = scsiInquiry;
            evpdPages     = scsiEvpdPages;
            mode          = scsiMode;
            type          = scsiType;
            modeSense6    = scsiModeSense6;
            modeSense10   = scsiModeSense10;
            configuration = mmcConfiguration;

            if (inquiryData == null || !inquiry.HasValue)
            {
                return;
            }

            Visible             = true;
            txtScsiInquiry.Text = Inquiry.Prettify(inquiry);

            if (mode.HasValue)
            {
                tabScsiModeSense.Visible = true;

                var modePagesList = new TreeGridItemCollection();

                treeModeSensePages.Columns.Add(new GridColumn {
                    HeaderText = "Page", DataCell = new TextBoxCell(0)
                });

                treeModeSensePages.AllowMultipleSelection = false;
                treeModeSensePages.ShowHeader             = false;
                treeModeSensePages.DataStore = modePagesList;

                modePagesList.Add(new TreeGridItem
                {
                    Values = new object[]
                    {
                        "Header", Modes.PrettifyModeHeader(mode.Value.Header, type)
                    }
                });

                if (mode.Value.Pages != null)
                {
                    foreach (var page in mode.Value.Pages.OrderBy(t => t.Page).ThenBy(t => t.Subpage))
                    {
                        var pageNumberText = page.Subpage == 0
                            ? $"MODE {page.Page:X2}h"
                            : $"MODE {page.Page:X2} Subpage {page.Subpage:X2}";
                        string decodedText;

                        switch (page.Page)
                        {
                        case 0x00:
                        {
                            if (type == PeripheralDeviceTypes.MultiMediaDevice && page.Subpage == 0)
                            {
                                decodedText = Modes.PrettifyModePage_00_SFF(page.PageResponse);
                            }
                            else
                            {
                                decodedText = "Undecoded";
                            }

                            break;
                        }

                        case 0x01:
                        {
                            if (page.Subpage == 0)
                            {
                                decodedText = type == PeripheralDeviceTypes.MultiMediaDevice
                                        ? Modes.PrettifyModePage_01_MMC(page.PageResponse)
                                        : Modes.PrettifyModePage_01(page.PageResponse);
                            }
                            else
                            {
                                goto default;
                            }

                            break;
                        }

                        case 0x02:
                        {
                            if (page.Subpage == 0)
                            {
                                decodedText = Modes.PrettifyModePage_02(page.PageResponse);
                            }
                            else
                            {
                                goto default;
                            }

                            break;
                        }

                        case 0x03:
                        {
                            if (page.Subpage == 0)
                            {
                                decodedText = Modes.PrettifyModePage_03(page.PageResponse);
                            }
                            else
                            {
                                goto default;
                            }

                            break;
                        }

                        case 0x04:
                        {
                            if (page.Subpage == 0)
                            {
                                decodedText = Modes.PrettifyModePage_04(page.PageResponse);
                            }
                            else
                            {
                                goto default;
                            }

                            break;
                        }

                        case 0x05:
                        {
                            if (page.Subpage == 0)
                            {
                                decodedText = Modes.PrettifyModePage_05(page.PageResponse);
                            }
                            else
                            {
                                goto default;
                            }

                            break;
                        }

                        case 0x06:
                        {
                            if (page.Subpage == 0)
                            {
                                decodedText = Modes.PrettifyModePage_06(page.PageResponse);
                            }
                            else
                            {
                                goto default;
                            }

                            break;
                        }

                        case 0x07:
                        {
                            if (page.Subpage == 0)
                            {
                                decodedText = type == PeripheralDeviceTypes.MultiMediaDevice
                                        ? Modes.PrettifyModePage_07_MMC(page.PageResponse)
                                        : Modes.PrettifyModePage_07(page.PageResponse);
                            }
                            else
                            {
                                goto default;
                            }

                            break;
                        }

                        case 0x08:
                        {
                            if (page.Subpage == 0)
                            {
                                decodedText = Modes.PrettifyModePage_08(page.PageResponse);
                            }
                            else
                            {
                                goto default;
                            }

                            break;
                        }

                        case 0x0A:
                        {
                            if (page.Subpage == 0)
                            {
                                decodedText = Modes.PrettifyModePage_0A(page.PageResponse);
                            }
                            else if (page.Subpage == 1)
                            {
                                decodedText = Modes.PrettifyModePage_0A_S01(page.PageResponse);
                            }
                            else
                            {
                                goto default;
                            }

                            break;
                        }

                        case 0x0B:
                        {
                            if (page.Subpage == 0)
                            {
                                decodedText = Modes.PrettifyModePage_0B(page.PageResponse);
                            }
                            else
                            {
                                goto default;
                            }

                            break;
                        }

                        case 0x0D:
                        {
                            if (page.Subpage == 0)
                            {
                                decodedText = Modes.PrettifyModePage_0D(page.PageResponse);
                            }
                            else
                            {
                                goto default;
                            }

                            break;
                        }

                        case 0x0E:
                        {
                            if (page.Subpage == 0)
                            {
                                decodedText = Modes.PrettifyModePage_0E(page.PageResponse);
                            }
                            else
                            {
                                goto default;
                            }

                            break;
                        }

                        case 0x0F:
                        {
                            if (page.Subpage == 0)
                            {
                                decodedText = Modes.PrettifyModePage_0F(page.PageResponse);
                            }
                            else
                            {
                                goto default;
                            }

                            break;
                        }

                        case 0x10:
                        {
                            if (page.Subpage == 0)
                            {
                                decodedText = type == PeripheralDeviceTypes.SequentialAccess
                                        ? Modes.PrettifyModePage_10_SSC(page.PageResponse)
                                        : Modes.PrettifyModePage_10(page.PageResponse);
                            }
                            else
                            {
                                goto default;
                            }

                            break;
                        }

                        case 0x11:
                        {
                            if (page.Subpage == 0)
                            {
                                decodedText = Modes.PrettifyModePage_11(page.PageResponse);
                            }
                            else
                            {
                                goto default;
                            }

                            break;
                        }

                        case 0x12:
                        case 0x13:
                        case 0x14:
                        {
                            if (page.Subpage == 0)
                            {
                                decodedText = Modes.PrettifyModePage_12_13_14(page.PageResponse);
                            }
                            else
                            {
                                goto default;
                            }

                            break;
                        }

                        case 0x1A:
                        {
                            if (page.Subpage == 0)
                            {
                                decodedText = Modes.PrettifyModePage_1A(page.PageResponse);
                            }
                            else if (page.Subpage == 1)
                            {
                                decodedText = Modes.PrettifyModePage_1A_S01(page.PageResponse);
                            }
                            else
                            {
                                goto default;
                            }

                            break;
                        }

                        case 0x1B:
                        {
                            if (page.Subpage == 0)
                            {
                                decodedText = Modes.PrettifyModePage_1B(page.PageResponse);
                            }
                            else
                            {
                                goto default;
                            }

                            break;
                        }

                        case 0x1C:
                        {
                            if (page.Subpage == 0)
                            {
                                decodedText = type == PeripheralDeviceTypes.MultiMediaDevice
                                        ? Modes.PrettifyModePage_1C_SFF(page.PageResponse)
                                        : Modes.PrettifyModePage_1C(page.PageResponse);
                            }
                            else if (page.Subpage == 1)
                            {
                                decodedText = Modes.PrettifyModePage_1C_S01(page.PageResponse);
                            }
                            else
                            {
                                goto default;
                            }

                            break;
                        }

                        case 0x1D:
                        {
                            if (page.Subpage == 0)
                            {
                                decodedText = Modes.PrettifyModePage_1D(page.PageResponse);
                            }
                            else
                            {
                                goto default;
                            }

                            break;
                        }

                        case 0x21:
                        {
                            if (StringHandlers.CToString(inquiry?.VendorIdentification).Trim() == "CERTANCE")
                            {
                                decodedText = Modes.PrettifyCertanceModePage_21(page.PageResponse);
                            }
                            else
                            {
                                goto default;
                            }

                            break;
                        }

                        case 0x22:
                        {
                            if (StringHandlers.CToString(inquiry?.VendorIdentification).Trim() == "CERTANCE")
                            {
                                decodedText = Modes.PrettifyCertanceModePage_22(page.PageResponse);
                            }
                            else
                            {
                                goto default;
                            }

                            break;
                        }

                        case 0x24:
                        {
                            if (StringHandlers.CToString(inquiry?.VendorIdentification).Trim() == "IBM")
                            {
                                decodedText = Modes.PrettifyIBMModePage_24(page.PageResponse);
                            }
                            else
                            {
                                goto default;
                            }

                            break;
                        }

                        case 0x2A:
                        {
                            if (page.Subpage == 0)
                            {
                                decodedText = Modes.PrettifyModePage_2A(page.PageResponse);
                            }
                            else
                            {
                                goto default;
                            }

                            break;
                        }

                        case 0x2F:
                        {
                            if (StringHandlers.CToString(inquiry?.VendorIdentification).Trim() == "IBM")
                            {
                                decodedText = Modes.PrettifyIBMModePage_2F(page.PageResponse);
                            }
                            else
                            {
                                goto default;
                            }

                            break;
                        }

                        case 0x30:
                        {
                            if (Modes.IsAppleModePage_30(page.PageResponse))
                            {
                                decodedText = "Drive identifies as Apple OEM drive";
                            }
                            else
                            {
                                goto default;
                            }

                            break;
                        }

                        case 0x3B:
                        {
                            if (StringHandlers.CToString(inquiry?.VendorIdentification).Trim() == "HP")
                            {
                                decodedText = Modes.PrettifyHPModePage_3B(page.PageResponse);
                            }
                            else
                            {
                                goto default;
                            }

                            break;
                        }

                        case 0x3C:
                        {
                            if (StringHandlers.CToString(inquiry?.VendorIdentification).Trim() == "HP")
                            {
                                decodedText = Modes.PrettifyHPModePage_3C(page.PageResponse);
                            }
                            else
                            {
                                goto default;
                            }

                            break;
                        }

                        case 0x3D:
                        {
                            if (StringHandlers.CToString(inquiry?.VendorIdentification).Trim() == "IBM")
                            {
                                decodedText = Modes.PrettifyIBMModePage_3D(page.PageResponse);
                            }
                            else if (StringHandlers.CToString(inquiry?.VendorIdentification).Trim() == "HP")
                            {
                                decodedText = Modes.PrettifyHPModePage_3D(page.PageResponse);
                            }
                            else
                            {
                                goto default;
                            }

                            break;
                        }

                        case 0x3E:
                        {
                            if (StringHandlers.CToString(inquiry?.VendorIdentification).Trim() == "FUJITSU")
                            {
                                decodedText = Modes.PrettifyFujitsuModePage_3E(page.PageResponse);
                            }
                            else if (StringHandlers.CToString(inquiry?.VendorIdentification).Trim() == "HP")
                            {
                                decodedText = Modes.PrettifyHPModePage_3E(page.PageResponse);
                            }
                            else
                            {
                                goto default;
                            }

                            break;
                        }

                        default:
                        {
                            decodedText = "Undecoded";
                            break;
                        }
                        }

                        // TODO: Automatic error reporting
                        if (decodedText == null)
                        {
                            decodedText = "Error decoding page, please open an issue.";
                        }
                        modePagesList.Add(new TreeGridItem {
                            Values = new object[] { pageNumberText, decodedText }
                        });
                    }
                }
            }

            if (evpdPages != null)
            {
                tabScsiEvpd.Visible      = true;
                treeEvpdPages.ShowHeader = false;

                var evpdPagesList = new TreeGridItemCollection();

                treeEvpdPages.Columns.Add(new GridColumn {
                    HeaderText = "Page", DataCell = new TextBoxCell(0)
                });

                treeEvpdPages.AllowMultipleSelection = false;
                treeEvpdPages.ShowHeader             = false;
                treeEvpdPages.DataStore = evpdPagesList;

                foreach (var page in evpdPages.OrderBy(t => t.Key))
                {
                    var evpdPageTitle   = "";
                    var evpdDecodedPage = "";
                    if (page.Key >= 0x01 && page.Key <= 0x7F)
                    {
                        evpdPageTitle   = $"ASCII Page {page.Key:X2}h";
                        evpdDecodedPage = EVPD.DecodeASCIIPage(page.Value);
                    }
                    else if (page.Key == 0x80)
                    {
                        evpdPageTitle   = "Unit Serial Number";
                        evpdDecodedPage = EVPD.DecodePage80(page.Value);
                    }
                    else if (page.Key == 0x81)
                    {
                        evpdPageTitle   = "SCSI Implemented operating definitions";
                        evpdDecodedPage = EVPD.PrettifyPage_81(page.Value);
                    }
                    else if (page.Key == 0x82)
                    {
                        evpdPageTitle   = "ASCII implemented operating definitions";
                        evpdDecodedPage = EVPD.DecodePage82(page.Value);
                    }
                    else if (page.Key == 0x83)
                    {
                        evpdPageTitle   = "SCSI Device identification";
                        evpdDecodedPage = EVPD.PrettifyPage_83(page.Value);
                    }
                    else if (page.Key == 0x84)
                    {
                        evpdPageTitle   = "SCSI Software Interface Identifiers";
                        evpdDecodedPage = EVPD.PrettifyPage_84(page.Value);
                    }
                    else if (page.Key == 0x85)
                    {
                        evpdPageTitle   = "SCSI Management Network Addresses";
                        evpdDecodedPage = EVPD.PrettifyPage_85(page.Value);
                    }
                    else if (page.Key == 0x86)
                    {
                        evpdPageTitle   = "SCSI Extended INQUIRY Data";
                        evpdDecodedPage = EVPD.PrettifyPage_86(page.Value);
                    }
                    else if (page.Key == 0x89)
                    {
                        evpdPageTitle   = "SCSI to ATA Translation Layer Data";
                        evpdDecodedPage = EVPD.PrettifyPage_89(page.Value);
                    }
                    else if (page.Key == 0xB0)
                    {
                        evpdPageTitle   = "SCSI Sequential-access Device Capabilities";
                        evpdDecodedPage = EVPD.PrettifyPage_B0(page.Value);
                    }
                    else if (page.Key == 0xB1)
                    {
                        evpdPageTitle   = "Manufacturer-assigned Serial Number";
                        evpdDecodedPage = EVPD.DecodePageB1(page.Value);
                    }
                    else if (page.Key == 0xB2)
                    {
                        evpdPageTitle   = "TapeAlert Supported Flags Bitmap";
                        evpdDecodedPage = $"0x{EVPD.DecodePageB2(page.Value):X16}";
                    }
                    else if (page.Key == 0xB3)
                    {
                        evpdPageTitle   = "Automation Device Serial Number";
                        evpdDecodedPage = EVPD.DecodePageB3(page.Value);
                    }
                    else if (page.Key == 0xB4)
                    {
                        evpdPageTitle   = "Data Transfer Device Element Address";
                        evpdDecodedPage = EVPD.DecodePageB4(page.Value);
                    }
                    else if (page.Key == 0xC0 &&
                             StringHandlers.CToString(inquiry.Value.VendorIdentification).ToLowerInvariant().Trim() ==
                             "quantum")
                    {
                        evpdPageTitle   = "Quantum Firmware Build Information page";
                        evpdDecodedPage = EVPD.PrettifyPage_C0_Quantum(page.Value);
                    }
                    else if (page.Key == 0xC0 &&
                             StringHandlers.CToString(inquiry.Value.VendorIdentification).ToLowerInvariant().Trim() ==
                             "seagate")
                    {
                        evpdPageTitle   = "Seagate Firmware Numbers page";
                        evpdDecodedPage = EVPD.PrettifyPage_C0_Seagate(page.Value);
                    }
                    else if (page.Key == 0xC0 &&
                             StringHandlers.CToString(inquiry.Value.VendorIdentification).ToLowerInvariant().Trim() ==
                             "ibm")
                    {
                        evpdPageTitle   = "IBM Drive Component Revision Levels page";
                        evpdDecodedPage = EVPD.PrettifyPage_C0_IBM(page.Value);
                    }
                    else if (page.Key == 0xC1 &&
                             StringHandlers.CToString(inquiry.Value.VendorIdentification).ToLowerInvariant().Trim() ==
                             "ibm")
                    {
                        evpdPageTitle   = "IBM Drive Serial Numbers page";
                        evpdDecodedPage = EVPD.PrettifyPage_C1_IBM(page.Value);
                    }
                    else if ((page.Key == 0xC0 || page.Key == 0xC1) &&
                             StringHandlers.CToString(inquiry.Value.VendorIdentification).ToLowerInvariant().Trim() ==
                             "certance")
                    {
                        evpdPageTitle   = "Certance Drive Component Revision Levels page";
                        evpdDecodedPage = EVPD.PrettifyPage_C0_C1_Certance(page.Value);
                    }
                    else if ((page.Key == 0xC2 || page.Key == 0xC3 || page.Key == 0xC4 || page.Key == 0xC5 ||
                              page.Key == 0xC6) &&
                             StringHandlers.CToString(inquiry.Value.VendorIdentification).ToLowerInvariant().Trim() ==
                             "certance")
                    {
                        switch (page.Key)
                        {
                        case 0xC2:
                            evpdPageTitle = "Head Assembly Serial Number";
                            break;

                        case 0xC3:
                            evpdPageTitle = "Reel Motor 1 Serial Number";
                            break;

                        case 0xC4:
                            evpdPageTitle = "Reel Motor 2 Serial Number";
                            break;

                        case 0xC5:
                            evpdPageTitle = "Board Serial Number";
                            break;

                        case 0xC6:
                            evpdPageTitle = "Base Mechanical Serial Number";
                            break;
                        }

                        evpdDecodedPage = EVPD.PrettifyPage_C2_C3_C4_C5_C6_Certance(page.Value);
                    }
                    else if ((page.Key == 0xC0 || page.Key == 0xC1 || page.Key == 0xC2 || page.Key == 0xC3 ||
                              page.Key == 0xC4 || page.Key == 0xC5) && StringHandlers
                             .CToString(inquiry.Value.VendorIdentification)
                             .ToLowerInvariant().Trim() == "hp")
                    {
                        switch (page.Key)
                        {
                        case 0xC0:
                            evpdPageTitle = "HP Drive Firmware Revision Levels page:";
                            break;

                        case 0xC1:
                            evpdPageTitle = "HP Drive Hardware Revision Levels page:";
                            break;

                        case 0xC2:
                            evpdPageTitle = "HP Drive PCA Revision Levels page:";
                            break;

                        case 0xC3:
                            evpdPageTitle = "HP Drive Mechanism Revision Levels page:";
                            break;

                        case 0xC4:
                            evpdPageTitle = "HP Drive Head Assembly Revision Levels page:";
                            break;

                        case 0xC5:
                            evpdPageTitle = "HP Drive ACI Revision Levels page:";
                            break;
                        }

                        evpdDecodedPage = EVPD.PrettifyPage_C0_to_C5_HP(page.Value);
                    }
                    else if (page.Key == 0xDF &&
                             StringHandlers.CToString(inquiry.Value.VendorIdentification).ToLowerInvariant().Trim() ==
                             "certance")
                    {
                        evpdPageTitle   = "Certance drive status page";
                        evpdDecodedPage = EVPD.PrettifyPage_DF_Certance(page.Value);
                    }
                    else
                    {
                        if (page.Key == 0x00)
                        {
                            continue;
                        }

                        evpdPageTitle   = $"Page {page.Key:X2}h";
                        evpdDecodedPage = "Undecoded";
                        DicConsole.DebugWriteLine("Device-Info command", "Found undecoded SCSI VPD page 0x{0:X2}",
                                                  page.Key);
                    }

                    evpdPagesList.Add(new TreeGridItem
                    {
                        Values = new object[] { evpdPageTitle, evpdDecodedPage, page.Value }
                    });
                }
            }

            if (configuration != null)
            {
                tabMmcFeatures.Visible = true;

                var featuresList = new TreeGridItemCollection();

                treeMmcFeatures.Columns.Add(new GridColumn {
                    HeaderText = "Feature", DataCell = new TextBoxCell(0)
                });

                treeMmcFeatures.AllowMultipleSelection = false;
                treeMmcFeatures.ShowHeader             = false;
                treeMmcFeatures.DataStore = featuresList;

                var ftr = Features.Separate(configuration);

                DicConsole.DebugWriteLine("Device-Info command", "GET CONFIGURATION length is {0} bytes",
                                          ftr.DataLength);
                DicConsole.DebugWriteLine("Device-Info command", "GET CONFIGURATION current profile is {0:X4}h",
                                          ftr.CurrentProfile);
                if (ftr.Descriptors != null)
                {
                    foreach (var desc in ftr.Descriptors)
                    {
                        var    featureNumber = $"Feature {desc.Code:X4}h";
                        string featureDescription;
                        DicConsole.DebugWriteLine("Device-Info command", "Feature {0:X4}h", desc.Code);

                        switch (desc.Code)
                        {
                        case 0x0000:
                            featureDescription = Features.Prettify_0000(desc.Data);
                            break;

                        case 0x0001:
                            featureDescription = Features.Prettify_0001(desc.Data);
                            break;

                        case 0x0002:
                            featureDescription = Features.Prettify_0002(desc.Data);
                            break;

                        case 0x0003:
                            featureDescription = Features.Prettify_0003(desc.Data);
                            break;

                        case 0x0004:
                            featureDescription = Features.Prettify_0004(desc.Data);
                            break;

                        case 0x0010:
                            featureDescription = Features.Prettify_0010(desc.Data);
                            break;

                        case 0x001D:
                            featureDescription = Features.Prettify_001D(desc.Data);
                            break;

                        case 0x001E:
                            featureDescription = Features.Prettify_001E(desc.Data);
                            break;

                        case 0x001F:
                            featureDescription = Features.Prettify_001F(desc.Data);
                            break;

                        case 0x0020:
                            featureDescription = Features.Prettify_0020(desc.Data);
                            break;

                        case 0x0021:
                            featureDescription = Features.Prettify_0021(desc.Data);
                            break;

                        case 0x0022:
                            featureDescription = Features.Prettify_0022(desc.Data);
                            break;

                        case 0x0023:
                            featureDescription = Features.Prettify_0023(desc.Data);
                            break;

                        case 0x0024:
                            featureDescription = Features.Prettify_0024(desc.Data);
                            break;

                        case 0x0025:
                            featureDescription = Features.Prettify_0025(desc.Data);
                            break;

                        case 0x0026:
                            featureDescription = Features.Prettify_0026(desc.Data);
                            break;

                        case 0x0027:
                            featureDescription = Features.Prettify_0027(desc.Data);
                            break;

                        case 0x0028:
                            featureDescription = Features.Prettify_0028(desc.Data);
                            break;

                        case 0x0029:
                            featureDescription = Features.Prettify_0029(desc.Data);
                            break;

                        case 0x002A:
                            featureDescription = Features.Prettify_002A(desc.Data);
                            break;

                        case 0x002B:
                            featureDescription = Features.Prettify_002B(desc.Data);
                            break;

                        case 0x002C:
                            featureDescription = Features.Prettify_002C(desc.Data);
                            break;

                        case 0x002D:
                            featureDescription = Features.Prettify_002D(desc.Data);
                            break;

                        case 0x002E:
                            featureDescription = Features.Prettify_002E(desc.Data);
                            break;

                        case 0x002F:
                            featureDescription = Features.Prettify_002F(desc.Data);
                            break;

                        case 0x0030:
                            featureDescription = Features.Prettify_0030(desc.Data);
                            break;

                        case 0x0031:
                            featureDescription = Features.Prettify_0031(desc.Data);
                            break;

                        case 0x0032:
                            featureDescription = Features.Prettify_0032(desc.Data);
                            break;

                        case 0x0033:
                            featureDescription = Features.Prettify_0033(desc.Data);
                            break;

                        case 0x0035:
                            featureDescription = Features.Prettify_0035(desc.Data);
                            break;

                        case 0x0037:
                            featureDescription = Features.Prettify_0037(desc.Data);
                            break;

                        case 0x0038:
                            featureDescription = Features.Prettify_0038(desc.Data);
                            break;

                        case 0x003A:
                            featureDescription = Features.Prettify_003A(desc.Data);
                            break;

                        case 0x003B:
                            featureDescription = Features.Prettify_003B(desc.Data);
                            break;

                        case 0x0040:
                            featureDescription = Features.Prettify_0040(desc.Data);
                            break;

                        case 0x0041:
                            featureDescription = Features.Prettify_0041(desc.Data);
                            break;

                        case 0x0042:
                            featureDescription = Features.Prettify_0042(desc.Data);
                            break;

                        case 0x0050:
                            featureDescription = Features.Prettify_0050(desc.Data);
                            break;

                        case 0x0051:
                            featureDescription = Features.Prettify_0051(desc.Data);
                            break;

                        case 0x0080:
                            featureDescription = Features.Prettify_0080(desc.Data);
                            break;

                        case 0x0100:
                            featureDescription = Features.Prettify_0100(desc.Data);
                            break;

                        case 0x0101:
                            featureDescription = Features.Prettify_0101(desc.Data);
                            break;

                        case 0x0102:
                            featureDescription = Features.Prettify_0102(desc.Data);
                            break;

                        case 0x0103:
                            featureDescription = Features.Prettify_0103(desc.Data);
                            break;

                        case 0x0104:
                            featureDescription = Features.Prettify_0104(desc.Data);
                            break;

                        case 0x0105:
                            featureDescription = Features.Prettify_0105(desc.Data);
                            break;

                        case 0x0106:
                            featureDescription = Features.Prettify_0106(desc.Data);
                            break;

                        case 0x0107:
                            featureDescription = Features.Prettify_0107(desc.Data);
                            break;

                        case 0x0108:
                            featureDescription = Features.Prettify_0108(desc.Data);
                            break;

                        case 0x0109:
                            featureDescription = Features.Prettify_0109(desc.Data);
                            break;

                        case 0x010A:
                            featureDescription = Features.Prettify_010A(desc.Data);
                            break;

                        case 0x010B:
                            featureDescription = Features.Prettify_010B(desc.Data);
                            break;

                        case 0x010C:
                            featureDescription = Features.Prettify_010C(desc.Data);
                            break;

                        case 0x010D:
                            featureDescription = Features.Prettify_010D(desc.Data);
                            break;

                        case 0x010E:
                            featureDescription = Features.Prettify_010E(desc.Data);
                            break;

                        case 0x0110:
                            featureDescription = Features.Prettify_0110(desc.Data);
                            break;

                        case 0x0113:
                            featureDescription = Features.Prettify_0113(desc.Data);
                            break;

                        case 0x0142:
                            featureDescription = Features.Prettify_0142(desc.Data);
                            break;

                        default:
                            featureDescription = "Unknown feature";
                            break;
                        }

                        featuresList.Add(new TreeGridItem {
                            Values = new object[] { featureNumber, featureDescription }
                        });
                    }
                }
                else
                {
                    DicConsole.DebugWriteLine("Device-Info command",
                                              "GET CONFIGURATION returned no feature descriptors");
                }
            }

            Invalidate();
        }
        public static void Initialize()
        {
            Menu = MainMenu.AddMenu(Player.Instance.ChampionName, "GodSpeedRengar");
            Menu.AddGroupLabel("Açıklama");
            Menu.AddLabel("Korkutucu Hareketler Yapma :D!");
            Menu.AddLabel("Çeviri TRAdana");


            // Modes
            Modes = Menu.AddSubMenu("Modlar", "modes");

            // Combo
            Modes.AddGroupLabel("Kombo");
            Variables.ComboSmite  = Modes.Add("comboUseSmite", new CheckBox("Tutuştur Kullan"));
            Variables.ComboYoumuu = Modes.Add("comboUseYoumuu", new CheckBox("Kullan Youmuu"));
            Modes.AddLabel("Modlar (1-Snare;2- OneShoot;3- Snare on Jump;4- Q always)");
            Variables.ComboMode      = Modes.Add("comboMode", new Slider("Modlar", 2, 1, 4));
            Variables.ComboSwitchKey = Modes.Add("comboSwitch", new KeyBind("Modu Değiştirme Tuşu", false, KeyBind.BindTypes.HoldActive, 'T'));

            Modes.AddSeparator();

            //Harass
            Modes.AddGroupLabel("Dürtme");
            Variables.HarassW = Modes.Add("harassUseW", new CheckBox("Kullan W"));
            Variables.HarassE = Modes.Add("harassUseE", new CheckBox("Kullan E"));

            Modes.AddSeparator();

            //LaneClear
            Modes.AddGroupLabel("LaneTemizleme");
            Variables.LaneQ      = Modes.Add("laneUseQ", new CheckBox("Kullan Q"));
            Variables.LaneW      = Modes.Add("laneUseW", new CheckBox("Kullan W"));
            Variables.LaneE      = Modes.Add("laneUseE", new CheckBox("Kullan E"));
            Variables.LaneTiamat = Modes.Add("laneUseTiamat", new CheckBox("Kullan Tiamat/Hydra"));
            Variables.LaneSave   = Modes.Add("laneSave", new CheckBox("5 yükü Sakla", false));

            Modes.AddSeparator();

            //JungleClear
            Modes.AddGroupLabel("OrmanTemizleme");
            Variables.JungQ      = Modes.Add("jungUseQ", new CheckBox("Kullan Q"));
            Variables.JungW      = Modes.Add("jungUseW", new CheckBox("Kullan W"));
            Variables.JungE      = Modes.Add("jungUseE", new CheckBox("Kullan E"));
            Variables.JungTiamat = Modes.Add("jungUseTiamat", new CheckBox("Kullan Tiamat/Hydra"));
            Variables.JungSave   = Modes.Add("jungSave", new CheckBox("5 yükü Sakla", false));

            Modes.AddSeparator();

            //Auto
            Modes.AddGroupLabel("Otomatik");
            Variables.AutoWHeal      = Modes.Add("autoWHeal", new Slider("W için canım şundan az <", 20, 0, 100));
            Variables.AutoEInterrupt = Modes.Add("autoEInterrupt", new CheckBox("Interrupt with E"));
            Variables.AutoSmiteKS    = Modes.Add("autoSmiteKS", new CheckBox("Çarpla Ks at (blue/red)"));
            Variables.AutoESK        = Modes.Add("autoEKS", new CheckBox("E Ks Kullan"));
            Variables.AutoWKS        = Modes.Add("autoWKS", new CheckBox("W Ks Kullan"));
            Variables.AutoSmiteSteal = Modes.Add("autoSteal", new CheckBox("Çarpla Çal Ejder/Baron"));

            //drawing
            Draw = Menu.AddSubMenu("Gösterge", "drawing");

            Variables.DrawMode = Draw.Add("drawMode", new CheckBox("Gösterge Modu"));
            //Variables.DrawSelectedTarget = Draw.Add("drawSelected", new CheckBox("Notify Selected Target While Steath"));

            Magnet = Menu.AddSubMenu("Magnet", "magnet");
            Magnet.AddLabel("Seçili hedefe doğru odaklan");
            Variables.MagnetEnable = Magnet.Add("magnetEnable", new CheckBox("Aktif", false));
            Variables.MagnetRange  = Magnet.Add("magnetRange", new Slider("Magnet(Mıktatıs) Menzili", 300, 150, 500));

            Targetting = Menu.AddSubMenu("Hedefleme", "targetting");

            Targetting.AddGroupLabel("Ulti Zıplama Hedefleme");
            Variables.UltSelected = Targetting.Add("ultiSelected", new CheckBox("Hedef Önceliği Seç"));
            foreach (var hero in EntityManager.Heroes.Enemies)
            {
                Targetting.Add("ulti" + hero.NetworkId,
                               new CheckBox(hero.ChampionName + "(" + hero.Name + ")"));
            }

            Targetting.AddGroupLabel("Çalıdan Hedefe Zıplama");
            Variables.BushSelected = Targetting.Add("bushSelected", new CheckBox("Hedef Önceliği Seç"));
            foreach (var hero in EntityManager.Heroes.Enemies)
            {
                Targetting.Add("bush" + hero.NetworkId,
                               new Slider(hero.ChampionName + "(" + hero.Name + ")", TargetSelector.GetPriority(hero), 1, 5));
            }

            Game.OnTick += Game_OnTick;
        }
Exemple #34
0
        /// <summary>
        ///     Takes the MODE PAGEs part of a device report and prints it as a list of values and another list of key=value pairs
        ///     to be sequenced by ASP.NET in the rendering
        /// </summary>
        /// <param name="modeSense">MODE PAGEs part of a device report</param>
        /// <param name="vendor">SCSI vendor string</param>
        /// <param name="deviceType">SCSI peripheral device type</param>
        /// <param name="scsiOneValue">List to put values on</param>
        /// <param name="modePages">List to put key=value pairs on</param>
        public static void Report(modeType modeSense, string vendor,
                                  PeripheralDeviceTypes deviceType,
                                  ref List <string> scsiOneValue, ref Dictionary <string, string> modePages)
        {
            if (modeSense.MediumTypeSpecified)
            {
                scsiOneValue.Add($"Medium type is {modeSense.MediumType:X2}h");
            }
            if (modeSense.WriteProtected)
            {
                scsiOneValue.Add("Device is write protected.");
            }
            if (modeSense.BlockDescriptors != null)
            {
                foreach (blockDescriptorType descriptor in modeSense.BlockDescriptors)
                {
                    if (descriptor.BlocksSpecified && descriptor.BlockLengthSpecified)
                    {
                        scsiOneValue
                        .Add($"Density code {descriptor.Density:X2}h has {descriptor.Blocks} blocks of {descriptor.BlockLength} bytes each");
                    }
                    else
                    {
                        scsiOneValue.Add($"Density code {descriptor.Density:X2}h");
                    }
                }
            }

            if (modeSense.DPOandFUA)
            {
                scsiOneValue.Add("Drive supports DPO and FUA bits");
            }
            if (modeSense.BlankCheckEnabled)
            {
                scsiOneValue.Add("Blank checking during write is enabled");
            }
            if (modeSense.BufferedModeSpecified)
            {
                switch (modeSense.BufferedMode)
                {
                case 0:
                    scsiOneValue.Add("Device writes directly to media");
                    break;

                case 1:
                    scsiOneValue.Add("Device uses a write cache");
                    break;

                case 2:
                    scsiOneValue.Add("Device uses a write cache but doesn't return until cache is flushed");
                    break;

                default:
                    scsiOneValue.Add($"Unknown buffered mode code 0x{modeSense.BufferedMode:X2}");
                    break;
                }
            }

            if (modeSense.ModePages == null)
            {
                return;
            }

            foreach (modePageType page in modeSense.ModePages)
            {
                switch (page.page)
                {
                case 0x00:
                {
                    if (deviceType == PeripheralDeviceTypes.MultiMediaDevice && page.subpage == 0)
                    {
                        modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_00_SFF(page.value));
                    }
                    else
                    {
                        modePages
                        .Add(page.subpage != 0 ? $"MODE page {page.page:X2}h subpage {page.subpage:X2}h" : $"MODE page {page.page:X2}h",
                             "Unknown vendor mode page");
                    }
                    break;
                }

                case 0x01:
                {
                    if (page.subpage == 0)
                    {
                        modePages.Add($"MODE page {page.page:X2}h",
                                      deviceType == PeripheralDeviceTypes.MultiMediaDevice
                                              ? Modes.PrettifyModePage_01_MMC(page.value)
                                              : Modes.PrettifyModePage_01(page.value));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x02:
                {
                    if (page.subpage == 0)
                    {
                        modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_02(page.value));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x03:
                {
                    if (page.subpage == 0)
                    {
                        modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_03(page.value));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x04:
                {
                    if (page.subpage == 0)
                    {
                        modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_04(page.value));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x05:
                {
                    if (page.subpage == 0)
                    {
                        modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_05(page.value));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x06:
                {
                    if (page.subpage == 0)
                    {
                        modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_06(page.value));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x07:
                {
                    if (page.subpage == 0)
                    {
                        modePages.Add($"MODE page {page.page:X2}h",
                                      deviceType == PeripheralDeviceTypes.MultiMediaDevice
                                              ? Modes.PrettifyModePage_07_MMC(page.value)
                                              : Modes.PrettifyModePage_07(page.value));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x08:
                {
                    if (page.subpage == 0)
                    {
                        modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_08(page.value));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x0A:
                {
                    if (page.subpage == 0)
                    {
                        modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_0A(page.value));
                    }
                    else if (page.subpage == 1)
                    {
                        modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_0A_S01(page.value));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x0B:
                {
                    if (page.subpage == 0)
                    {
                        modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_0B(page.value));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x0D:
                {
                    if (page.subpage == 0)
                    {
                        modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_0D(page.value));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x0E:
                {
                    if (page.subpage == 0)
                    {
                        modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_0E(page.value));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x0F:
                {
                    if (page.subpage == 0)
                    {
                        modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_0F(page.value));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x10:
                {
                    if (page.subpage == 0)
                    {
                        modePages.Add($"MODE page {page.page:X2}h",
                                      deviceType == PeripheralDeviceTypes.SequentialAccess
                                              ? Modes.PrettifyModePage_10_SSC(page.value)
                                              : Modes.PrettifyModePage_10(page.value));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x11:
                {
                    if (page.subpage == 0)
                    {
                        modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_11(page.value));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x12:
                case 0x13:
                case 0x14:
                {
                    if (page.subpage == 0)
                    {
                        modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_12_13_14(page.value));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x1A:
                {
                    if (page.subpage == 0)
                    {
                        modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_1A(page.value));
                    }
                    else if (page.subpage == 1)
                    {
                        modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_1A_S01(page.value));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x1B:
                {
                    if (page.subpage == 0)
                    {
                        modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_1B(page.value));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x1C:
                {
                    if (page.subpage == 0)
                    {
                        modePages.Add($"MODE page {page.page:X2}h",
                                      deviceType == PeripheralDeviceTypes.MultiMediaDevice
                                              ? Modes.PrettifyModePage_1C_SFF(page.value)
                                              : Modes.PrettifyModePage_1C(page.value));
                    }
                    else if (page.subpage == 1)
                    {
                        modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_1C_S01(page.value));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x1D:
                {
                    if (page.subpage == 0)
                    {
                        modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_1D(page.value));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x21:
                {
                    if (vendor == "CERTANCE")
                    {
                        modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyCertanceModePage_21(page.value));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x22:
                {
                    if (vendor == "CERTANCE")
                    {
                        modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyCertanceModePage_22(page.value));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x24:
                {
                    if (vendor == "IBM")
                    {
                        modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyIBMModePage_24(page.value));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x2A:
                {
                    if (page.subpage == 0)
                    {
                        modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyModePage_2A(page.value));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x2F:
                {
                    if (vendor == "IBM")
                    {
                        modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyIBMModePage_2F(page.value));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x30:
                {
                    if (Modes.IsAppleModePage_30(page.value))
                    {
                        modePages.Add("MODE page 30h", "Drive identifies as an Apple OEM drive");
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x3B:
                {
                    if (vendor == "HP")
                    {
                        modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyHPModePage_3B(page.value));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x3C:
                {
                    if (vendor == "HP")
                    {
                        modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyHPModePage_3C(page.value));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x3D:
                {
                    if (vendor == "IBM")
                    {
                        modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyIBMModePage_3D(page.value));
                    }
                    else if (vendor == "HP")
                    {
                        modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyHPModePage_3D(page.value));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x3E:
                {
                    if (vendor == "FUJITSU")
                    {
                        modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyFujitsuModePage_3E(page.value));
                    }
                    else if (vendor == "HP")
                    {
                        modePages.Add($"MODE page {page.page:X2}h", Modes.PrettifyHPModePage_3E(page.value));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                default:
                {
                    modePages.Add(page.subpage != 0 ? $"MODE page {page.page:X2}h subpage {page.subpage:X2}h" : $"MODE page {page.page:X2}h",
                                  "Unknown mode page");
                }
                break;
                }
            }

            Dictionary <string, string> newModePages = new Dictionary <string, string>();

            foreach (KeyValuePair <string, string> kvp in modePages)
            {
                if (string.IsNullOrWhiteSpace(kvp.Value))
                {
                    newModePages.Add(kvp.Key, "Undecoded");
                }
                else
                {
                    newModePages.Add(kvp.Key, kvp.Value.Replace("\n", "<br/>"));
                }
            }

            modePages = newModePages;
        }
Exemple #35
0
 public CacheNotExistsException(Modes mode)
 {
     Mode = mode;
 }
Exemple #36
0
        /// <summary>
        /// Gets the specified remote file.
        /// </summary>
        /// <param name="remoteFile">The remote file.</param>
        /// <param name="localFile">The local file.</param>
        /// <param name="tftpMode">The TFTP mode.</param>
        public void Get(string remoteFile, string localFile, Modes tftpMode)
        {
            int len      = 0;
            int packetNr = 1;

            byte[] sndBuffer = CreateRequestPacket(Opcodes.Read, remoteFile, tftpMode);
            byte[] rcvBuffer = new byte[516];

            IPAddress ipa;

            if ((ipa = stXFTPUtil.GetIPAddress(tftpServer)) == null)
            {
                throw new XFTPException(502, Properties.Resources.txtXFTPBadIpAddress);
            }

            BinaryWriter fileStream = new BinaryWriter(new FileStream(localFile, FileMode.Create, FileAccess.Write, FileShare.Read));
            IPEndPoint   serverEP   = new IPEndPoint(ipa, tftpPort);
            EndPoint     dataEP     = (EndPoint)serverEP;
            Socket       tftpSocket = new Socket(serverEP.Address.AddressFamily, SocketType.Dgram, ProtocolType.Udp);

            // Request and Receive first Data Packet From TFTP Server
            tftpSocket.SendTo(sndBuffer, sndBuffer.Length, SocketFlags.None, serverEP);
            tftpSocket.ReceiveTimeout = 1000;
            len = tftpSocket.ReceiveFrom(rcvBuffer, ref dataEP);

            // keep track of the TID
            serverEP.Port = ((IPEndPoint)dataEP).Port;

            while (true)
            {
                // handle any kind of error
                if (((Opcodes)rcvBuffer[1]) == Opcodes.Error)
                {
                    fileStream.Close();
                    tftpSocket.Close();
                    throw new XFTPException(((rcvBuffer[2] << 8) & 0xff00) | rcvBuffer[3], Encoding.ASCII.GetString(rcvBuffer, 4, rcvBuffer.Length - 5).Trim('\0'));
                }
                // expect the next packet
                if ((((rcvBuffer[2] << 8) & 0xff00) | rcvBuffer[3]) == packetNr)
                {
                    // Store to local file
                    fileStream.Write(rcvBuffer, 4, len - 4);

                    // Send Ack Packet to TFTP Server
                    sndBuffer = CreateAckPacket(packetNr++);
                    tftpSocket.SendTo(sndBuffer, sndBuffer.Length, SocketFlags.None, serverEP);
                }
                // Was ist the last packet ?
                if (len < 516)
                {
                    break;
                }
                else
                {
                    // Receive Next Data Packet From TFTP Server
                    len = tftpSocket.ReceiveFrom(rcvBuffer, ref dataEP);
                }
            }

            // Close Socket and release resources
            tftpSocket.Close();
            fileStream.Close();
        }
    public void LoadData(List <string> heroData)
    {
        int index = 2;

        StringId = heroData[0].Split(' ')[1];

        while (heroData[index] != ".end")
        {
            List <string> data = heroData[index++].Replace("%", "").Replace("\"", "").
                                 Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).ToList();
            switch (data[0])
            {
            case "rendering:":
                RenderingRankOverride = int.Parse(data[2]);
                break;

            case "commonfx:":
                if (CommonEffects == null)
                {
                    CommonEffects = new CommonEffects(data);
                }
                else
                {
                    CommonEffects.LoadData(data);
                }
                break;

            case "combat_skill:":
                SkillArtInfo skillArt = new SkillArtInfo(data, false);
                SkillArtInfo.Add(skillArt);
                break;

            case "riposte_skill:":
                SkillArtInfo riposteArt = new SkillArtInfo(data, false);
                SkillArtInfo.Add(riposteArt);
                break;

            default:
                Debug.LogError("Unknown art token in hero: " + StringId);
                break;
            }
        }
        index += 2;

        while (heroData[index] != ".end")
        {
            List <string> data = heroData[index++].Replace("%", "").Replace("\"", "").
                                 Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).ToList();
            switch (data[0])
            {
            case "resistances:":
                Resistanses.Add(AttributeType.Stun, float.Parse(data[2]) / 100);
                Resistanses.Add(AttributeType.Poison, float.Parse(data[4]) / 100);
                Resistanses.Add(AttributeType.Bleed, float.Parse(data[6]) / 100);
                Resistanses.Add(AttributeType.Disease, float.Parse(data[8]) / 100);
                Resistanses.Add(AttributeType.Move, float.Parse(data[10]) / 100);
                Resistanses.Add(AttributeType.Debuff, float.Parse(data[12]) / 100);
                Resistanses.Add(AttributeType.DeathBlow, float.Parse(data[14]) / 100);
                Resistanses.Add(AttributeType.Trap, float.Parse(data[16]) / 100);
                break;

            case "weapon:":
                Equipment weapon = new Equipment(data[2], Weapons.Count + 1, HeroEquipmentSlot.Weapon);
                weapon.EquipmentModifiers.Add(new FlatModifier(AttributeType.DamageLow, float.Parse(data[6]), false));
                weapon.EquipmentModifiers.Add(new FlatModifier(AttributeType.DamageHigh, float.Parse(data[7]), false));
                weapon.EquipmentModifiers.Add(new FlatModifier(AttributeType.CritChance, float.Parse(data[9]) / 100, false));
                weapon.EquipmentModifiers.Add(new FlatModifier(AttributeType.SpeedRating, float.Parse(data[11]), false));
                Weapons.Add(weapon);
                break;

            case "armour:":
                Equipment armor = new Equipment(data[2], Armors.Count + 1, HeroEquipmentSlot.Armor);
                armor.EquipmentModifiers.Add(new FlatModifier(AttributeType.DefenseRating, float.Parse(data[4]) / 100, false));
                armor.EquipmentModifiers.Add(new FlatModifier(AttributeType.HitPoints, float.Parse(data[8]), true));
                Armors.Add(armor);
                break;

            case "combat_skill:":
                List <string> combatData = new List <string>();
                data = heroData[index - 1].Split(new char[] { '\"' }, StringSplitOptions.RemoveEmptyEntries).ToList();
                bool isEffectData = false;
                foreach (var item in data)
                {
                    if (isEffectData)
                    {
                        if (item.Trim(' ').StartsWith("."))
                        {
                            isEffectData = false;
                        }
                        else
                        {
                            combatData.Add(item);
                            continue;
                        }
                    }

                    string[] combatItems = item.Replace("%", "").Split(
                        new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                    if (combatItems[combatItems.Length - 1] == ".effect")
                    {
                        isEffectData = true;
                    }
                    combatData.AddRange(combatItems);
                }

                CombatSkillVariants.Add(new CombatSkill(combatData, true));
                break;

            case "combat_move_skill:":
                MoveSkill moveSkill = new MoveSkill();
                moveSkill.Id           = data[2];
                moveSkill.Type         = data[6];
                moveSkill.MoveBackward = int.Parse(data[8]);
                moveSkill.MoveForward  = int.Parse(data[9]);
                MoveSkill = moveSkill;
                break;

            case "riposte_skill:":
                List <string> riposteData = new List <string>();
                data = heroData[index - 1].Split(new char[] { '\"' }).ToList();
                bool isReposteEffect = false;
                foreach (var item in data)
                {
                    if (isReposteEffect)
                    {
                        if (item.Trim(' ')[0] == '.')
                        {
                            isEffectData = false;
                        }
                        else
                        {
                            riposteData.Add(item);
                            continue;
                        }
                    }

                    string[] combatItems = item.Replace("%", "").Split(
                        new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                    if (combatItems[combatItems.Length - 1] == ".effect")
                    {
                        isEffectData = true;
                    }
                    riposteData.AddRange(combatItems);
                }
                RiposteSkill = new CombatSkill(riposteData, true);
                break;

            case "incompatible_party_member:":
                IncompatiablePartyTag = data[4];
                break;

            case "tag:":
                Tags.Add(data[2]);
                break;

            case "controlled:":
                TargetRank = int.Parse(data[2]);
                break;

            case "id_index:":
                IndexId = int.Parse(data[2]);
                break;

            case "skill_selection:":
                CanSelectCombatSkills        = bool.Parse(data[2]);
                NumberOfSelectedCombatSkills = int.Parse(data[4]);
                break;

                #region Death Door
            case "deaths_door:":
                if (DeathDoor == null)
                {
                    DeathDoor = new DeathDoor(data);
                }
                else
                {
                    DeathDoor.LoadData(data);
                }
                break;

                #endregion
                #region Generation
            case "generation:":
                if (Generation == null)
                {
                    Generation = new HeroGeneration(data);
                }
                else
                {
                    Generation.LoadData(data);
                }
                break;

                #endregion
                #region Battle Loot
            case "extra_battle_loot:":
                if (ExtraBattleLoot == null)
                {
                    ExtraBattleLoot = new LootDefinition(data);
                }
                else
                {
                    ExtraBattleLoot.LoadData(data);
                }
                break;

                #endregion
                #region Curio Loot
            case "extra_curio_loot:":
                if (ExtraCurioLoot == null)
                {
                    ExtraCurioLoot = new LootDefinition(data);
                }
                else
                {
                    ExtraCurioLoot.LoadData(data);
                }
                break;

                #endregion
                #region Inventory Stack
            case "extra_stack_limit:":
                ExtraStackLimit = data[2];
                break;

                #endregion
                #region Mode
            case "mode:":
                Modes.Add(new CharacterMode(data));
                break;

                #endregion
            default:
                Debug.LogError("Unknown info token " + data[0] + " in hero: " + StringId);
                break;
            }
        }

        CombatSkills = new List <CombatSkill>(CombatSkillVariants.FindAll(skill => skill.Level == 0));
    }
Exemple #38
0
 /// <summary>
 /// Constructs a new data set ready to have lists of data assigned
 /// to it.
 /// </summary>
 /// <param name="lastModified">
 /// The date and time the source of the data was last modified.
 /// </param>
 /// <param name="mode">
 /// The mode of operation the data set will be using.
 /// </param>
 internal DataSet(DateTime lastModified, Modes mode)
 {
     LastModified = lastModified;
     Mode         = mode;
 }
 public void SetMode(int mode)
 {
     Mode = (Modes)mode;
 }
Exemple #40
0
        protected override double RunSolverOneStep(int TimestepNo, double phystime, double dt)
        {
            Stopwatch globalWatch = new Stopwatch();

            globalWatch.Start();

            /*
             * Configuration options
             */
            // Only applies to subdivision-based quadrature (brute force and adaptive)
            int[] divisions = new int[] { (int)testCase.GridSize };

            // Only applies to adaptive quadrature
            int leafDivisions = -1;

            // Only applies to regularized quadrature
            double[] widths                = new double[] { double.NaN };
            int[]    vanishingMonents      = new int[] { int.MinValue };
            int[]    continuousDerivatives = new int[] { int.MinValue };

            // Only applies to HMF quadrature
            LineSegment.IRootFindingAlgorithm rootFindingAlgorithm;


            /*
             * ENTER CONFIGURATION HERE
             */

            // Export options
            int  plotSuperSampling           = 3;
            bool logVolumeNodes              = true;
            int  logVolumeNodes_selectedCell = -1;
            bool logSurfaceNodes             = false;
            bool logConsole    = true;
            int  selectedShift = -1;

            // Quadrature variant

            Modes mode = Modes.SayeGaussRules;

            int[] orders = new int[] { 3 };

            //Modes mode = Modes.HMFClassic;
            //int[] orders = new int[] { 3, 4, 5, 6, 7, 8 };
            //LevelSetSurfaceQuadRuleFactory.RestrictNodes = false;
            //LevelSetSurfaceQuadRuleFactory.UseGaussNodes = true;
            //LevelSetVolumeQuadRuleFactory.RestrictNodes = false;
            //LevelSetVolumeQuadRuleFactory.UseGaussNodes = true;
            //LevelSetVolumeQuadRuleFactory.NodeCountSafetyFactor = 1.0;

            //Modes mode = Modes.HMFClassic;
            //int[] orders = new int[] { 1 };
            //LevelSetSurfaceQuadRuleFactory.RestrictNodes = false;
            //LevelSetSurfaceQuadRuleFactory.UseGaussNodes = true;
            //LevelSetVolumeQuadRuleFactory.RestrictNodes = false;
            //LevelSetVolumeQuadRuleFactory.UseGaussNodes = true;
            //LevelSetVolumeQuadRuleFactory.NodeCountSafetyFactor = 1.0;

            //Modes mode = Modes.HMFOneStepGaussAndStokes;
            //int[] orders = new int[] { 2, 4, 6, 8, 10 };

            //Modes mode = Modes.Adaptive;
            //int[] orders = new int[] { 1 };
            //int[] divisions = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
            //int leafDivisions = 1;

            //Modes mode = Modes.Regularized;
            //int[] orders = Enumerable.Range(1, 20).Select(k => 2 * k - 1).ToArray();
            //widths = new double[] { 0.1, 0.2 };
            //vanishingMonents = new int[] { 0, 2, 4, 6 };
            //continuousDerivatives = new int[] { 1, 3, 5 };

            //Modes mode = Modes.BruteForce;
            //int[] orders = new int[] { 1 };
            //divisions = new int[] { 0, 1, 2, 3, 4 };

            //Modes mode = Modes.Standard;
            //int[] orders = Enumerable.Range(1, 20).Select(k => 2 * k - 1).ToArray();

            if (levelSet is IAnalyticLevelSet)
            {
                rootFindingAlgorithm = new AnalyticLevelSetRootFindingAlgorithm();
            }
            else
            {
                rootFindingAlgorithm = new LineSegment.SafeGuardedNewtonMethod(1e-14);
                //rootFindingAlgorithm = new LineSegment.GSLRootFindingAlgorithm(1e-14);
            }

            /*
             * END OF CONFIGURATION
             */


            SubGrid  cutCellGrid     = levelSetTracker.Regions.GetCutCellSubGrid();
            CellMask cellMask        = CellMask.GetFullMask(GridData);
            SubGrid  selectedSubGrid = new SubGrid(cellMask);

            testCase.ScaleShifts(0.5 * testCase.GridSpacing);
            double hBase = ((BoSSS.Foundation.Grid.Classic.GridData)GridData).Cells.h_maxGlobal;

            string logName = ""
                             + testCase.GetType().Name
                             + "_" + Grid.RefElements[0].GetType().Name
                             + "_" + testCase.GridSize
                             + "_" + mode.ToString();

            if (logConsole)
            {
                string filename = logName + "_stdout.txt";
                ilPSP.Environment.StdOut.WriterS.Add(new StreamWriter(filename));
            }

            Console.WriteLine("Test case: " + testCase.GetType().Name);

            var errorMap = new Dictionary <Tuple <int, int, double, int, int>, List <Tuple <double, double, int> > >();

            foreach (int division in divisions)
            {
                foreach (int order in orders)
                {
                    foreach (double width in widths)
                    {
                        foreach (int vanishingMoment in vanishingMonents)
                        {
                            foreach (int continuousDerivative in continuousDerivatives)
                            {
                                errorMap[Tuple.Create(division, order, width, vanishingMoment, continuousDerivative)] =
                                    new List <Tuple <double, double, int> >();
                            }
                        }
                    }
                }
            }

            int i = 1;

            while (testCase.ProceedToNextShift())
            {
                Console.WriteLine("Processing shift " + i + " of " + testCase.NumberOfShifts);

                if (selectedShift > 0 && i != selectedShift)
                {
                    i++;
                    continue;
                }

                cutCellGrid = new SubGrid(
                    levelSetTracker.Regions.GetCutCellSubGrid().VolumeMask.Intersect(
                        selectedSubGrid.VolumeMask));

                double referenceValue = SetUpConfiguration();

                StreamWriter volumeNodesLog  = null;
                StreamWriter surfaceNodesLog = null;
                if (plotSuperSampling >= 0 && i == 1)
                {
                    PlotCurrentState(0.0, 0, plotSuperSampling, cutCellGrid);
                }

                Console.WriteLine();
                foreach (int division in divisions)
                {
                    Console.WriteLine("Number of divisions: " + division);

                    if (logVolumeNodes)
                    {
                        string filename = Path.Combine(
                            Path.GetFullPath("."),
                            "volumeNodes_" + testCase.GetType().Name + "_" + i + "_" + division);
                        volumeNodesLog = new StreamWriter(filename + ".txt");
                        if (GridData.SpatialDimension == 2)
                        {
                            volumeNodesLog.WriteLine("Cell\tNode\tx\ty\tweight");
                        }
                        else
                        {
                            volumeNodesLog.WriteLine("Cell\tNode\tx\ty\tz\tweight");
                        }
                    }

                    if (logSurfaceNodes)
                    {
                        string filename = Path.Combine(
                            Path.GetFullPath("."),
                            "surfaceNodes_" + testCase.GetType().Name + "_" + i + "_" + division);
                        surfaceNodesLog = new StreamWriter(filename + ".txt");
                        if (Grid.SpatialDimension == 2)
                        {
                            surfaceNodesLog.WriteLine("Cell\tNode\tx\ty\tweight");
                        }
                        else
                        {
                            surfaceNodesLog.WriteLine("Cell\tNode\tx\ty\tz\tweight");
                        }
                    }

                    foreach (int order in orders)
                    {
                        Console.WriteLine("Order: " + order);

                        foreach (double width in widths)
                        {
                            foreach (int vanishingMoment in vanishingMonents)
                            {
                                foreach (int continuousDerivative in continuousDerivatives)
                                {
                                    var result = PerformConfiguration(
                                        mode,
                                        order,
                                        division,
                                        volumeNodesLog,
                                        surfaceNodesLog,
                                        leafDivisions,
                                        vanishingMoment,
                                        continuousDerivative,
                                        width,
                                        hBase,
                                        rootFindingAlgorithm,
                                        logVolumeNodes_selectedCell);
                                    double error = Math.Abs(result.Item1 - referenceValue);

                                    var key = Tuple.Create(
                                        division, order, width, vanishingMoment, continuousDerivative);
                                    errorMap[key].Add(Tuple.Create(
                                                          result.Item1 + testCase.Solution - referenceValue,
                                                          error,
                                                          result.Item2));
                                }
                            }
                        }
                    }

                    if (volumeNodesLog != null)
                    {
                        volumeNodesLog.Close();
                    }
                    if (surfaceNodesLog != null)
                    {
                        surfaceNodesLog.Close();
                    }
                }
                Console.WriteLine();

                i++;
            }
            testCase.ResetShifts();

            using (StreamWriter log = new StreamWriter(logName + ".txt")) {
                log.WriteLine("Divisions\tOrder\tWidth\tMoments\tDerivatives\tResult\tMeanError\tMeanRelError\tStdDev\tMinError\tMaxError\tMaxErrorCase\tTime");

                foreach (var entry in errorMap)
                {
                    if (entry.Value.Count == 0)
                    {
                        continue;
                    }

                    IEnumerable <double> errors = entry.Value.Select((tuple) => tuple.Item2);
                    double meanResult           = entry.Value.Select(tuple => tuple.Item1).Average();
                    double meanError            = errors.Average();
                    double stdDev = Math.Sqrt(errors.Select((error) => error * error).Average() - meanError * meanError);
                    double time   = entry.Value.Select((tuple) => tuple.Item3).Average();

                    string line = string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}\t{11}\t{12}",
                                                entry.Key.Item1, // division
                                                entry.Key.Item2, // order
                                                entry.Key.Item3, // width
                                                entry.Key.Item4, // vanishing moments
                                                entry.Key.Item5, // continuous derivative
                                                meanResult.ToString(formatInfo),
                                                meanError.ToString(formatInfo),
                                                (meanError / testCase.Solution).ToString(formatInfo),
                                                stdDev.ToString(formatInfo),
                                                errors.Min().ToString(formatInfo),
                                                errors.Max().ToString(formatInfo),
                                                errors.IndexOfMax((d) => d) + 1,
                                                time.ToString(formatInfo));


                    log.WriteLine(line);
                }
            }

            globalWatch.Stop();
            Console.WriteLine("Finished case " + testCase.GetType().Name + " after " + globalWatch.ElapsedMilliseconds + "ms");

            return(dt);
        }
Exemple #41
0
        public static void Print(Modes.DecodedMode decMode, PeripheralDeviceTypes devType, byte[] vendorId)
        {
            DicConsole.WriteLine(Modes.PrettifyModeHeader(decMode.Header, devType));

            if (decMode.Pages == null)
            {
                return;
            }

            foreach (Modes.ModePage page in decMode.Pages)
            {
                //DicConsole.WriteLine("Page {0:X2}h subpage {1:X2}h is {2} bytes long", page.Page, page.Subpage, page.PageResponse.Length);
                switch (page.Page)
                {
                case 0x00:
                {
                    if (devType == PeripheralDeviceTypes.MultiMediaDevice && page.Subpage == 0)
                    {
                        DicConsole.WriteLine(Modes.PrettifyModePage_00_SFF(page.PageResponse));
                    }
                    else
                    {
                        if (page.Subpage != 0)
                        {
                            DicConsole.WriteLine("Found unknown vendor mode page {0:X2}h subpage {1:X2}h",
                                                 page.Page, page.Subpage);
                        }
                        else
                        {
                            DicConsole.WriteLine("Found unknown vendor mode page {0:X2}h", page.Page);
                        }
                    }

                    break;
                }

                case 0x01:
                {
                    if (page.Subpage == 0)
                    {
                        DicConsole.WriteLine(devType == PeripheralDeviceTypes.MultiMediaDevice
                                                     ? Modes.PrettifyModePage_01_MMC(page.PageResponse)
                                                     : Modes.PrettifyModePage_01(page.PageResponse));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x02:
                {
                    if (page.Subpage == 0)
                    {
                        DicConsole.WriteLine(Modes.PrettifyModePage_02(page.PageResponse));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x03:
                {
                    if (page.Subpage == 0)
                    {
                        DicConsole.WriteLine(Modes.PrettifyModePage_03(page.PageResponse));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x04:
                {
                    if (page.Subpage == 0)
                    {
                        DicConsole.WriteLine(Modes.PrettifyModePage_04(page.PageResponse));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x05:
                {
                    if (page.Subpage == 0)
                    {
                        DicConsole.WriteLine(Modes.PrettifyModePage_05(page.PageResponse));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x06:
                {
                    if (page.Subpage == 0)
                    {
                        DicConsole.WriteLine(Modes.PrettifyModePage_06(page.PageResponse));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x07:
                {
                    if (page.Subpage == 0)
                    {
                        DicConsole.WriteLine(devType == PeripheralDeviceTypes.MultiMediaDevice
                                                     ? Modes.PrettifyModePage_07_MMC(page.PageResponse)
                                                     : Modes.PrettifyModePage_07(page.PageResponse));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x08:
                {
                    if (page.Subpage == 0)
                    {
                        DicConsole.WriteLine(Modes.PrettifyModePage_08(page.PageResponse));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x0A:
                {
                    if (page.Subpage == 0)
                    {
                        DicConsole.WriteLine(Modes.PrettifyModePage_0A(page.PageResponse));
                    }
                    else if (page.Subpage == 1)
                    {
                        DicConsole.WriteLine(Modes.PrettifyModePage_0A_S01(page.PageResponse));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x0B:
                {
                    if (page.Subpage == 0)
                    {
                        DicConsole.WriteLine(Modes.PrettifyModePage_0B(page.PageResponse));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x0D:
                {
                    if (page.Subpage == 0)
                    {
                        DicConsole.WriteLine(Modes.PrettifyModePage_0D(page.PageResponse));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x0E:
                {
                    if (page.Subpage == 0)
                    {
                        DicConsole.WriteLine(Modes.PrettifyModePage_0E(page.PageResponse));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x0F:
                {
                    if (page.Subpage == 0)
                    {
                        DicConsole.WriteLine(Modes.PrettifyModePage_0F(page.PageResponse));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x10:
                {
                    if (page.Subpage == 0)
                    {
                        DicConsole.WriteLine(devType == PeripheralDeviceTypes.SequentialAccess
                                                     ? Modes.PrettifyModePage_10_SSC(page.PageResponse)
                                                     : Modes.PrettifyModePage_10(page.PageResponse));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x11:
                {
                    if (page.Subpage == 0)
                    {
                        DicConsole.WriteLine(Modes.PrettifyModePage_11(page.PageResponse));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x12:
                case 0x13:
                case 0x14:
                {
                    if (page.Subpage == 0)
                    {
                        DicConsole.WriteLine(Modes.PrettifyModePage_12_13_14(page.PageResponse));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x1A:
                {
                    if (page.Subpage == 0)
                    {
                        DicConsole.WriteLine(Modes.PrettifyModePage_1A(page.PageResponse));
                    }
                    else if (page.Subpage == 1)
                    {
                        DicConsole.WriteLine(Modes.PrettifyModePage_1A_S01(page.PageResponse));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x1B:
                {
                    if (page.Subpage == 0)
                    {
                        DicConsole.WriteLine(Modes.PrettifyModePage_1B(page.PageResponse));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x1C:
                {
                    if (page.Subpage == 0)
                    {
                        DicConsole.WriteLine(devType == PeripheralDeviceTypes.MultiMediaDevice
                                                     ? Modes.PrettifyModePage_1C_SFF(page.PageResponse)
                                                     : Modes.PrettifyModePage_1C(page.PageResponse));
                    }
                    else if (page.Subpage == 1)
                    {
                        DicConsole.WriteLine(Modes.PrettifyModePage_1C_S01(page.PageResponse));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x1D:
                {
                    if (page.Subpage == 0)
                    {
                        DicConsole.WriteLine(Modes.PrettifyModePage_1D(page.PageResponse));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x21:
                {
                    if (StringHandlers.CToString(vendorId).Trim() == "CERTANCE")
                    {
                        DicConsole.WriteLine(Modes.PrettifyCertanceModePage_21(page.PageResponse));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x22:
                {
                    if (StringHandlers.CToString(vendorId).Trim() == "CERTANCE")
                    {
                        DicConsole.WriteLine(Modes.PrettifyCertanceModePage_22(page.PageResponse));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x24:
                {
                    if (StringHandlers.CToString(vendorId).Trim() == "IBM")
                    {
                        DicConsole.WriteLine(Modes.PrettifyIBMModePage_24(page.PageResponse));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x2A:
                {
                    if (page.Subpage == 0)
                    {
                        DicConsole.WriteLine(Modes.PrettifyModePage_2A(page.PageResponse));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x2F:
                {
                    if (StringHandlers.CToString(vendorId).Trim() == "IBM")
                    {
                        DicConsole.WriteLine(Modes.PrettifyIBMModePage_2F(page.PageResponse));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x30:
                {
                    if (Modes.IsAppleModePage_30(page.PageResponse))
                    {
                        DicConsole.WriteLine("Drive identifies as Apple OEM drive");
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x3B:
                {
                    if (StringHandlers.CToString(vendorId).Trim() == "HP")
                    {
                        DicConsole.WriteLine(Modes.PrettifyHPModePage_3B(page.PageResponse));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x3C:
                {
                    if (StringHandlers.CToString(vendorId).Trim() == "HP")
                    {
                        DicConsole.WriteLine(Modes.PrettifyHPModePage_3C(page.PageResponse));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x3D:
                {
                    if (StringHandlers.CToString(vendorId).Trim() == "IBM")
                    {
                        DicConsole.WriteLine(Modes.PrettifyIBMModePage_3D(page.PageResponse));
                    }
                    else if (StringHandlers.CToString(vendorId).Trim() == "HP")
                    {
                        DicConsole.WriteLine(Modes.PrettifyHPModePage_3D(page.PageResponse));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                case 0x3E:
                {
                    if (StringHandlers.CToString(vendorId).Trim() == "FUJITSU")
                    {
                        DicConsole.WriteLine(Modes.PrettifyFujitsuModePage_3E(page.PageResponse));
                    }
                    else if (StringHandlers.CToString(vendorId).Trim() == "HP")
                    {
                        DicConsole.WriteLine(Modes.PrettifyHPModePage_3E(page.PageResponse));
                    }
                    else
                    {
                        goto default;
                    }

                    break;
                }

                default:
                {
                    if (page.Subpage != 0)
                    {
                        DicConsole.WriteLine("Found unknown mode page {0:X2}h subpage {1:X2}h", page.Page,
                                             page.Subpage);
                    }
                    else
                    {
                        DicConsole.WriteLine("Found unknown mode page {0:X2}h", page.Page);
                    }
                    break;
                }
                }
            }
        }
Exemple #42
0
        private Tuple <double, int, int> PerformConfiguration(
            Modes mode,
            int order,
            int division = 0,
            StreamWriter volumeNodesLog  = null,
            StreamWriter surfaceNodesLog = null,
            int leafDivisions            = -1,
            int vanishingMoment          = -1,
            int continuousDerivative     = -1,
            double width = double.NaN,
            double hBase = double.NaN,
            LineSegment.IRootFindingAlgorithm rootFindingAlgorithm = null,
            int logVolumeNodes_selectedCell = -1)
        {
            SubGrid cutCellGrid = levelSetTracker.Regions.GetCutCellSubGrid();

            IQuadRuleFactory <QuadRule> volumeFactory = null;
            IQuadRuleFactory <QuadRule> edgeFactory   = null;

            switch (mode)
            {
            case Modes.Standard:     //
            {
                volumeFactory = new StandardQuadRuleFactory(Grid.RefElements[0]);
                edgeFactory   = new StandardQuadRuleFactory(
                    Grid.RefElements[0].FaceRefElement);
                break;
            }

            case Modes.BruteForce:     //
            {
                volumeFactory = (IQuadRuleFactory <QuadRule>) new CutCellQuadRuleFactory(
                    new BruteForceSubdivisionStrategy(
                        Grid.RefElements[0], division),
                    order);
                edgeFactory = new CutCellQuadRuleFactory(
                    new BruteForceSubdivisionStrategy(
                        Grid.RefElements[0].FaceRefElement, division),
                    order);
                break;
            }

            case Modes.Adaptive:     //
            {
                volumeFactory = (IQuadRuleFactory <QuadRule>) new CutCellQuadRuleFactory(
                    new AdaptiveSubdivisionStrategy(
                        Grid.RefElements[0], levelSetTracker.DataHistories[0].Current, division),
                    leafDivisions);
                edgeFactory = new CutCellQuadRuleFactory(
                    new AdaptiveSubdivisionStrategy(
                        Grid.RefElements[0].FaceRefElement, levelSetTracker.DataHistories[0].Current, division),
                    leafDivisions);
                break;
            }

            case Modes.Regularized:     //
            {
                volumeFactory = new RegularizedQuadRuleFactory(
                    new StandardQuadRuleFactory(Grid.RefElements[0]),
                    levelSetTracker,
                    testCase.GetPolynomial(vanishingMoment, continuousDerivative),
                    0.5 * width * hBase);
                edgeFactory = null;
                break;
            }

            case Modes.HMFClassic:     //
            {
                IQuadRuleFactory <CellBoundaryQuadRule> volumeRuleFactoryEdge;
                if (Grid.SpatialDimension == 2)
                {
                    LineAndPointQuadratureFactory bndrule = new LineAndPointQuadratureFactory(
                        this.Grid.RefElements[0],
                        levelSetTracker.DataHistories[0].Current,
                        true,
                        rootFindingAlgorithm);

                    volumeRuleFactoryEdge = bndrule.GetLineFactory(true);

                    //volumeRuleFactoryEdge = new CutLineQuadRuleFactory(
                    //    levelSetTracker,
                    //    Grid.RefElements[0],
                    //    rootFindingAlgorithm: rootFindingAlgorithm);
                }
                else
                {
                    volumeRuleFactoryEdge = new LevelSetEdgeVolumeQuadRuleFactory(
                        levelSetTracker.DataHistories[0].Current,
                        rootFindingAlgorithm,
                        JumpTypes.Heaviside);
                }

                LevelSetSurfaceQuadRuleFactory surfaceFactory =
                    new LevelSetSurfaceQuadRuleFactory(
                        levelSetTracker.DataHistories[0].Current, volumeRuleFactoryEdge);


                if (testCase is ISurfaceTestCase)
                {
                    volumeFactory = surfaceFactory;
                }
                else
                {
                    volumeFactory = new LevelSetVolumeQuadRuleFactory(
                        levelSetTracker.DataHistories[0].Current,
                        volumeRuleFactoryEdge,
                        surfaceFactory,
                        JumpTypes.Heaviside);
                }
                edgeFactory = null;
                break;
            }

            case Modes.HMFOneStepGauss:     //
            {
                if (Grid.SpatialDimension != 2)
                {
                    throw new NotImplementedException();
                }

                LineAndPointQuadratureFactory bndrule = new LineAndPointQuadratureFactory(
                    this.Grid.RefElements[0],
                    levelSetTracker.DataHistories[0].Current,
                    true,
                    rootFindingAlgorithm);

                LevelSetComboRuleFactory2 Factory = new LevelSetComboRuleFactory2(
                    levelSetTracker.DataHistories[0].Current,
                    bndrule.GetLineFactory(true),
                    null,
                    _SurfaceNodesOnZeroLevset: false,
                    _UseAlsoStokes: false,
                    _DoCheck: false);

                if (testCase is ISurfaceTestCase)
                {
                    volumeFactory = Factory.GetSurfaceFactory();
                }
                else
                {
                    volumeFactory = Factory.GetVolumeFactory();
                }
                edgeFactory = null;

                break;
            }

            case Modes.HMFOneStepGaussAndStokes:     //
            {
                if (Grid.SpatialDimension != 2)
                {
                    throw new NotImplementedException();
                }

                LineAndPointQuadratureFactory bndrule = new LineAndPointQuadratureFactory(
                    this.Grid.RefElements[0],
                    levelSetTracker.DataHistories[0].Current,
                    true,
                    rootFindingAlgorithm);

                LevelSetComboRuleFactory2 Factory = new LevelSetComboRuleFactory2(
                    levelSetTracker.DataHistories[0].Current,
                    bndrule.GetLineFactory(true), bndrule.GetPointFactory(),
                    _SurfaceNodesOnZeroLevset: false,
                    _UseAlsoStokes: true,
                    _DoCheck: false);

                if (testCase is ISurfaceTestCase)
                {
                    volumeFactory = Factory.GetSurfaceFactory();
                }
                else
                {
                    volumeFactory = Factory.GetVolumeFactory();
                }
                edgeFactory = null;

                break;
            }

            case Modes.SayeGaussRules:     //
            {
                SayeGaussComboRuleFactory FactoryFactory = SayeFactories.SayeGaussRule_Combo(
                    levelSetTracker.DataHistories[0].Current,
                    rootFindingAlgorithm
                    );

                if (testCase is ISurfaceTestCase)
                {
                    volumeFactory = FactoryFactory.GetSurfaceFactory();
                }
                else
                {
                    volumeFactory = FactoryFactory.GetVolumeFactory();
                }

                edgeFactory = null;
                break;
            }

            case Modes.EquivalentPolynomials:     //
            {
                var lineAndPointFactory = new LineAndPointQuadratureFactory(
                    Grid.RefElements[0],
                    levelSetTracker.DataHistories[0].Current,
                    true,
                    rootFindingAlgorithm);
                if (testCase is ISurfaceTestCase)
                {
                    volumeFactory = new LinearReconstructionQuadRuleFactory(
                        levelSetTracker, lineAndPointFactory);
                }
                else
                {
                    volumeFactory = new EquivalentPolynomialQuadRuleFactory(
                        new StandardQuadRuleFactory(Grid.RefElements[0]),
                        levelSetTracker,
                        lineAndPointFactory);
                }

                edgeFactory = null;
                break;
            }
            }

            if (volumeNodesLog != null)
            {
                WriteVolumeNodes(volumeNodesLog, volumeFactory, order, cutCellGrid, testCase, logVolumeNodes_selectedCell);
            }

            if (surfaceNodesLog != null)
            {
                WriteSurfaceNodes(surfaceNodesLog, edgeFactory, order, cutCellGrid);
            }

            Stopwatch timer      = new Stopwatch();
            Stopwatch localTimer = new Stopwatch();
            double    result     = double.NaN;

            timer.Start();
            if (testCase is IVolumeTestCase ||
                mode == Modes.Regularized ||
                mode == Modes.HMFClassic ||
                mode == Modes.HMFOneStepGauss ||
                mode == Modes.HMFOneStepGaussAndStokes ||
                mode == Modes.EquivalentPolynomials ||
                mode == Modes.SayeGaussRules)
            {
                result = PerformVolumeQuadrature(
                    mode, volumeFactory, cutCellGrid, order, localTimer);
            }
            else
            {
                result = PerformSurfaceQuadrature(
                    mode, volumeFactory, edgeFactory, cutCellGrid, order, localTimer);
            }
            timer.Stop();

            return(new Tuple <double, int, int>(
                       result,
                       (int)timer.ElapsedMilliseconds,
                       (int)localTimer.ElapsedMilliseconds));
        }
 public void SetMode(Modes modo)
 {
 }
Exemple #44
0
        /// <summary>Retried errored sectors in CompactDisc</summary>
        /// <param name="audioExtents">Extents with audio sectors</param>
        /// <param name="blockSize">Size of the read sector in bytes</param>
        /// <param name="currentTry">Current dump hardware try</param>
        /// <param name="extents">Extents</param>
        /// <param name="offsetBytes">Read offset</param>
        /// <param name="readcd">Device supports READ CD</param>
        /// <param name="sectorsForOffset">Sectors needed to fix offset</param>
        /// <param name="subSize">Subchannel size in bytes</param>
        /// <param name="supportedSubchannel">Drive's maximum supported subchannel</param>
        /// <param name="supportsLongSectors">Supports reading EDC and ECC</param>
        /// <param name="totalDuration">Total commands duration</param>
        /// <param name="tracks">Disc tracks</param>
        /// <param name="subLog">Subchannel log</param>
        /// <param name="desiredSubchannel">Subchannel desired to save</param>
        /// <param name="isrcs">List of disc ISRCs</param>
        /// <param name="mcn">Disc media catalogue number</param>
        /// <param name="subchannelExtents">List of subchannels not yet dumped correctly</param>
        /// <param name="smallestPregapLbaPerTrack">List of smallest pregap relative address per track</param>
        void RetryCdUserData(ExtentsULong audioExtents, uint blockSize, DumpHardwareType currentTry,
                             ExtentsULong extents, int offsetBytes, bool readcd, int sectorsForOffset, uint subSize,
                             MmcSubchannel supportedSubchannel, ref double totalDuration, SubchannelLog subLog,
                             MmcSubchannel desiredSubchannel, Track[] tracks, Dictionary <byte, string> isrcs,
                             ref string mcn, HashSet <int> subchannelExtents,
                             Dictionary <byte, int> smallestPregapLbaPerTrack, bool supportsLongSectors)
        {
            bool sense = true;                   // Sense indicator

            byte[]     cmdBuf = null;            // Data buffer
            double     cmdDuration;              // Command execution time
            const uint sectorSize = 2352;        // Full sector size

            byte[]            senseBuf = null;   // Sense buffer
            PlextorSubchannel supportedPlextorSubchannel;

            switch (supportedSubchannel)
            {
            case MmcSubchannel.None:
                supportedPlextorSubchannel = PlextorSubchannel.None;

                break;

            case MmcSubchannel.Raw:
                supportedPlextorSubchannel = PlextorSubchannel.Pack;

                break;

            case MmcSubchannel.Q16:
                supportedPlextorSubchannel = PlextorSubchannel.Q16;

                break;

            default:
                supportedPlextorSubchannel = PlextorSubchannel.None;

                break;
            }

            if (_resume.BadBlocks.Count <= 0 ||
                _aborted ||
                _retryPasses <= 0)
            {
                return;
            }

            int  pass              = 1;
            bool forward           = true;
            bool runningPersistent = false;

            Modes.ModePage?currentModePage = null;
            byte[]         md6;
            byte[]         md10;

            if (_persistent)
            {
                Modes.ModePage_01_MMC pgMmc;

                sense = _dev.ModeSense6(out cmdBuf, out _, false, ScsiModeSensePageControl.Current, 0x01, _dev.Timeout,
                                        out _);

                if (sense)
                {
                    sense = _dev.ModeSense10(out cmdBuf, out _, false, ScsiModeSensePageControl.Current, 0x01,
                                             _dev.Timeout, out _);

                    if (!sense)
                    {
                        Modes.DecodedMode?dcMode10 =
                            Modes.DecodeMode10(cmdBuf, PeripheralDeviceTypes.MultiMediaDevice);

                        if (dcMode10?.Pages != null)
                        {
                            foreach (Modes.ModePage modePage in dcMode10.Value.Pages.Where(modePage =>
                                                                                           modePage.Page == 0x01 && modePage.Subpage == 0x00))
                            {
                                currentModePage = modePage;
                            }
                        }
                    }
                }
                else
                {
                    Modes.DecodedMode?dcMode6 = Modes.DecodeMode6(cmdBuf, PeripheralDeviceTypes.MultiMediaDevice);

                    if (dcMode6?.Pages != null)
                    {
                        foreach (Modes.ModePage modePage in dcMode6.Value.Pages.Where(modePage =>
                                                                                      modePage.Page == 0x01 && modePage.Subpage == 0x00))
                        {
                            currentModePage = modePage;
                        }
                    }
                }

                if (currentModePage == null)
                {
                    pgMmc = new Modes.ModePage_01_MMC
                    {
                        PS             = false,
                        ReadRetryCount = 32,
                        Parameter      = 0x00
                    };

                    currentModePage = new Modes.ModePage
                    {
                        Page         = 0x01,
                        Subpage      = 0x00,
                        PageResponse = Modes.EncodeModePage_01_MMC(pgMmc)
                    };
                }

                pgMmc = new Modes.ModePage_01_MMC
                {
                    PS             = false,
                    ReadRetryCount = 255,
                    Parameter      = 0x20
                };

                var md = new Modes.DecodedMode
                {
                    Header = new Modes.ModeHeader(),
                    Pages  = new[]
                    {
                        new Modes.ModePage
                        {
                            Page         = 0x01,
                            Subpage      = 0x00,
                            PageResponse = Modes.EncodeModePage_01_MMC(pgMmc)
                        }
                    }
                };

                md6  = Modes.EncodeMode6(md, _dev.ScsiType);
                md10 = Modes.EncodeMode10(md, _dev.ScsiType);

                UpdateStatus?.Invoke("Sending MODE SELECT to drive (return damaged blocks).");
                _dumpLog.WriteLine("Sending MODE SELECT to drive (return damaged blocks).");
                sense = _dev.ModeSelect(md6, out senseBuf, true, false, _dev.Timeout, out _);

                if (sense)
                {
                    sense = _dev.ModeSelect10(md10, out senseBuf, true, false, _dev.Timeout, out _);
                }

                if (sense)
                {
                    UpdateStatus?.
                    Invoke("Drive did not accept MODE SELECT command for persistent error reading, try another drive.");

                    AaruConsole.DebugWriteLine("Error: {0}", Sense.PrettifySense(senseBuf));

                    _dumpLog.WriteLine("Drive did not accept MODE SELECT command for persistent error reading, try another drive.");
                }
                else
                {
                    runningPersistent = true;
                }
            }

            InitProgress?.Invoke();
cdRepeatRetry:
            ulong[]      tmpArray = _resume.BadBlocks.ToArray();
            List <ulong> sectorsNotEvenPartial = new List <ulong>();

            for (int i = 0; i < tmpArray.Length; i++)
            {
                ulong badSector = tmpArray[i];

                if (_aborted)
                {
                    currentTry.Extents = ExtentsConverter.ToMetadata(extents);
                    _dumpLog.WriteLine("Aborted!");

                    break;
                }

                PulseProgress?.Invoke(string.Format("Retrying sector {0}, pass {1}, {3}{2}", badSector, pass,
                                                    forward ? "forward" : "reverse",
                                                    runningPersistent ? "recovering partial data, " : ""));

                Track track = tracks.OrderBy(t => t.TrackStartSector).
                              LastOrDefault(t => badSector >= t.TrackStartSector);

                byte sectorsToReRead   = 1;
                uint badSectorToReRead = (uint)badSector;

                if (_fixOffset &&
                    audioExtents.Contains(badSector) &&
                    offsetBytes != 0)
                {
                    if (offsetBytes > 0)
                    {
                        badSectorToReRead -= (uint)sectorsForOffset;
                    }

                    sectorsToReRead = (byte)(sectorsForOffset + 1);
                }

                if (_supportsPlextorD8 && audioExtents.Contains(badSector))
                {
                    sense = ReadPlextorWithSubchannel(out cmdBuf, out senseBuf, badSectorToReRead, blockSize,
                                                      sectorsToReRead, supportedPlextorSubchannel, out cmdDuration);

                    totalDuration += cmdDuration;
                }
                else if (readcd)
                {
                    sense = _dev.ReadCd(out cmdBuf, out senseBuf, badSectorToReRead, blockSize, sectorsToReRead,
                                        MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders, true,
                                        true, MmcErrorField.None, supportedSubchannel, _dev.Timeout, out cmdDuration);

                    totalDuration += cmdDuration;
                }

                if (sense || _dev.Error)
                {
                    _errorLog?.WriteLine(badSector, _dev.Error, _dev.LastError, senseBuf);

                    if (!runningPersistent)
                    {
                        continue;
                    }

                    DecodedSense?decSense = Sense.Decode(senseBuf);

                    // MEDIUM ERROR, retry with ignore error below
                    if (decSense.HasValue &&
                        decSense.Value.ASC == 0x11)
                    {
                        if (!sectorsNotEvenPartial.Contains(badSector))
                        {
                            sectorsNotEvenPartial.Add(badSector);
                        }
                    }
                }

                // Because one block has been partially used to fix the offset
                if (_fixOffset &&
                    audioExtents.Contains(badSector) &&
                    offsetBytes != 0)
                {
                    uint blocksToRead = sectorsToReRead;

                    FixOffsetData(offsetBytes, sectorSize, sectorsForOffset, supportedSubchannel, ref blocksToRead,
                                  subSize, ref cmdBuf, blockSize, false);
                }

                if (!sense &&
                    !_dev.Error)
                {
                    _resume.BadBlocks.Remove(badSector);
                    extents.Add(badSector);
                    UpdateStatus?.Invoke($"Correctly retried sector {badSector} in pass {pass}.");
                    _dumpLog.WriteLine("Correctly retried sector {0} in pass {1}.", badSector, pass);
                    sectorsNotEvenPartial.Remove(badSector);
                }
                else
                {
                    _errorLog?.WriteLine(badSector, _dev.Error, _dev.LastError, senseBuf);
                }

                if (supportedSubchannel != MmcSubchannel.None)
                {
                    byte[] data = new byte[sectorSize];
                    byte[] sub  = new byte[subSize];
                    Array.Copy(cmdBuf, 0, data, 0, sectorSize);
                    Array.Copy(cmdBuf, sectorSize, sub, 0, subSize);

                    if (supportsLongSectors)
                    {
                        _outputPlugin.WriteSectorLong(data, badSector);
                    }
                    else
                    {
                        _outputPlugin.WriteSector(Sector.GetUserData(data), badSector);
                    }

                    bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel,
                                                                                   desiredSubchannel, sub, badSector, 1, subLog, isrcs, (byte)track.TrackSequence, ref mcn,
                                                                                   tracks, subchannelExtents, _fixSubchannelPosition, _outputPlugin, _fixSubchannel,
                                                                                   _fixSubchannelCrc, _dumpLog, UpdateStatus, smallestPregapLbaPerTrack, true);

                    // Set tracks and go back
                    if (!indexesChanged)
                    {
                        continue;
                    }

                    (_outputPlugin as IWritableOpticalImage).SetTracks(tracks.ToList());
                    i--;
                }
                else
                {
                    if (supportsLongSectors)
                    {
                        _outputPlugin.WriteSectorLong(cmdBuf, badSector);
                    }
                    else
                    {
                        _outputPlugin.WriteSector(Sector.GetUserData(cmdBuf), badSector);
                    }
                }
            }

            if (pass < _retryPasses &&
                !_aborted &&
                _resume.BadBlocks.Count > 0)
            {
                pass++;
                forward = !forward;
                _resume.BadBlocks.Sort();

                if (!forward)
                {
                    _resume.BadBlocks.Reverse();
                }

                goto cdRepeatRetry;
            }

            EndProgress?.Invoke();

            // TODO: Enable when underlying images support lead-outs

            /*
             *  RetryCdLeadOuts(blocks, blockSize, ref currentSpeed, currentTry, extents, ibgLog, ref imageWriteDuration,
             *         leadOutExtents, ref maxSpeed, mhddLog, ref minSpeed, read6, read10, read12, read16, readcd,
             *         supportedSubchannel, subSize, ref totalDuration);
             */

            // Try to ignore read errors, on some drives this allows to recover partial even if damaged data
            if (_persistent && sectorsNotEvenPartial.Count > 0)
            {
                var pgMmc = new Modes.ModePage_01_MMC
                {
                    PS             = false,
                    ReadRetryCount = 255,
                    Parameter      = 0x01
                };

                var md = new Modes.DecodedMode
                {
                    Header = new Modes.ModeHeader(),
                    Pages  = new[]
                    {
                        new Modes.ModePage
                        {
                            Page         = 0x01,
                            Subpage      = 0x00,
                            PageResponse = Modes.EncodeModePage_01_MMC(pgMmc)
                        }
                    }
                };

                md6  = Modes.EncodeMode6(md, _dev.ScsiType);
                md10 = Modes.EncodeMode10(md, _dev.ScsiType);

                _dumpLog.WriteLine("Sending MODE SELECT to drive (ignore error correction).");
                sense = _dev.ModeSelect(md6, out senseBuf, true, false, _dev.Timeout, out _);

                if (sense)
                {
                    sense = _dev.ModeSelect10(md10, out senseBuf, true, false, _dev.Timeout, out _);
                }

                if (!sense)
                {
                    runningPersistent = true;

                    InitProgress?.Invoke();

                    for (int i = 0; i < sectorsNotEvenPartial.Count; i++)
                    {
                        ulong badSector = sectorsNotEvenPartial[i];

                        if (_aborted)
                        {
                            currentTry.Extents = ExtentsConverter.ToMetadata(extents);
                            _dumpLog.WriteLine("Aborted!");

                            break;
                        }

                        PulseProgress?.Invoke($"Trying to get partial data for sector {badSector}");

                        Track track = tracks.OrderBy(t => t.TrackStartSector).
                                      LastOrDefault(t => badSector >= t.TrackStartSector);

                        if (readcd)
                        {
                            sense = _dev.ReadCd(out cmdBuf, out senseBuf, (uint)badSector, blockSize, 1,
                                                MmcSectorTypes.AllTypes, false, false, true, MmcHeaderCodes.AllHeaders,
                                                true, true, MmcErrorField.None, supportedSubchannel, _dev.Timeout,
                                                out cmdDuration);

                            totalDuration += cmdDuration;
                        }

                        if (sense || _dev.Error)
                        {
                            _errorLog?.WriteLine(badSector, _dev.Error, _dev.LastError, senseBuf);

                            continue;
                        }

                        _dumpLog.WriteLine("Got partial data for sector {0} in pass {1}.", badSector, pass);

                        if (supportedSubchannel != MmcSubchannel.None)
                        {
                            byte[] data = new byte[sectorSize];
                            byte[] sub  = new byte[subSize];
                            Array.Copy(cmdBuf, 0, data, 0, sectorSize);
                            Array.Copy(cmdBuf, sectorSize, sub, 0, subSize);

                            if (supportsLongSectors)
                            {
                                _outputPlugin.WriteSectorLong(data, badSector);
                            }
                            else
                            {
                                _outputPlugin.WriteSector(Sector.GetUserData(data), badSector);
                            }

                            bool indexesChanged = Media.CompactDisc.WriteSubchannelToImage(supportedSubchannel,
                                                                                           desiredSubchannel, sub, badSector, 1, subLog, isrcs, (byte)track.TrackSequence,
                                                                                           ref mcn, tracks, subchannelExtents, _fixSubchannelPosition, _outputPlugin,
                                                                                           _fixSubchannel, _fixSubchannelCrc, _dumpLog, UpdateStatus,
                                                                                           smallestPregapLbaPerTrack, true);

                            // Set tracks and go back
                            if (indexesChanged)
                            {
                                (_outputPlugin as IWritableOpticalImage).SetTracks(tracks.ToList());
                                i--;
                            }
                        }
                        else
                        {
                            if (supportsLongSectors)
                            {
                                _outputPlugin.WriteSectorLong(cmdBuf, badSector);
                            }
                            else
                            {
                                _outputPlugin.WriteSector(Sector.GetUserData(cmdBuf), badSector);
                            }
                        }
                    }

                    EndProgress?.Invoke();
                }
            }

            if (runningPersistent && currentModePage.HasValue)
            {
                var md = new Modes.DecodedMode
                {
                    Header = new Modes.ModeHeader(),
                    Pages  = new[]
                    {
                        currentModePage.Value
                    }
                };

                md6  = Modes.EncodeMode6(md, _dev.ScsiType);
                md10 = Modes.EncodeMode10(md, _dev.ScsiType);

                _dumpLog.WriteLine("Sending MODE SELECT to drive (return device to previous status).");
                sense = _dev.ModeSelect(md6, out senseBuf, true, false, _dev.Timeout, out _);

                if (sense)
                {
                    _dev.ModeSelect10(md10, out senseBuf, true, false, _dev.Timeout, out _);
                }
            }

            EndProgress?.Invoke();
        }
Exemple #45
0
 /// <summary>
 /// Creates a new stream data set connected to the byte array
 /// data source provided.
 /// </summary>
 /// <param name="data">
 /// Byte array containing uncompressed data set.
 /// </param>
 /// <param name="mode">
 /// The mode of operation the data set will be using.
 /// </param>
 internal DataSet(byte[] data, Modes mode)
     : base(data, mode)
 {
 }
    public BombWrapper(Bomb bomb)
    {
        Bomb           = bomb;
        holdable       = bomb.GetComponentInChildren <FloatingHoldable>();
        timerComponent = bomb.GetTimer();
        widgetManager  = bomb.WidgetManager;

        Color modeColor = ModeColors[Tweaks.CurrentMode];

        BombStatus.Instance.TimerPrefab.color    = modeColor;
        timerComponent.text.color                = modeColor;
        timerComponent.StrikeIndicator.RedColour = modeColor;

        if (Tweaks.CurrentMode == Mode.Zen)
        {
            ZenModeTimePenalty = Mathf.Abs(Modes.settings.ZenModeTimePenalty);
            ZenModeTimerRate   = -timerComponent.GetRate();
            timerComponent.SetRateModifier(ZenModeTimerRate);
            Modes.initialTime = timerComponent.TimeRemaining;

            //This was in the original code to make sure the bomb didn't explode on the first strike
            bomb.NumStrikesToLose++;
        }

        foreach (BombComponent component in Bomb.BombComponents)
        {
            component.OnPass += delegate
            {
                BombStatus.Instance.UpdateSolves();

                if (Tweaks.CurrentMode == Mode.Time)
                {
                    if (!Modes.settings.ComponentValues.TryGetValue(Modes.GetModuleID(component), out double ComponentValue))
                    {
                        ComponentValue = 6;
                    }

                    Modes.settings.TotalModulesMultiplier.TryGetValue(Modes.GetModuleID(component), out double totalModulesMultiplier);

                    float time = (float)(Mathf.Min(Modes.Multiplier, Modes.settings.TimeModeMaxMultiplier) * (ComponentValue + Bomb.BombComponents.Count * totalModulesMultiplier));

                    CurrentTimer += Math.Max(Modes.settings.TimeModeMinimumTimeGained, time);

                    Modes.Multiplier += Modes.settings.TimeModeSolveBonus;
                    BombStatus.Instance.UpdateMultiplier();
                }

                return(false);
            };

            var OnStrike = component.OnStrike;
            component.OnStrike = (BombComponent source) =>
            {
                if (Tweaks.CurrentMode == Mode.Time)
                {
                    Modes.Multiplier = Math.Max(Modes.Multiplier - Modes.settings.TimeModeMultiplierStrikePenalty, Modes.settings.TimeModeMinMultiplier);
                    BombStatus.Instance.UpdateMultiplier();
                    if (CurrentTimer < (Modes.settings.TimeModeMinimumTimeLost / Modes.settings.TimeModeTimerStrikePenalty))
                    {
                        CurrentTimer -= Modes.settings.TimeModeMinimumTimeLost;
                    }
                    else
                    {
                        CurrentTimer -= CurrentTimer * Modes.settings.TimeModeTimerStrikePenalty;
                    }

                    // We can safely set the number of strikes to -1 since it's going to be increased by the game after us.
                    Bomb.NumStrikes = -1;
                }

                OnStrike(source);

                // These mode modifications need to happen after the game handles the strike since they change the timer rate.
                if (Tweaks.CurrentMode == Mode.Zen)
                {
                    bomb.NumStrikesToLose++;

                    ZenModeTimerRate = Mathf.Max(ZenModeTimerRate - Mathf.Abs(Modes.settings.ZenModeTimerSpeedUp), -Mathf.Abs(Modes.settings.ZenModeTimerMaxSpeed));
                    timerComponent.SetRateModifier(ZenModeTimerRate);

                    CurrentTimer       += ZenModeTimePenalty * 60;
                    ZenModeTimePenalty += Mathf.Abs(Modes.settings.ZenModeTimePenaltyIncrease);
                }

                if (Tweaks.CurrentMode == Mode.Steady)
                {
                    timerComponent.SetRateModifier(1);
                    CurrentTimer -= Modes.settings.SteadyModeFixedPenalty * 60 - Modes.settings.SteadyModePercentPenalty * bombStartingTimer;
                }

                BombStatus.Instance.UpdateStrikes();

                return(false);
            };
        }

        var moduleTweaks = new Dictionary <string, Func <BombComponent, ModuleTweak> >()
        {
            { "Emoji Math", bombComponent => new EmojiMathLogging(bombComponent) },
            { "Probing", bombComponent => new ProbingLogging(bombComponent) },
            { "SeaShells", bombComponent => new SeaShellsLogging(bombComponent) },
            { "switchModule", bombComponent => new SwitchesLogging(bombComponent) },
            { "WordScrambleModule", bombComponent => new WordScramblePatch(bombComponent) },

            { "Wires", bombComponent => new WiresLogging(bombComponent) },
            { "Keypad", bombComponent => new KeypadLogging(bombComponent) },
        };

        modules     = new string[bomb.Faces.Sum(face => face.Anchors.Count)];
        anchors     = new decimal[bomb.Faces.Sum(face => face.Anchors.Count)][];
        bombLogInfo = new Dictionary <string, object>()
        {
            { "serial", JsonConvert.DeserializeObject <Dictionary <string, string> >(bomb.WidgetManager.GetWidgetQueryResponses(KMBombInfo.QUERYKEY_GET_SERIAL_NUMBER, null)[0])["serial"] },
            { "displayNames", displayNames },
            { "ids", ids },
            { "anchors", anchors },
            { "modules", modules }
        };

        modulesUnactivated = bomb.BombComponents.Count;
        foreach (BombComponent component in bomb.BombComponents)
        {
            KMBombModule bombModule = component.GetComponent <KMBombModule>();
            if (bombModule != null)
            {
                switch (bombModule.ModuleType)
                {
                //TTK is our favorite Zen mode compatible module
                //Of course, everything here is repurposed from Twitch Plays.
                case "TurnTheKey":
                    new TTKComponentSolver(bombModule, bomb, Tweaks.CurrentMode.Equals(Mode.Zen) ? Modes.initialTime : timerComponent.TimeRemaining);
                    break;

                // Correct some mispositioned objects in older modules
                case "ForeignExchangeRates":
                case "resistors":
                case "CryptModule":
                case "LEDEnc":
                    // This fixes the position of the module itself (but keeps the status light in its original location, which fixes it)
                    component.transform.Find("Model").transform.localPosition = new Vector3(0.004f, 0, 0);
                    break;

                case "Listening":
                    // This fixes the Y-coordinate of the position of the status light
                    component.transform.Find("StatusLight").transform.localPosition = new Vector3(-0.0761f, 0.01986f, 0.075f);
                    break;

                case "TwoBits":
                case "errorCodes":
                    // This fixes the position of the status light
                    component.GetComponentInChildren <StatusLightParent>().transform.localPosition = new Vector3(0.075167f, 0.01986f, 0.076057f);
                    break;
                }
            }

            ModuleTweak moduleTweak = null;
            string      moduleType  = bombModule != null ? bombModule.ModuleType : component.ComponentType.ToString();
            if (moduleTweaks.ContainsKey(moduleType))
            {
                moduleTweak = moduleTweaks[moduleType](component);
            }

            component.StartCoroutine(GetModuleInformation(component, moduleTweak));

            if (component.ComponentType == ComponentTypeEnum.Mod)
            {
                ReflectedTypes.FindModeBoolean(component);
            }
        }
    }
Exemple #47
0
 /// <summary>
 /// Creates a new stream <see cref="DataSet"/> connected to the data
 /// file provided.
 /// </summary>
 /// <param name="fileName">
 /// Valid path to the uncompressed data set file.
 /// </param>
 /// <param name="lastModified">
 /// Date and time the source data was last modified.
 /// </param>
 /// <param name="mode">
 /// The mode of operation the data set will be using.
 /// </param>
 /// <param name="isTempFile">
 /// True if the file should be deleted when the source is disposed.
 /// </param>
 internal DataSet(string fileName, DateTime lastModified, Modes mode, bool isTempFile)
     : base(fileName, lastModified, mode, isTempFile)
 {
 }
Exemple #48
0
        public static void TranslatePageParametersToEntities(Process process, IDictionary <string, string> parameters, string defaultOutput)
        {
            var output = parameters.ContainsKey("output") ? parameters["output"] : defaultOutput;

            var isOutput = Outputs.Contains(output);
            var isMode   = Modes.Contains(output);

            foreach (var entity in process.Entities)
            {
                if (isMode)
                {
                    if (output == "map")
                    {
                        entity.Page = 1;
                        entity.Size = 0;
                    }
                    else
                    {
                        if (entity.Page > 0)
                        {
                            int page;
                            if (parameters.ContainsKey("page"))
                            {
                                if (!int.TryParse(parameters["page"], out page))
                                {
                                    page = 1;
                                }
                            }
                            else
                            {
                                page = 1;
                            }

                            entity.Page = page;

                            var size = 0;
                            if (parameters.ContainsKey("size"))
                            {
                                int.TryParse(parameters["size"], out size);
                            }

                            if (size > 0 || output == "page")
                            {
                                if (size == 0)
                                {
                                    size = DefaultPageSize;
                                }
                                entity.Size = size > 100 ? 100 : size;
                            }
                        }
                    }
                }
                else
                {
                    if (isOutput)
                    {
                        entity.Page = 0;
                        entity.Size = 0;
                    }
                    else      // unknown output request
                    {
                        entity.Page = 1;
                        entity.Size = 0;
                    }
                }
            }
        }
Exemple #49
0
 public PrintoutLogReceipt()
 {
     InitializeComponent();
     currentMode = Modes.GRVConfirmation;
 }
Exemple #50
0
 public Extract(Modes mode) : base()
 {
     this.mode = mode;
     SetFilter();
 }
Exemple #51
0
        public static void Main(string[] args)
        {
            if (args.Length < 3)
            {
                Console.WriteLine("Invalid number of arguments: expecting 2 or more!");
                return;
            }
            String path = null;

            for (int i = 0; i < args.Length; i++)
            {
                if (File.Exists(args[i]))
                {
                    path = args[i];
                    break;
                }
            }
            if (String.IsNullOrEmpty(path))
            {
                Console.WriteLine("Invalid argument: please specify an existing file!");
                return;
            }

            bool   before     = false;
            bool   after      = false;
            String before_str = null;
            String after_str  = null;
            Modes  mode       = Modes.NONE;

            for (int i = 0; i < args.Length; i++)
            {
                args[i] = args[i].Trim();

                if (
                    (
                        (
                            (args[i] == "-before" && !before) || (args[i] == "-after" && !after) // if arg is before/after and no before/after arg has been found yet
                        ) && (
                            args.Length <= (i + 1)                                               // but if there is no index after the arg
                            ||
                            (args[i + 1] == "-before" || args[i + 1] == "-after")                // or if the next arg is after/before instead of a timestamp
                            )
                    )
                    )
                {
                    // then -> invalid arg: no timestamp
                    Console.WriteLine("Invalid argument: no time stamp specified!");
                    return;
                }
                // if arg is before but before has already been found
                if ((args[i] == "-before" && before) || (args[i] == "-after" && after))
                {
                    // then skip
                    continue;
                }

                if (args[i] == "-before")
                {
                    before     = true;
                    before_str = args[i + 1];
                    mode       = Modes.BEFORE;
                }
                else if (args[i] == "-after")
                {
                    after     = true;
                    after_str = args[i + 1];
                    mode      = Modes.AFTER;
                }
            }
            if (before && after)
            {
                mode = Modes.BETWEEN;
            }
            if (!before && !after)
            {
                Console.WriteLine("Invalid argument: missing arguments!");
                return;
            }

            // first index: default before date: 1/1/1970
            // second index: default after date: 1/1/2500
            // if mistakenly not read from args[] then nothing will be deleted
            // since no bookmarks should have been created before 01 Jan 1970 or after 01 Jan 2500
            long[] dates = { 0, 16725225600 };

            if (before)
            {
                DateTime beforeT;
                if (String.IsNullOrEmpty(before_str) || !DateTime.TryParse(before_str, out beforeT))
                {
                    Console.WriteLine("Invalid argument: could not read 'before' timestamp!");
                    return;
                }

                dates[0] = ToUnixTime(new DateTime(beforeT.Ticks, DateTimeKind.Local));
            }

            if (after)
            {
                DateTime afterT;
                if (String.IsNullOrEmpty(after_str) || !DateTime.TryParse(after_str, out afterT))
                {
                    Console.WriteLine("Invalid argument: could not read 'after' timestamp!");
                    return;
                }

                dates[1] = ToUnixTime(new DateTime(afterT.Ticks, DateTimeKind.Local));
            }


            if (before && after && dates[0] < dates[1])
            {
                mode = Modes.EXCEPT;
            }

            ConsoleColor old = Console.ForegroundColor;

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("Mode: {0}", mode);
            Console.ForegroundColor = old;

            // if document isn't a netscape bookmarks file, quit
            String file_content = File.ReadAllText(path, Encoding.UTF8);
            String result       = file_content;

            if (file_content.Length == 0 || !file_content.Contains("<!DOCTYPE NETSCAPE-Bookmark-file-1>"))
            {
                Console.WriteLine("Invalid argument: file is empty or invalid.");
                return;
            }

            // regex (unescaped): /<a[^>^<]*add_date="(?'date'\d*)"[^>^<]*>[^>^<]*<\/a>/gmis
            Regex           bookmark_regex = new Regex("\\s*<dt><a[^>^<]*add_date=\"(?'date'\\d*)\"[^>^<]*>(?'title'[^>^<]*)<\\/a>\\s", RegexOptions.IgnoreCase | RegexOptions.Singleline);
            MatchCollection matches        = bookmark_regex.Matches(file_content);

            if (matches.Count == 0)
            {
                Console.WriteLine("No results found!");
                return;
            }

            foreach (Match m in matches)
            {
                if (!m.Groups["date"].Success || !m.Groups["title"].Success)
                {
                    continue;
                }

                long date = Int64.Parse(m.Groups["date"].Value);

                switch (mode)
                {
                case Modes.AFTER:
                    if (date > dates[1])
                    {
                        result = result.Replace(m.Value, "");
                        Console.WriteLine("REMOVED: {0}", m.Groups["title"].Value);
                    }
                    break;

                case Modes.BEFORE:
                    if (date < dates[0])
                    {
                        result = result.Replace(m.Value, "");
                        Console.WriteLine("REMOVED: {0}", m.Groups["title"].Value);
                    }
                    break;

                case Modes.BETWEEN:
                    if (date > dates[1] && date < dates[0])
                    {
                        result = result.Replace(m.Value, "");
                        Console.WriteLine("REMOVED: {0}", m.Groups["title"].Value);
                    }
                    break;

                case Modes.EXCEPT:
                    if (date < dates[0] || date > dates[1])
                    {
                        result = result.Replace(m.Value, "");
                        Console.WriteLine("REMOVED: {0}", m.Groups["title"].Value);
                    }
                    break;

                case Modes.NONE:
                default:
                    Console.WriteLine("An unknown error occured.");
                    break;
                }
            }
            File.WriteAllText(path, result, Encoding.UTF8);
            return;
        }
 public DaggerfallUnitySaveGameWindow(IUserInterfaceManager uiManager, Modes mode, DaggerfallBaseWindow previous = null, bool displayMostRecentChar = false)
     : base(uiManager, previous)
 {
     this.mode = mode;
     this.displayMostRecentChar = displayMostRecentChar;
 }
Exemple #53
0
 static SettingsMenus()
 {
     Menu = MainMenu.AddMenu(MenuName, MenuName.ToLower());
     Modes.Initialize();
 }
Exemple #54
0
        public static void Run(string path      = "", Modes mode = Modes.GetAllGuidelines,
                               bool verbose     = false,
                               bool preview     = false,
                               bool byFolder    = false,
                               bool chapterOnly = false)
        {
            /*var colorList = new List<ConsoleColor>{ConsoleColor.Blue, ConsoleColor.Green, ConsoleColor.Yellow,
             *  ConsoleColor.DarkCyan, ConsoleColor.DarkRed, ConsoleColor.Cyan};
             *
             * var intelliTectSplit = IntelliTect.Split(new[] {Environment.NewLine}, StringSplitOptions.None);
             * for (var index = 0; index < intelliTectSplit.Length; index++)
             * {
             *  string line = intelliTectSplit[index];
             *  ConsoleColor prevColor = Console.ForegroundColor;
             *  Console.ForegroundColor = colorList[index];
             *  Console.WriteLine(line);
             *  Console.ForegroundColor = prevColor;
             * }*/

            Console.WriteLine(IntelliTect);

            if (preview)
            {
                Console.WriteLine("Preview mode. Actions will not be taken");
            }

            if (string.IsNullOrWhiteSpace(path))
            {
                ConsoleColor foregroundColor = Console.ForegroundColor;
                Console.ForegroundColor = ConsoleColor.Yellow;
                path = Environment.CurrentDirectory;
                Console.WriteLine($"Path not specified. Using working directory: {path}");
                Console.ForegroundColor = foregroundColor;
            }

            switch (mode)
            {
            case Modes.GetAllGuidelines:
                Console.WriteLine($"Getting all Guidelines from the documents found in: {path}");
                // GuidelinesFormatter.AllGuidelinesToMarkDown(path, verbose);
                break;

            /*  case Modes.TestGeneration:
             *    var generatedTests
             *        = ListingManager.GenerateUnitTests(path, TestGeneration_Interactive, true);
             *    if (verbose)
             *    {
             *        Console.WriteLine($"{generatedTests.Count} tests generated");
             *    }
             *    break;
             * case Modes.ScanForMismatchedListings:
             *    var extraListings = ListingManager.GetAllExtraListings(path).OrderBy(x => x);
             *
             *    Console.WriteLine("---Extra Listings---");
             *    foreach (string extraListing in extraListings)
             *    {
             *        Console.WriteLine(extraListing);
             *    }
             *    break;*/
            default:
                Console.WriteLine($"Mode ({mode}) does not exist. Exiting");
                break;
            }
        }
Exemple #55
0
 static DrawingMenu()
 {
     Menu = MainMenu.AddMenu(MenuName, MenuName);
     Menu.AddGroupLabel("Hoşgeldin LightAmumu!");
     Modes.Initialize();
 }
Exemple #56
0
 public ScriptEngine(Modes mode) : this()
 {
     _mode = mode;
 }
Exemple #57
0
 public Extract(Extract filter) : base(filter)
 {
     this.mode = filter.mode;
     SetFilter();
 }
Exemple #58
0
        public static void Log(LogLevel level, string message, int additionalEntrySeparators = 0, bool additionalEntrySeparatorsLogFileOnlyMode = true, [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumber = -1)
        {
            try
            {
                if (Modes.Count == 0 || !IsOn())
                {
                    return;
                }

                if (level < MinimumLevel)
                {
                    return;
                }

                message = Guard.Correct(message);
                var category = string.IsNullOrWhiteSpace(callerFilePath) ? "" : $"{EnvironmentHelpers.ExtractFileName(callerFilePath)} ({callerLineNumber})";

                var messageBuilder = new StringBuilder();
                messageBuilder.Append($"{DateTime.UtcNow.ToLocalTime():yyyy-MM-dd HH:mm:ss} {level.ToString().ToUpperInvariant()}\t");

                if (message.Length == 0)
                {
                    if (category.Length == 0)                     // If both empty. It probably never happens though.
                    {
                        messageBuilder.Append($"{EntrySeparator}");
                    }
                    else                     // If only the message is empty.
                    {
                        messageBuilder.Append($"{category}{EntrySeparator}");
                    }
                }
                else
                {
                    if (category.Length == 0)                     // If only the category is empty.
                    {
                        messageBuilder.Append($"{message}{EntrySeparator}");
                    }
                    else                     // If none of them empty.
                    {
                        messageBuilder.Append($"{category}\t{message}{EntrySeparator}");
                    }
                }

                var finalMessage = messageBuilder.ToString();

                for (int i = 0; i < additionalEntrySeparators; i++)
                {
                    messageBuilder.Insert(0, EntrySeparator);
                }

                var finalFileMessage = messageBuilder.ToString();
                if (!additionalEntrySeparatorsLogFileOnlyMode)
                {
                    finalMessage = finalFileMessage;
                }

                lock (Lock)
                {
                    if (Modes.Contains(LogMode.Console))
                    {
                        lock (Console.Out)
                        {
                            var color = Console.ForegroundColor;
                            switch (level)
                            {
                            case LogLevel.Warning:
                                color = ConsoleColor.Yellow;
                                break;

                            case LogLevel.Error:
                            case LogLevel.Critical:
                                color = ConsoleColor.Red;
                                break;

                            default:
                                break;                                         // Keep original color.
                            }

                            Console.ForegroundColor = color;
                            Console.Write(finalMessage);
                            Console.ResetColor();
                        }
                    }

                    if (Modes.Contains(LogMode.Console))
                    {
                        Debug.Write(finalMessage);
                    }

                    if (!Modes.Contains(LogMode.File))
                    {
                        return;
                    }

                    IoHelpers.EnsureContainingDirectoryExists(FilePath);

                    if (File.Exists(FilePath))
                    {
                        var sizeInBytes = new FileInfo(FilePath).Length;
                        if (sizeInBytes > 1000 * MaximumLogFileSize)
                        {
                            File.Delete(FilePath);
                        }
                    }

                    File.AppendAllText(FilePath, finalFileMessage);
                }
            }
            catch (Exception ex)
            {
                if (Interlocked.Increment(ref LoggingFailedCount) == 1)                 // If it only failed the first time, try log the failure.
                {
                    LogDebug($"Logging failed: {ex}");
                }
                // If logging the failure is successful then clear the failure counter.
                // If it's not the first time the logging failed, then we do not try to log logging failure, so clear the failure counter.
                Interlocked.Exchange(ref LoggingFailedCount, 0);
            }
        }
Exemple #59
0
 private void Awake()
 {
     mode = Modes.Fixed;
     x    = Random.Range(-radius_max, radius_max);
     z    = Random.Range(-radius_max, radius_max);
 }
Exemple #60
0
 static Config()
 {
     Menu = MainMenu.AddMenu(MenuName, MenuName.ToLower());
     Menu.AddGroupLabel("KA " + Player.Instance.ChampionName);
     Modes.Initialize();
 }