ToString() public method

public ToString ( ) : string
return string
        static void LoadRom(string fileName, UInt16 memoryAddress)
        {
            BinaryReader reader = new BinaryReader(File.Open(fileName, FileMode.Open));
            int pos = 0;
            UInt16 index = memoryAddress;

            int length = (int)reader.BaseStream.Length;
            try
            {
                while (pos < length)
                {
                    byte[] word = reader.ReadBytes(2);
                    if (BitConverter.IsLittleEndian)
                        Array.Reverse(word);

                    UInt16 data = BitConverter.ToUInt16(word, 0);
                    //UInt16 data = reader.ReadUInt16();
                    Console.Write(data.ToString("X") + ":");
                    MasterComponent.Instance.MemoryMap.Write16BitsToAddress(index, data);
                    pos += sizeof(UInt16);
                    index += 1;
                }

                Console.WriteLine("Loaded rom " + fileName + " into 0x" + memoryAddress.ToString("X"));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error loading rom " + fileName + " into 0x" + memoryAddress.ToString("X"));
                Console.WriteLine(ex);
            }
            reader.Close();
        }
        public TelemetryPacket(String telemetry)
        {
            isPayload = checkIfFromPayload(telemetry); // This should be done first before conversions

            temperature = getShortInt(telemetry.Substring(TEMPERATURE_IDX, 4)) * 0.1; // unvonverted temp is in 0.1 celsious
            altitude = getShortInt(telemetry.Substring(ALT_IDX, 4))*0.1; // Altitude expected is in 100m's
            missionTime = getUShortInt(telemetry.Substring(MISSION_TIME_IDx, 4));
            packetCount = getUShortInt(telemetry.Substring(PACKET_COUNT_IDX, 4));
            batVoltage = getShortInt(telemetry.Substring(SOURCE_VOLT_IDX,4));

            lux = getUnsignedShortInt(telemetry.Substring(LUM_IDX,4))*16;

            payloadDeployed = telemetry.Substring(PAYLOAD_DEPLOYED_IDX, 1) == "F";
            umbrellaDeployed = telemetry.Substring(UMBRELLA_DEPLOYED_IDX, 1) == "F";

            packetArray = new String[] {
                TEAM_ID,
                packetCount.ToString(),
                missionTime.ToString(),
                altitude.ToString("F1"),
                temperature.ToString("F1"),
                batVoltage.ToString("F1"),
                lux.ToString()
            };

            packetString = String.Join(",",packetArray);
        }
Example #3
0
        public static String GetFormatName(UInt16 format)
        {
            // registered Clipboard formats
            var name = GetRegisteredFormatName(format);
            if (name != null)
            {
                return name;
            }

            // standard Clipboard formats
            var standardFormats = Enum.GetValues(typeof(ClipboardFormats));
            foreach (var standardFormat in standardFormats)
            {
                if ((UInt16)standardFormat == format)
                {
                    return standardFormat.ToString();
                }
            }

            // private Clipboard formats
            if ((format > Win32Api.CF_PRIVATEFIRST) && (format < Win32Api.CF_PRIVATELAST))
            {
                return String.Format("CF_PRIVATEFIRST + {0}", format - Win32Api.CF_PRIVATEFIRST);
            }
            else if ((format > Win32Api.CF_GDIOBJFIRST) && (format < Win32Api.CF_GDIOBJLAST))
            {
                return String.Format("CF_GDIOBJFIRST + {0}", format - Win32Api.CF_PRIVATEFIRST);
            }

            return format.ToString();
        }
Example #4
0
    public bool DoPosTest(string testDesc, string id, UInt16 uintA, string format, String expectedValue, NumberFormatInfo _NFI)
    {
        bool retVal = true;
        string errorDesc;

        string actualValue;

        TestLibrary.TestFramework.BeginScenario(testDesc);
        try
        {
            actualValue = uintA.ToString(format, _NFI);

            if (actualValue != expectedValue)
            {
                errorDesc =
                    string.Format("The string representation of {0} is not the value {1} as expected: actual({2})",
                    uintA, expectedValue, actualValue);
                errorDesc += "\nThe format info is \"" + ((format == null) ? "null" : format) + "\" speicifed";
                TestLibrary.TestFramework.LogError(id + "_001", errorDesc);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            errorDesc = "Unexpect exception:" + e;
            errorDesc += "\nThe UInt16 integer is " + uintA + ", format info is \"" + format + "\" speicifed.";
            TestLibrary.TestFramework.LogError(id + "_002", errorDesc);
            retVal = false;
        }
        return retVal;
    }
        public UInt16 Read16BitsFromAddress(UInt16 address)
        {
            UInt16 returnValue = 0;

            if (address >= 0 && address <= 0x7F) // note for some reason the STIC only actually uses the range from 0 to 0x3F
                returnValue = MasterComponent.Instance.STIC.Read(address); // STIC REGISTERS
            else if (address >= 0x0100 && address <= 0x01EF)
                returnValue = _scratchpadRAM.Read(address - 0x0100);
            else if (address >= 0x01F0 && address <= 0x01FF)
                returnValue = MasterComponent.Instance.PSG.Read(address - 0x01F0); // not totally sure this needs to be subtracting
            else if (address >= 0x0200 && address <= 0x035F)
                returnValue = _systemRAM.Read(address - 0x0200);
            else if (address >= 0x1000 && address <= 0x1FFF)
                returnValue = _executiveROM.Read(address - 0x1000);
            else if (address >= 0x3000 && address <= 0x37FF)
                returnValue = _graphicsROM.Read(address - 0x3000);
            else if (address >= 0x3800 && address <= 0x39FF)
                returnValue = _graphicsRAM.Read(address - 0x3800);
            else
                returnValue = _cartridge.Read(address - 0x3A00);

            Console.WriteLine("   RD a=0x" + address.ToString("X") + " v=0x" + returnValue.ToString("X") + ", " + Convert.ToString(returnValue, 2).PadLeft(8, '0'));

            return returnValue;
        }
Example #6
0
 public void addAbility(Int32 abilityID, UInt16 slotID, UInt32 charID, UInt16 level, UInt16 is_loaded)
 {
     string theQuery = "INSERT INTO char_abilities SET char_id='" + charID.ToString()  + "', slot='" + slotID.ToString() + "', ability_id='" + abilityID.ToString() + "', level='" + level.ToString() + "', is_loaded='" + is_loaded.ToString() + "', added=NOW() ";
     conn.Open();
     queryExecuter = conn.CreateCommand();
     queryExecuter.CommandText = theQuery;
     queryExecuter.ExecuteNonQuery();
     conn.Close();
 }
Example #7
0
        public void addItemToInventory(UInt16 slotId, UInt32 itemGoID)
        {
            UInt32 charID = Store.currentClient.playerData.getCharID();

            string sqlQuery = "INSERT INTO inventory SET charId = '" + charID.ToString() + "' , goid = '" + itemGoID.ToString() + "', slot = '" + slotId.ToString() + "', created = NOW() ";
            queryExecuter = conn.CreateCommand();
            queryExecuter.CommandText = sqlQuery;
            queryExecuter.ExecuteNonQuery();
        }
Example #8
0
        private void ChangeMapProperties()
        {
            MapPropertiesDialog mapDialog = new MapPropertiesDialog();

            mapDialog.MapName = mapName;
            mapDialog.BitmapPath = bitmapPath;
            mapDialog.TileWidth = tileWidth;
            mapDialog.TileHeight = tileHeight;
            mapDialog.MapWidth = mapWidth;
            mapDialog.MapHeight = mapHeight;

            if (mapDialog.ShowDialog() == DialogResult.OK)
            {
                tileWidth = mapDialog.TileWidth;
                tileHeight = mapDialog.TileHeight;
                mapWidth = mapDialog.MapWidth;
                mapHeight = mapDialog.MapHeight;

                twLabel.Text = tileWidth.ToString() + " px";
                thLabel.Text = tileHeight.ToString() + " px";
                mwLabel.Text = mapWidth.ToString() + " x " + tileWidth.ToString() + " px";
                mhLabel.Text = mapHeight.ToString() + " x " + tileHeight.ToString() + " px";

                tileContainer.ResetParameters();
                map.ResetParameters();

                tileContainer.SetParameters(tileBitmap, tileWidth, tileHeight);
                try
                {
                    map.SetParameters(tileWidth, tileHeight, mapWidth, mapHeight, mapDialog.BaseTiles, tileBitmap, tileContainer, mapObjects, objectContainer);
                }
                catch (Exception)
                {
                    MessageBox.Show(Utils.ERROR_CREATING_MAP, Utils.APP_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    CloseMap();
                    return;
                }
            }

            mapDialog = null;
        }
Example #9
0
 public static string getParam(byte tp,UInt16 vl,OProg prog)
 {
     if (tp == ARG_STR)
     {
         foreach (OProg.OString s in prog.strings)
             if (s.ofs == vl)
                 return "s" + s.id.ToString();
         throw new Exception("String Not Found "+vl.ToString("X4"));
     }
     string res = "";
     switch (tp)
     {
         case ARG_IMM: res = "i"; break;
         case ARG_WORD: res = "w"; break;
         case ARG_BYTE: res = "b"; break;
         case ARG_CODE: res = "c"; break;
         default:
             throw new Exception("Anknown arg type " + tp.ToString());
     }
     res += vl.ToString("X4");
     return res;
 }
 public Ingredient_Instant(UInt16 Id, UInt16 stm, EvoRecipe rcp,ObservableCollection<CanisterUnit> a)
 {
     _RecipeInfo = rcp;
     _StartTime = stm;
     _ID = Id;
     _CanisterUnit = a;
     _IngredientInfo = new IngredientInfo(IngredientType.INSTANTPOWDER);
     SetIngredientInfo(_IngredientInfo, (IngredientInfo)_RecipeInfo._lstIngredientInfo.First(c => c.ID == _ID));
     InitializeComponent();
     this.DataContext = _IngredientInfo;
     tbstm.Text = stm.ToString();
     fillpowder();
     ReloadCanisterIngredient();
 }
        public Ingredient_FilterBrew(UInt16 Id,UInt16 stm,EvoRecipe rcp)
        {
           // _EvoRecipe = (EvoRecipe)Function.XmlSerializer.LoadFromXml("EVO.Ingredient.xml", typeof(EvoRecipe));
            _RecipeInfo = rcp;
            _StartTime = stm;
            _ID = Id;
            _IngredientInfo = new IngredientInfo(IngredientType.FILTERBREW);
            SetIngredientInfo(_IngredientInfo, (IngredientInfo)_RecipeInfo._lstIngredientInfo.First(c => c.ID == _ID));
            InitializeComponent();
            this.DataContext = _IngredientInfo;
            tbstm.Text = stm.ToString();
            tbpkg1.Text = Function.GetBeanType(_IngredientInfo._FilterBrew.Grind1Type);
            tbpkg2.Text = Function.GetBeanType(_IngredientInfo._FilterBrew.Grind2Type);

        }
Example #12
0
        private void btnFindDevice_Click(object sender, EventArgs e)
        {
            try
            {
                done = false;
                Bootloader.Connect();
                PageSize = Bootloader.PageSize;
                FlashSize = Bootloader.FlashSize;

                Logger.Write("Connected");
            #if DEBUG
                Logger.Write("Page Size: " + PageSize.ToString() + " bytes");
                Logger.Write("Flash Size: " + FlashSize.ToString() + " bytes");
            #endif

                this.btnLocateFirmware.Enabled = true;
                this.btnFindDevice.Enabled = false;
            }
            catch (DeviceNotFoundException)
            {
                try
                {
                    Device dev = new Device();
                    dev.Connect();
                    Logger.Write("Rebooting device into firmware update mode...");
                    dev.RebootToBootloader();
                    dev.Disconnect();
                    while (wait) /* Wait for device to reboot and be enumerated by the OS */
                    {
                        System.Threading.Thread.Sleep(200);
                        Application.DoEvents();
                    }
                    wait = true;
                    btnFindDevice_Click(null, null);
                }
                catch (DeviceNotFoundException)
                {
                    done = true;
                    Logger.Write("Device not found!");
                }
                catch (NullReferenceException)
                {
                    done = true;
                    Logger.Write("Device not found!");
                }
            }
        }
        public void Write16BitsToAddress(UInt16 address, UInt16 value)
        {
            Console.WriteLine("   WR a=0x" + address.ToString("X") + " v=0x" + value.ToString("X"));

            if (address >= 0 && address <= 0x7F) // note for some reason the STIC only actually uses the range from 0 to 0x3F
                MasterComponent.Instance.STIC.Write(address, value); // STIC REGISTERS
            else if (address >= 0x0100 && address <= 0x01EF)
                _scratchpadRAM.Write(address - 0x100, value);
            else if (address >= 0x01F0 && address <= 0x01FF)
                MasterComponent.Instance.PSG.Write(address - 0x01F0, value); // not totally sure this needs to be subtracting
            else if (address >= 0x0200 && address <= 0x035F)
                _systemRAM.Write(address - 0x0200, value);
            else if (address >= 0x1000 && address <= 0x1FFF)
                _executiveROM.Write(address - 0x1000, value);
            else if (address >= 0x3000 && address <= 0x37FF)
                _graphicsROM.Write(address - 0x3000, value);
            else if (address >= 0x3800 && address <= 0x39FF)
                _graphicsRAM.Write(address - 0x3800, value);
            else
                _cartridge.Write(address - 0x3A00, value);
        }
Example #14
0
		public static string ToString(UInt16 value)
		{
			return value.ToString(CultureInfo.InvariantCulture);
		}
Example #15
0
        public void updateSourceHlForObjectTracking(UInt16 sourceDistrict, UInt16 sourceHl, UInt32 lastObjectId)
        {
            string sqlQuery = "SELECT id,HardlineId, DistrictId, objectId FROM data_hardlines WHERE DistrictId = '" + sourceDistrict.ToString() + "' AND HardlineId = '" + sourceHl.ToString() + "' LIMIT 1";
            queryExecuter = conn.CreateCommand();
            queryExecuter.CommandText = sqlQuery;
            dr = queryExecuter.ExecuteReader();

            UInt16 theId = 0;
            UInt16 hardlineId = 0;
            UInt16 districtId = 0;
            UInt32 objectId = 0;

            while (dr.Read())
            {
                theId = (UInt16)dr.GetInt16(0);
                hardlineId = (UInt16)dr.GetInt16(1);
                districtId = (UInt16)dr.GetInt16(2);
                objectId = (UInt32)dr.GetInt32(3);

            }

            dr.Close();

            if (objectId == 0 || objectId != lastObjectId)
                {
                    string updateQuery = "UPDATE data_hardlines SET objectId = '" + lastObjectId.ToString() + "' WHERE id = '" + theId.ToString() + "' LIMIT 1";
                    queryExecuter = conn.CreateCommand();
                    queryExecuter.CommandText = updateQuery;
                    queryExecuter.ExecuteNonQuery();
                    Output.WriteLine("[WORLD DB] UPDATE Hardline " + hardlineId.ToString() + " in District " + districtId.ToString() + " with Object ID : "+lastObjectId.ToString());
                }
        }
Example #16
0
        public void updateLocationByHL(UInt16 district, UInt16 hardline)
        {
            string sqlQuery = "SELECT DH.X,DH.Y,DH.Z,DH.ROT,DIS.key,DH.DistrictId FROM data_hardlines AS DH, districts as DIS WHERE DH.DistrictId = '" + district.ToString() + "' AND DH.HardLineId = '" + hardline.ToString() + "' AND DH.DistrictId=DIS.id ";
            queryExecuter = conn.CreateCommand();
            queryExecuter.CommandText = sqlQuery;
            dr = queryExecuter.ExecuteReader();

            while (dr.Read()){
                double x = (double)(dr.GetFloat(0));
                double y = (double)(dr.GetFloat(1));
                double z = (double)(dr.GetFloat(2));
                string disKey = dr.GetString(4);
                Output.WriteLine("USER DIS IS NOW " + disKey);
                Store.currentClient.playerData.setDistrict(disKey);
                Store.currentClient.playerData.setDistrictId((uint)dr.GetInt16(5));
                Store.currentClient.playerInstance.Position.setValue(NumericalUtils.doublesToLtVector3d(x, y, z));
                //Store.currentClient.playerInstance.YawInterval.setValue((byte)dr.GetDecimal(3));
            }
            dr.Close();
            savePlayer(Store.currentClient);
        }
Example #17
0
        public void updateInventorySlot(UInt16 sourceSlot, UInt16 destSlot)
        {
            UInt32 charID = Store.currentClient.playerData.getCharID();

            string sqlQuery = "UPDATE inventory SET slot = '" + destSlot.ToString() + "' WHERE slot = '" + sourceSlot.ToString() + "' AND charID = '" + charID.ToString() + "' LIMIT 1";
            queryExecuter = conn.CreateCommand();
            queryExecuter.CommandText = sqlQuery;
            queryExecuter.ExecuteNonQuery();
        }
Example #18
0
        private static bool CheckCacheForNPC(UInt16 intCreatureID)
        {
            // Calculate Reverse ID
            String strHexID = intCreatureID.ToString("X");
            byte[] npc = new byte[2];

            // This is the important part!
            // The two addresses (2 x 8 bits, where each address is 8 bits of 2 Hexadecimal values)
            // are in reverse order, so we reverse them to get the equivalent decimal NPC ID.
            npc[0] = Convert.ToByte(strHexID.Substring(2, 2), 16);
            npc[1] = Convert.ToByte(strHexID.Substring(0, 2), 16);

            // Search for NPC ID in WDB.
            using (FileStream stream = new FileStream(strWoWCache, FileMode.Open))
            {
                using (BinaryReader reader = new BinaryReader(stream))
                {
                    byte[] data = new byte[2];
                    data[0] = reader.ReadByte();
                    data[1] = reader.ReadByte();
                    // The WDB preamble won't include an NPC ID, so this first buffer need not be checked.
                    // We can go on and start doing comparisons and ignore the first buffer.

                    try
                    {
                        while (true)
                        {
                            // Shift our "register" by one bit.
                            data[0] = data[1];
                            data[1] = reader.ReadByte();

                            if (data[0] == npc[0]
                                && data[1] == npc[1])
                            {
                                reader.Close();
                                stream.Close();
                                return true;
                            }
                        }

                    }
                    catch (EndOfStreamException)
                    {
                        reader.Close();
                        stream.Close();
                        return false;
                    }

                }
            }
        }
Example #19
0
        public void SMAP_Write16(UInt32 addr, UInt16 value)
        {
            if (addr >= DEV9Header.SMAP_BD_TX_BASE && addr < (DEV9Header.SMAP_BD_TX_BASE + DEV9Header.SMAP_BD_SIZE))
            {
                Log_Verb("SMAP : Generic TX 16bit write " + value.ToString("X"));
                if (dev9.bdSwap != 0)
                    value = (UInt16)((value >> 8) | (value << 8));
                dev9.Dev9Wu16((int)addr, value);
                return;
            }
            else if (addr >= DEV9Header.SMAP_BD_RX_BASE && addr < (DEV9Header.SMAP_BD_RX_BASE + DEV9Header.SMAP_BD_SIZE))
            {
                Log_Verb("SMAP : Generic RX 16bit write " + value.ToString("X"));
                //int rx_index = (int)((addr - DEV9Header.SMAP_BD_RX_BASE) >> 3);
                if (dev9.bdSwap != 0)
                    value = (UInt16)((value >> 8) | (value << 8));
                dev9.Dev9Wu16((int)addr, value);
                return;
            }

            switch (addr)
            {
                case DEV9Header.SMAP_R_RXFIFO_RD_PTR:
                    Log_Verb("SMAP: SMAP_R_RXFIFO_RD_PTR 16bit write " + value.ToString("X"));
                    dev9.Dev9Wu16((int)addr, value);
                    break;
                case DEV9Header.SMAP_R_RXFIFO_SIZE:
                    Log_Verb("SMAP: SMAP_R_34 16bit write " + value.ToString("X"));
                    dev9.Dev9Wu16((int)addr, value);
                    break;
                case DEV9Header.SMAP_R_INTR_CLR:
                    Log_Verb("SMAP: SMAP_R_INTR_CLR 16bit write " + value.ToString("X"));
                    dev9.irqCause &= ~value;
                    return;

                case DEV9Header.SMAP_R_TXFIFO_WR_PTR:
                    Log_Verb("SMAP: SMAP_R_TXFIFO_WR_PTR 16bit write " + value.ToString("X"));
                    dev9.Dev9Wu16((int)addr, value);
                    return;
                case DEV9Header.SMAP_R_TXFIFO_SIZE:
                    Log_Verb("SMAP: SMAP_R_TXFIFO_SIZE 16bit write " + value.ToString("X"));
                    dev9.Dev9Wu16((int)addr, value);
                    break;
                //handle L writes
                //#define EMAC3_L_WRITE(name) \
                //    case name: \
                //        DEV9_LOG("SMAP: " #name " 16 bit write %x\n", value); \
                //        dev9Ru16(addr) = value; \
                //        return;
                case DEV9Header.SMAP_R_EMAC3_MODE0_L:
                    Log_Verb("SMAP: SMAP_R_EMAC3_SMAP_R_EMAC3_MODE0_L 16bit write " + value.ToString("X"));
                    dev9.Dev9Wu16((int)addr, value);
                    return;
                case DEV9Header.SMAP_R_EMAC3_MODE1_L:
                    Log_Verb("SMAP: SMAP_R_EMAC3_SMAP_R_EMAC3_MODE1_L 16bit write " + value.ToString("X"));
                    dev9.Dev9Wu16((int)addr, value);
                    return;
                case DEV9Header.SMAP_R_EMAC3_TxMODE0_L:
                case DEV9Header.SMAP_R_EMAC3_TxMODE1_L:
                case DEV9Header.SMAP_R_EMAC3_RxMODE_L:
                case DEV9Header.SMAP_R_EMAC3_INTR_STAT_L:
                case DEV9Header.SMAP_R_EMAC3_INTR_ENABLE_L:
                case DEV9Header.SMAP_R_EMAC3_ADDR_HI_L:
                case DEV9Header.SMAP_R_EMAC3_ADDR_LO_L:
                case DEV9Header.SMAP_R_EMAC3_VLAN_TPID:
                case DEV9Header.SMAP_R_EMAC3_PAUSE_TIMER_L:
                case DEV9Header.SMAP_R_EMAC3_INDIVID_HASH1:
                case DEV9Header.SMAP_R_EMAC3_INDIVID_HASH2:
                case DEV9Header.SMAP_R_EMAC3_INDIVID_HASH3:
                case DEV9Header.SMAP_R_EMAC3_INDIVID_HASH4:
                case DEV9Header.SMAP_R_EMAC3_GROUP_HASH1:
                case DEV9Header.SMAP_R_EMAC3_GROUP_HASH2:
                case DEV9Header.SMAP_R_EMAC3_GROUP_HASH3:
                case DEV9Header.SMAP_R_EMAC3_GROUP_HASH4:

                case DEV9Header.SMAP_R_EMAC3_LAST_SA_HI:
                case DEV9Header.SMAP_R_EMAC3_LAST_SA_LO:
                case DEV9Header.SMAP_R_EMAC3_INTER_FRAME_GAP_L:
                case DEV9Header.SMAP_R_EMAC3_STA_CTRL_L:
                case DEV9Header.SMAP_R_EMAC3_TX_THRESHOLD_L:
                case DEV9Header.SMAP_R_EMAC3_RX_WATERMARK_L:
                case DEV9Header.SMAP_R_EMAC3_TX_OCTETS:
                case DEV9Header.SMAP_R_EMAC3_RX_OCTETS:
                    Log_Verb("SMAP: SMAP_R_EMAC3_***(L_Write) 16bit write " + value.ToString("X"));
                    //Look at all that logging I'm not doing
                    dev9.Dev9Wu16((int)addr, value);
                    return;

                //#define EMAC3_H_WRITE(name) \
                //    case name: \
                //        DEV9_LOG("SMAP: " #name " 16 bit write %x\n", value); \
                //        dev9Ru16(addr) = value; \
                //        emac3_write(addr-2); \
                //        return;
                //handle H writes
                case DEV9Header.SMAP_R_EMAC3_MODE0_H:
                case DEV9Header.SMAP_R_EMAC3_MODE1_H:
                case DEV9Header.SMAP_R_EMAC3_TxMODE0_H:
                case DEV9Header.SMAP_R_EMAC3_TxMODE1_H:
                case DEV9Header.SMAP_R_EMAC3_RxMODE_H:
                case DEV9Header.SMAP_R_EMAC3_INTR_STAT_H:
                case DEV9Header.SMAP_R_EMAC3_INTR_ENABLE_H:
                case DEV9Header.SMAP_R_EMAC3_ADDR_HI_H:
                case DEV9Header.SMAP_R_EMAC3_ADDR_LO_H:
                case DEV9Header.SMAP_R_EMAC3_VLAN_TPID + 2:
                case DEV9Header.SMAP_R_EMAC3_PAUSE_TIMER_H:
                case DEV9Header.SMAP_R_EMAC3_INDIVID_HASH1 + 2:
                case DEV9Header.SMAP_R_EMAC3_INDIVID_HASH2 + 2:
                case DEV9Header.SMAP_R_EMAC3_INDIVID_HASH3 + 2:
                case DEV9Header.SMAP_R_EMAC3_INDIVID_HASH4 + 2:
                case DEV9Header.SMAP_R_EMAC3_GROUP_HASH1 + 2:
                case DEV9Header.SMAP_R_EMAC3_GROUP_HASH2 + 2:
                case DEV9Header.SMAP_R_EMAC3_GROUP_HASH3 + 2:
                case DEV9Header.SMAP_R_EMAC3_GROUP_HASH4 + 2:

                case DEV9Header.SMAP_R_EMAC3_LAST_SA_HI + 2:
                case DEV9Header.SMAP_R_EMAC3_LAST_SA_LO + 2:
                case DEV9Header.SMAP_R_EMAC3_INTER_FRAME_GAP_H:
                case DEV9Header.SMAP_R_EMAC3_STA_CTRL_H:
                case DEV9Header.SMAP_R_EMAC3_TX_THRESHOLD_H:
                case DEV9Header.SMAP_R_EMAC3_RX_WATERMARK_H:
                case DEV9Header.SMAP_R_EMAC3_TX_OCTETS + 2:
                case DEV9Header.SMAP_R_EMAC3_RX_OCTETS + 2:
                    // DEV9_LOG("SMAP: " #name " 16 bit write %x\n", value); \
                    Log_Verb("SMAP: SMAP_R_EMAC3_***(H_Write) 16bit write " + value.ToString("X"));
                    dev9.Dev9Wu16((int)addr, value);
                    EMAC3_Write(addr - 2);
                    return;

                default:
                    Log_Error("SMAP : Unknown 16 bit write @" + addr.ToString("X8") + ",v=" + value.ToString("X"));
                    dev9.Dev9Wu16((int)addr, value);
                    return;
            }

            // CLR_DEV9.DEV9_LOG("SMAP : error , 16 bit write @ %X,v=%X\n", addr, value);
            //DEV9Header.dev9Wu16((int)addr, value);
        }
Example #20
0
 /// <summary>
 /// Converts the value of the specified 16-bit unsigned integer to its equivalent SqlString representation.
 /// </summary>
 /// <param name="value">A 16-bit unsigned integer.</param>
 /// <returns>The SqlString equivalent of the 16-bit unsigned integer value.</returns>
 
 public static SqlString ToSqlString(UInt16 value) { return value.ToString(); }
Example #21
0
 /// <summary>
 /// Converts the value of the specified nullable 16-bit unsigned integer to its equivalent SqlString representation.
 /// </summary>
 /// <param name="value">A nullable 16-bit unsigned integer.</param>
 /// <returns>The SqlString equivalent of the nullable 16-bit unsigned integer value.</returns>
 
 public static SqlString ToSqlString(UInt16? value) { return value.HasValue ? value.ToString() : SqlString.Null; }
Example #22
0
		public static SqlString ToSqlString(UInt16          p) { return p.ToString();                                                                     }
Example #23
0
 /// <summary>
 /// Converts the value of the specified nullable 16-bit unsigned integer to its equivalent SqlChars representation.
 /// </summary>
 /// <param name="value">A nullable 16-bit unsigned integer.</param>
 /// <returns>The equivalent SqlChars.</returns>
 
 public static SqlChars ToSqlChars(UInt16? value) { return value.HasValue ? new SqlChars(value.ToString().ToCharArray()) : SqlChars.Null; }
Example #24
0
		public static SqlChars ToSqlChars(UInt16? p)         { return p.HasValue? new SqlChars(p.ToString().ToCharArray()): SqlChars.Null; }
 public void CheckUInt16(UInt16 value, string format)
 {
     var parsed = Format.Parse(format);
     var formatter = new StringFormatter(pool);
     formatter.Append(value, parsed);
     var result = formatter.ToString();
     var clrResult = value.ToString(format, CultureInfo.InvariantCulture);
     Assert.Equal(clrResult, result);
 }
Example #26
0
        //
        //? 0x000B80
        //? 0x008000
        //? 0x008B80
        //? 0x010000
        //0x014000
        //0x038B80
        //0x040000
        public ChecksumResult tdi41_checksum_search(byte[] file_buffer, UInt32 file_size, bool debug)
        {
            bool first_pass = true;
            UInt32 chk_oldvalue, chk_value, chk_start_addr, chk_end_addr;
            //UInt32[] chk_array = new UInt32[7] { 0x000B80, 0x008000, 0x008B80, 0x010000, 0x014000, 0x38B80, 0x40000 };
            UInt32[] chk_array = new UInt32[7] { 0x00000, 0x000B80, 0x008000, 0x030000, 0x038000, 0x038B80, 0x40000 };
            UInt16 seed_a = 0, seed_b = 0;

            chk_found = 0;
            chk_fixed = 0;

            for (; chk_found < chk_array.Length-1; chk_found++)
            {
                chk_start_addr = chk_array[chk_found];
                chk_end_addr = chk_array[chk_found + 1];
                if (!first_pass)
                {
                    seed_a |= 0x8631;
                    seed_b |= 0xEFCD;
                }

                chk_oldvalue = ((UInt32)file_buffer[chk_end_addr - 1] << 24)
                             + ((UInt32)file_buffer[chk_end_addr - 2] << 16)
                             + ((UInt32)file_buffer[chk_end_addr - 3] << 8)
                             + (UInt32)file_buffer[chk_end_addr - 4];

                chk_value = tdi41_checksum_calculate(file_buffer, chk_start_addr, chk_end_addr - 4, seed_a, seed_b);
                Console.WriteLine("chks " + chk_start_addr.ToString("X8") + "-" + chk_end_addr.ToString("X8") + " file: " + chk_oldvalue.ToString("X8") + " calc: " + chk_value.ToString("X8"));

                if (chk_oldvalue != chk_value && chk_oldvalue != 0xC3C3C3C3 )
                {
                    file_buffer[chk_end_addr - 4] = Convert.ToByte(chk_value & 0x000000ff);
                    file_buffer[chk_end_addr - 3] = Convert.ToByte((chk_value >> 8) & 0x000000ff);
                    file_buffer[chk_end_addr - 2] = Convert.ToByte((chk_value >> 16) & 0x000000ff);
                    file_buffer[chk_end_addr - 1] = Convert.ToByte((chk_value >> 24) & 0x000000ff);
                    Console.WriteLine("Checksum at address " + chk_end_addr.ToString("X8") + " failed");
                    chk_fixed++;
                }

                first_pass = false;
            }

            if (chk_fixed == 0) return ChecksumResult.ChecksumOK;
            else if (chk_fixed >= 8) return ChecksumResult.ChecksumTypeError;
            Console.WriteLine("chkfix: " + chk_fixed.ToString());
            return ChecksumResult.ChecksumFail;
        }
Example #27
0
 /// <summary> Adds a command argument. </summary>
 /// <param name="argument"> The argument. </param>
 public void AddArgument(UInt16 argument)
 {
     _arguments.Add(argument.ToString(CultureInfo.InvariantCulture));
 }
Example #28
0
 public Exceptional<DirectoryObject> GetObjectsDirectory(GraphDBType myTypeOfDBObject, UInt16 shard)
 {
     return _IGraphFSSession.GetFSObject<DirectoryObject>(new ObjectLocation(myTypeOfDBObject.ObjectLocation, DBConstants.DBObjectsLocation, shard.ToString()));
 }
Example #29
0
        public ChecksumResult tdi41_2002_checksum_search(byte[] file_buffer, UInt32 file_size, bool debug)
        {
            UInt32 seed_1, seed_2;
            UInt16 seed_1_msb, seed_1_lsb, seed_2_lsb, seed_2_msb;

            UInt32 chk_oldvalue, chk_value, chk_start_addr, chk_end_addr, chk_store_addr;

            chk_found = 2;
            chk_fixed = 0;

            // Find seed 1
            seed_1 = tdi41_2002_checksum_calculate(file_buffer, 0x14000, 0x4bffe, 0x8631, 0xefcd, 0, 0, true);
            seed_1_msb = (UInt16)(seed_1 >> 16);
            seed_1_lsb = (UInt16)seed_1;

            // Find seed 2
            seed_2 = tdi41_2002_checksum_calculate(file_buffer, 0, 0x7ffe, 0, 0, 0, 0, true);
            seed_2_msb = (UInt16)(seed_2 >> 16);
            seed_2_lsb = (UInt16)seed_2;

            // checksum 1
            chk_oldvalue = ((UInt32)file_buffer[0xffff] << 24)
                         + ((UInt32)file_buffer[0xfffe] << 16)
                         + ((UInt32)file_buffer[0xfffd] << 8)
                         + (UInt32)file_buffer[0xfffc];

            chk_value = tdi41_2002_checksum_calculate(file_buffer, 0x8000, 0xfffb, seed_2_lsb, seed_2_msb, 0x4531, 0x3550, false);

            if (chk_oldvalue != chk_value)
            {
                file_buffer[0xfffc] = Convert.ToByte(chk_value & 0x000000ff);
                file_buffer[0xfffd] = Convert.ToByte((chk_value >> 8) & 0x000000ff);
                file_buffer[0xfffe] = Convert.ToByte((chk_value >> 16) & 0x000000ff);
                file_buffer[0xffff] = Convert.ToByte((chk_value >> 24) & 0x000000ff);

                chk_fixed++;
            }

            // Checksum 2
            chk_oldvalue = ((UInt32)file_buffer[0x13fff] << 24)
                         + ((UInt32)file_buffer[0x13ffe] << 16)
                         + ((UInt32)file_buffer[0x13ffd] << 8)
                         + (UInt32)file_buffer[0x13ffc];

            chk_value = tdi41_2002_checksum_calculate(file_buffer, 0x10000, 0x13ffb, 0, 0, 0x8631, 0xefcd, false);

            if (chk_oldvalue != chk_value)
            {
                file_buffer[0x13ffc] = Convert.ToByte(chk_value & 0x000000ff);
                file_buffer[0x13ffd] = Convert.ToByte((chk_value >> 8) & 0x000000ff);
                file_buffer[0x13ffe] = Convert.ToByte((chk_value >> 16) & 0x000000ff);
                file_buffer[0x13fff] = Convert.ToByte((chk_value >> 24) & 0x000000ff);

                chk_fixed++;
            }

            // Checksum blocks loop
            chk_store_addr = 0x4fffb;
            do
            {
                if ((file_buffer[chk_store_addr + 13] == 0x56) &&   //V
                    (file_buffer[chk_store_addr + 14] == 0x34) &&   //4
                    (file_buffer[chk_store_addr + 15] == 0x2e) &&   //.
                    (file_buffer[chk_store_addr + 16] == 0x31))     //1
                {
                    // Checksum
                    chk_start_addr = chk_store_addr - 0x3ffb;
                    chk_end_addr = chk_store_addr;

                    chk_oldvalue = ((UInt32)file_buffer[chk_store_addr + 4] << 24)
                                 + ((UInt32)file_buffer[chk_store_addr + 3] << 16)
                                 + ((UInt32)file_buffer[chk_store_addr + 2] << 8)
                                 + (UInt32)file_buffer[chk_store_addr + 1];

                    chk_value = tdi41_2002_checksum_calculate(file_buffer, chk_start_addr, chk_end_addr, seed_1_lsb, seed_1_msb, seed_1_lsb, seed_1_msb, false);

                    if (chk_oldvalue != chk_value)
                    {
                        file_buffer[chk_store_addr + 1] = Convert.ToByte(chk_value & 0x000000ff);
                        file_buffer[chk_store_addr + 2] = Convert.ToByte((chk_value >> 8) & 0x000000ff);
                        file_buffer[chk_store_addr + 3] = Convert.ToByte((chk_value >> 16) & 0x000000ff);
                        file_buffer[chk_store_addr + 4] = Convert.ToByte((chk_value >> 24) & 0x000000ff);

                        chk_fixed++;
                    }

                    // Checksum
                    chk_start_addr = chk_store_addr + 5;
                    chk_end_addr = chk_store_addr + 0xb80;

                    chk_oldvalue = ((UInt32)file_buffer[chk_store_addr + 2948] << 24)
                                 + ((UInt32)file_buffer[chk_store_addr + 2947] << 16)
                                 + ((UInt32)file_buffer[chk_store_addr + 2946] << 8)
                                 + (UInt32)file_buffer[chk_store_addr + 2945];

                    chk_value = tdi41_2002_checksum_calculate(file_buffer, chk_start_addr, chk_end_addr, seed_1_lsb, seed_1_msb, seed_1_lsb, seed_1_msb, false);

                    if (chk_oldvalue != chk_value)
                    {
                        file_buffer[chk_store_addr + 2945] = Convert.ToByte(chk_value & 0x000000ff);
                        file_buffer[chk_store_addr + 2946] = Convert.ToByte((chk_value >> 8) & 0x000000ff);
                        file_buffer[chk_store_addr + 2947] = Convert.ToByte((chk_value >> 16) & 0x000000ff);
                        file_buffer[chk_store_addr + 2948] = Convert.ToByte((chk_value >> 24) & 0x000000ff);

                        chk_fixed++;
                    }

                    // Checksum
                    chk_start_addr = chk_store_addr + 0xb85;
                    chk_end_addr = chk_store_addr + 0xc000;

                    chk_oldvalue = ((UInt32)file_buffer[chk_store_addr + 49156] << 24)
                                 + ((UInt32)file_buffer[chk_store_addr + 49155] << 16)
                                 + ((UInt32)file_buffer[chk_store_addr + 49154] << 8)
                                 + (UInt32)file_buffer[chk_store_addr + 49153];

                    chk_value = tdi41_2002_checksum_calculate(file_buffer, chk_start_addr, chk_end_addr, seed_1_lsb, seed_1_msb, seed_1_lsb, seed_1_msb, false);

                    if (chk_oldvalue != chk_value)
                    {
                        file_buffer[chk_store_addr + 49153] = Convert.ToByte(chk_value & 0x000000ff);
                        file_buffer[chk_store_addr + 49154] = Convert.ToByte((chk_value >> 8) & 0x000000ff);
                        file_buffer[chk_store_addr + 49155] = Convert.ToByte((chk_value >> 16) & 0x000000ff);
                        file_buffer[chk_store_addr + 49156] = Convert.ToByte((chk_value >> 24) & 0x000000ff);

                        chk_fixed++;
                    }

                    chk_found += 3;
                }

                chk_store_addr += 0x10000;
            } while (chk_store_addr + 5 < file_size);
            if (chk_fixed == 0) return ChecksumResult.ChecksumOK;
            else if (chk_fixed >= 8) return ChecksumResult.ChecksumTypeError;
            Console.WriteLine("chkfix: " + chk_fixed.ToString());
            return ChecksumResult.ChecksumFail;
        }
	private void UpdateBatteryInfo(UInt16 level){
		double fraction = ((double)level)/((double)9000.0);
		if(fraction > 9000.0)
			fraction = 9000.0;
		batteryProgressbar.Fraction = fraction;
		batteryProgressbar.Text = level.ToString() + " mV";
	}