ToString() public method

public ToString ( ) : string
return string
Exemplo n.º 1
0
        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 string AnalogInput(int portNumber)
        //{
        //    if (ADResolution > 16)
        //    {
        //        ULStat = DaqBoard.AIn32(portNumber, AcutalRange, out DataValue32, Options);
        //        return DataValue32.ToString();
        //    }
        //    else
        //    {
        //        ULStat = DaqBoard.AIn(portNumber, AcutalRange, out DataValue);
        //        return DataValue.ToString();

        //    }
        //}


        /// <summary>
        /// input a analog value,the range is 5volts
        /// </summary>
        /// <param name="portNumber"></param>
        /// <param name="EngUnits"></param>
        /// <returns></returns>
        public string AnalogInput(int portNumber, out float EngUnits)
        {
            ULStat = DaqBoard.AIn(portNumber, Range.Bip5Volts, out DataValue);

            ULStat = DaqBoard.ToEngUnits(Range.Bip5Volts, DataValue, out EngUnits);


            return(DataValue.ToString());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Expand Results File Name : Helper
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public virtual string GetExpandedResultsFileNameHelper(
            string fileName)
        {
            System.UInt16 sessionId       = this.SessionId;
            string        dir             = System.IO.Path.GetDirectoryName(fileName);
            string        tempFileName    = System.IO.Path.GetFileName(fileName);
            string        sessionIdString = sessionId.ToString("000");

            tempFileName = tempFileName.Replace('.', '_');
            const string postfix   = "res";
            const string extension = ".xml";

            System.Collections.ArrayList fileNameElementsArray =
                new System.Collections.ArrayList();
            if (sessionIdString != string.Empty)
            {
                fileNameElementsArray.Add(sessionIdString);
            }
            if (tempFileName != string.Empty)
            {
                fileNameElementsArray.Add(tempFileName);
            }
            if (postfix != string.Empty)
            {
                fileNameElementsArray.Add(postfix);
            }
            string[] fileNameElements =
                (string[])fileNameElementsArray.ToArray(typeof(string));
            tempFileName = string.Join("_", fileNameElements);
            tempFileName = System.IO.Path.ChangeExtension(tempFileName, extension);
            tempFileName = System.IO.Path.Combine(dir, tempFileName);
            return(tempFileName);
        }
Exemplo n.º 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;
    }
Exemplo n.º 5
0
        public override void RenderModel(double deltaTime, float t)
        {
            SetModel(ItemId.ToString());

            Model.Gravity        = 0.04f;
            Model.Drag           = new Vector3(0.95f, 0.98f, 0.95f);
            Model.GroundFriction = new Vector3(0.6f, 1f, 0.6f);
            Model.GroundBounce   = new Vector3(0f, 0.5f, 0f);

            bool sprite = BlockInfo.Draw[ItemId] == DrawType.Sprite;

            if (!sprite)
            {
                this.ModelScale = new Vector3(1 / 4f, 1 / 4f, 1 / 4f);
            }
            else
            {
                this.ModelScale = new Vector3(1 / 2f, 1 / 2f, 1 / 2f);
            }
            Model.RecalcProperties(this);
            UpdateModelBounds();
            Position = Vector3.Lerp(interp.prev.Pos, interp.next.Pos, t);
            if (!sprite)
            {
                interp.LerpAngles(t);
            }
            else
            {
                this.RotY = game.LocalPlayer.HeadY - 45f;
            }
            anim.GetCurrentAnimState(t);
            Model.Render(this);
        }
        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;
        }
Exemplo n.º 7
0
 /// <summary>
 /// Write Configuration data in XML format to the XML Text Writer.
 /// </summary>
 /// <param name="writer">XML Text Writer</param>
 public override void WriteXmlConfig(XmlTextWriter writer)
 {
     writer.WriteStartElement("Hl7PeerToPeerConfiguration");
     writer.WriteStartElement("FromActor");
     writer.WriteStartElement("ActorName");
     writer.WriteElementString("ActorType", ActorTypes.Type(FromActorName.Type));
     writer.WriteElementString("ActorId", FromActorName.Id);
     writer.WriteEndElement();
     writer.WriteElementString("AeTitle", FromActorAeTitle);
     writer.WriteEndElement();
     writer.WriteStartElement("ToActor");
     writer.WriteStartElement("ActorName");
     writer.WriteElementString("ActorType", ActorTypes.Type(ToActorName.Type));
     writer.WriteElementString("ActorId", ToActorName.Id);
     writer.WriteEndElement();
     writer.WriteElementString("AeTitle", ToActorAeTitle);
     writer.WriteElementString("IpAddress", ToActorIpAddress);
     writer.WriteEndElement();
     writer.WriteElementString("PortNumber", PortNumber.ToString());
     writer.WriteElementString("MessageDelimiters", MessageDelimiters.ToString());
     writer.WriteElementString("SecureConnection", SecureConnection.ToString());
     writer.WriteElementString("AutoValidate", AutoValidate.ToString());
     writer.WriteElementString("ActorOption1", ActorOption1);
     writer.WriteElementString("ActorOption2", ActorOption2);
     writer.WriteElementString("ActorOption3", ActorOption3);
     writer.WriteElementString("SessionId", _sessionId.ToString());
     writer.WriteEndElement();
 }
Exemplo n.º 8
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();
        }
        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);
        }
Exemplo n.º 10
0
 public override void WriteXmlConfig(XmlTextWriter writer)
 {
     writer.WriteStartElement("PeerIheActorDicomConfiguration");
     writer.WriteElementString("ActorName", ActorNames.Name(ActorName));
     writer.WriteElementString("SessionId", _sessionId.ToString());
     writer.WriteStartElement("DvtNode");
     writer.WriteElementString("AeTitle", _dvtNode.AeTitle);
     writer.WriteElementString("IpAddress", _dvtNode.IpAddress);
     writer.WriteElementString("PortNumber", _dvtNode.PortNumber.ToString());
     writer.WriteEndElement();
     writer.WriteStartElement("SutNode");
     writer.WriteElementString("AeTitle", _sutNode.AeTitle);
     writer.WriteElementString("IpAddress", _sutNode.IpAddress);
     writer.WriteElementString("PortNumber", _sutNode.PortNumber.ToString());
     writer.WriteEndElement();
     writer.WriteElementString("DataDirectory", _dataDirectory);
     writer.WriteElementString("StoreData", _storeData.ToString());
     writer.WriteStartElement("DefinitionFiles");
     foreach (System.String defintionFilename in _definitionFiles)
     {
         writer.WriteElementString("DefinitionFile", defintionFilename);
     }
     writer.WriteEndElement();
     writer.WriteElementString("ResultsRootDirectory", _resultsRootDirectory);
     writer.WriteEndElement();
 }
Exemplo n.º 11
0
 public override string ToString()
 {
     return("MThd: " + MThd.ToString()
            + " header_length:" + header_length.ToString()
            + " format: " + format.ToString()
            + " # tracks: " + number_of_tracks.ToString()
            + " division" + division.ToString());
 }
Exemplo n.º 12
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();
        }
Exemplo n.º 13
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();
 }
Exemplo n.º 14
0
        public static TMD DownloadTMD(Uri nusbase, ulong titleid, u16 version)
        {
            Stream download = Download(nusbase, titleid, "tmd." + version.ToString());

            TMD tmd = TMD.Create(download);

            download.Close();

            return(tmd);
        }
Exemplo n.º 15
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;
        }
Exemplo n.º 16
0
        private void VerifyFingerPrint()
        {
            uint16_t fingerID = 0;
            uint16_t score    = 0;
            int      stat     = 0;

            while (true)
            {
                stat = HDFingerprintHelper.StartVerify(FpHandle, "finger.bmp", ref fingerID, ref score);
                Invoke(new UiProcessFunction(UpdateLabel), new object[] { "指纹编号" + fingerID.ToString() + " 得分 " + score.ToString() + " 状态码 " + stat.ToString() });
            }
        }
 public string AnalogInput(int portNumber)
 {
     if (ADResolution > 16)
     {
         ULStat = DaqBoard.AIn32(portNumber, AcutalRange, out DataValue32, Options);
         return(DataValue32.ToString());
     }
     else
     {
         ULStat = DaqBoard.AIn(portNumber, AcutalRange, out DataValue);
         return(DataValue.ToString());
     }
 }
Exemplo n.º 18
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;
 }
Exemplo n.º 19
0
        static StackObject *ToString_5(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.UInt16 instance_of_this_method = GetInstance(__domain, ptr_of_this_method, __mStack);

            var result_of_this_method = instance_of_this_method.ToString();

            return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method));
        }
Exemplo n.º 20
0
 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();
 }
Exemplo n.º 21
0
        /// <summary>
        /// Получить информацию за год
        /// </summary>
        /// <param name="year">год</param>
        /// <returns></returns>
        public InformationForTheYear this[System.UInt16 year]
        {
            get
            {
                foreach (XmlElement element in RowElement.ChildNodes)
                {
                    if (element.Attributes["number"].Value == year.ToString())
                    {
                        return(new InformationForTheYear(element));
                    }
                }

                throw new Exception("Element not found");
            }
        }
        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);

        }
Exemplo n.º 23
0
        public string DeviceDescription()
        {
            string deviceDesc = "Device ";

            if (dwAddr != VALUE_NONE)
            {
                string.Concat(deviceDesc, "0x", dwAddr.ToString("X"), ", ");
            }

            return(string.Concat(deviceDesc, "vid 0x", wVid.ToString("X"),
                                 ", pid 0x", wPid.ToString("X"), ", ifc ",
                                 dwInterfaceNum.ToString(), ", alt setting ",
                                 dwAltSettingNum.ToString(), ", handle 0x",
                                 hDevice.ToString()));
        }
        static StackObject *ToString_13(ILIntepreter __intp, StackObject *__esp, List <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.String format = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);
            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.UInt16 instance_of_this_method = GetInstance(__domain, ptr_of_this_method, __mStack);

            var result_of_this_method = instance_of_this_method.ToString(format);

            return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method));
        }
Exemplo n.º 25
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!");
                }
            }
        }
Exemplo n.º 26
0
        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);
        }
Exemplo n.º 27
0
        public EntityItem(Game game) : base(game)
        {
            this.ItemId    = 1;
            this.ItemCount = 1;
            SetModel(ItemId.ToString());

            Model.Gravity        = 0.04f;
            Model.Drag           = new Vector3(0.95f, 0.98f, 0.95f);
            Model.GroundFriction = new Vector3(0.6f, 1f, 0.6f);
            Model.GroundBounce   = new Vector3(0f, 0.5f, 0f);

            Model.RecalcProperties(this);
            UpdateModelBounds();
            this.ModelScale = new Vector3(1 / 4f, 1 / 4f, 1 / 4f);
            interp          = new LocalInterpComponent(game, this);

            collisions         = new CollisionsComponent(game, this);
            physics            = new PhysicsComponent(game, this);
            physics.hacks      = hacks;
            physics.collisions = collisions;
        }
Exemplo n.º 28
0
 private void para_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (isInitFinished)
     {
         PropertyInfo[] pi = io.DIOPara.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);
         foreach (PropertyInfo p in pi)
         {
             if (((ComboBox)sender).Tag.ToString() == p.Name)
             {
                 U16 val = Convert.ToUInt16(((ComboBox)sender).SelectedIndex);
                 if (p.PropertyType.BaseType.Name == "Enum")
                 {
                     p.SetValue(io.DIOPara, Enum.Parse(p.PropertyType, val.ToString()), null);
                 }
                 if (p.PropertyType.BaseType.Name == "ValueType")
                 {
                     p.SetValue(io.DIOPara, Convert.ChangeType(val, p.PropertyType), null);
                 }
             }
         }
     }
 }
Exemplo n.º 29
0
 /// <summary>
 /// Write Configuration data in XML format to the XML Text Writer.
 /// </summary>
 /// <param name="writer">XML Text Writer</param>
 public override void WriteXmlConfig(XmlTextWriter writer)
 {
     writer.WriteStartElement("DicomPeerToPeerConfiguration");
     writer.WriteStartElement("FromActor");
     writer.WriteStartElement("ActorName");
     writer.WriteElementString("ActorType", ActorTypes.Type(FromActorName.Type));
     writer.WriteElementString("ActorId", FromActorName.Id);
     writer.WriteEndElement();
     writer.WriteElementString("AeTitle", FromActorAeTitle);
     writer.WriteEndElement();
     writer.WriteStartElement("ToActor");
     writer.WriteStartElement("ActorName");
     writer.WriteElementString("ActorType", ActorTypes.Type(ToActorName.Type));
     writer.WriteElementString("ActorId", ToActorName.Id);
     writer.WriteEndElement();
     writer.WriteElementString("AeTitle", ToActorAeTitle);
     writer.WriteElementString("IpAddress", ToActorIpAddress);
     writer.WriteEndElement();
     writer.WriteElementString("PortNumber", PortNumber.ToString());
     writer.WriteElementString("SecureConnection", SecureConnection.ToString());
     writer.WriteElementString("AutoValidate", AutoValidate.ToString());
     writer.WriteElementString("ActorOption1", ActorOption1);
     writer.WriteElementString("ActorOption2", ActorOption2);
     writer.WriteElementString("ActorOption3", ActorOption3);
     writer.WriteElementString("SessionId", _sessionId.ToString());
     writer.WriteElementString("SourceDataDirectory", _sourceDataDirectory);
     writer.WriteElementString("StoreDataDirectory", _storeDataDirectory);
     writer.WriteElementString("StoreData", _storeData.ToString());
     writer.WriteStartElement("DefinitionFiles");
     foreach (System.String defintionFilename in _definitionFiles)
     {
         writer.WriteElementString("DefinitionFile", defintionFilename);
     }
     writer.WriteEndElement();
     writer.WriteEndElement();
 }
Exemplo n.º 30
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; }
Exemplo n.º 31
0
        /// <summary>
        /// samotny prevod PropertyItem.Value na string dle PropertyItem.Type
        /// </summary>
        /// <param name="PItem"></param>
        /// <returns></returns>
        static private string PropertyValueToString(PropertyItem PItem)
        {
            const int BYTEJUMP_SHORT     = 2;
            const int BYTEJUMP_LONG      = 4;
            const int BYTEJUMP_SLONG     = 4;
            const int BYTEJUMP_RATIONAL  = 8;
            const int BYTEJUMP_SRATIONAL = 8;

            string Result = null;

            switch ((PropertyTagType)PItem.Type)
            {
            case (PropertyTagType.Byte):                    // 1
            {
                Result = BitConverter.ToString(PItem.Value, 0, PItem.Len);
                break;
            }

            case (PropertyTagType.ASCII):                    // 2
            {
                /* - puvodni, ale pak nejde cestina !!!
                 * System.Text.ASCIIEncoding Encoding = new System.Text.ASCIIEncoding();
                 *                  Result = Encoding.GetString(PItem.Value, 0, PItem.Len - 1);
                 */
                // spravny prevod do defaultniho kodovani, tj v ceskych win bude fungovat cestina
                Result = VtStrings.BytesToStrCS(PItem.Value);
                break;
            }

            case (PropertyTagType.Short):                    // 3
            {
                for (int i = 0; i < PItem.Len; i = i + BYTEJUMP_SHORT)
                {
                    System.UInt16 Value = BitConverter.ToUInt16(PItem.Value, i);
                    Result += Value.ToString();
                }
                break;
            }

            case (PropertyTagType.Long):                    // 4
            {
                for (int i = 0; i < PItem.Len; i = i + BYTEJUMP_LONG)
                {
                    System.UInt32 Value = BitConverter.ToUInt32(PItem.Value, i);
                    Result += Value.ToString();
                }
                break;
            }

            case (PropertyTagType.Rational):                    // 5
            {
                for (int i = 0; i < PItem.Len; i = i + BYTEJUMP_RATIONAL)
                {
                    System.UInt32 Numer = BitConverter.ToUInt32(PItem.Value, i);
                    System.UInt32 Denom = BitConverter.ToUInt32(PItem.Value, i + BYTEJUMP_LONG);
                    if (Result != null)
                    {
                        Result += ' ';
                    }
                    Result += Numer.ToString() + '/' + Denom.ToString();
                }
                break;
            }

            case (PropertyTagType.Undefined):                    // 7
            {
                Result = BitConverter.ToString(PItem.Value, 0, PItem.Len);
                break;
            }

            case (PropertyTagType.SLONG):                    // 9
            {
                for (int i = 0; i < PItem.Len; i = i + BYTEJUMP_SLONG)
                {
                    System.Int32 Value = BitConverter.ToInt32(PItem.Value, i);
                    Result += Value.ToString();
                }
                break;
            }

            case (PropertyTagType.SRational):                    // 10
            {
                for (int i = 0; i < PItem.Len; i = i + BYTEJUMP_SRATIONAL)
                {
                    System.Int32 Numer = BitConverter.ToInt32(PItem.Value, i);
                    System.Int32 Denom = BitConverter.ToInt32(PItem.Value, i + BYTEJUMP_SLONG);
                    if (Result != null)
                    {
                        Result += ' ';
                    }
                    Result += Numer.ToString() + '/' + Denom.ToString();
                }
                break;
            }

            default:
                break;
            }
            return(Result);
        }
Exemplo n.º 32
0
		public static SqlString ToSqlString(UInt16          p) { return p.ToString();                                                                     }
Exemplo n.º 33
0
        /// <summary>
        ///  Создать и сохранить ведомость
        /// </summary>
        /// <param name="In">Элемент, в который будет вложен элемент ведомости</param>
        /// <param name="year">год ведомости</param>
        /// <param name="EducationalInstitution">Учреждение образования</param>
        /// <param name="codeAndSpecialityName">Код и наименование специальности</param>
        /// <param name="chairman">Председатель</param>
        /// <param name="deputy">Заместитель</param>
        /// <param name="CommissionMember1">Член комиссии</param>
        /// <param name="CommissionMember2">Член комиссии</param>
        public Statement2(XmlElement In,
                          System.UInt16 year            = 0,
                          string EducationalInstitution = "",
                          string codeAndSpecialityName  = "",
                          string chairman          = "",
                          string deputy            = "",
                          string CommissionMember1 = "",
                          string CommissionMember2 = ""
                          )
        {
            //
            //Можно было всё очень сильно упростить, если передавать параметры(атрибуты) ведомости с помощью словаря
            // но я уже вот так сделал
            //
            this.StatementInXml = Statement2_Document.CreateElement("statement");
            In.AppendChild(this.StatementInXml);

            XmlAttribute Attr_UniqueKey = Statement2_Document.CreateAttribute("UniqueKey");

            Attr_UniqueKey.Value = Config.GenKey();

            XmlAttribute Attr_year = Statement2_Document.CreateAttribute("year");

            Attr_year.Value = year.ToString();

            XmlAttribute Attr_EducationalInstitution = Statement2_Document.CreateAttribute("EducationalInstitution");

            Attr_EducationalInstitution.Value = EducationalInstitution;

            XmlAttribute Attr_codeAndSpecialityName = Statement2_Document.CreateAttribute("codeAndSpecialityName");

            Attr_codeAndSpecialityName.Value = codeAndSpecialityName;

            XmlAttribute Attr_chairman = Statement2_Document.CreateAttribute("chairman");

            Attr_chairman.Value = chairman;

            XmlAttribute Attr_deputy = Statement2_Document.CreateAttribute("deputy");

            Attr_deputy.Value = deputy;

            XmlAttribute Attr_CommissionMember1 = Statement2_Document.CreateAttribute("CommissionMember1");

            Attr_CommissionMember1.Value = CommissionMember1;

            XmlAttribute Attr_CommissionMember2 = Statement2_Document.CreateAttribute("CommissionMember2");

            Attr_CommissionMember2.Value = CommissionMember2;

            this.StatementInXml.Attributes.Append(Attr_UniqueKey);
            this.StatementInXml.Attributes.Append(Attr_year);
            this.StatementInXml.Attributes.Append(Attr_EducationalInstitution);
            this.StatementInXml.Attributes.Append(Attr_codeAndSpecialityName);
            this.StatementInXml.Attributes.Append(Attr_chairman);
            this.StatementInXml.Attributes.Append(Attr_deputy);
            this.StatementInXml.Attributes.Append(Attr_CommissionMember1);
            this.StatementInXml.Attributes.Append(Attr_CommissionMember2);

            XmlElement TabularPart = Statement2_Document.CreateElement("TabularPart");

            this.StatementInXml.AppendChild(TabularPart);

            Statement2_Document.Save(Config.Statement2_Path);
        }
Exemplo n.º 34
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;
        }
Exemplo n.º 35
0
		public static string ToString(UInt16 value)
		{
			return value.ToString(CultureInfo.InvariantCulture);
		}
Exemplo n.º 36
0
        /// <summary>
        /// Write関数
        /// </summary>
        /// <remarks>この関数はModelManagerから呼び出される。呼び出し時にはマジック文字とバージョン番号が書かれた状態で渡される</remarks>
        /// <param name="writer">マジック文字とバージョン番号書き込み済みのBinaryWriter</param>
        /// <param name="scale">スケール</param>
        public void Write(BinaryWriter writer, float scale)
        {
            //通常ヘッダ書きだし(英語ヘッダはBoneIndexの後(ミクなら0x00071167)に書かれている
            Header.Write(writer);
            //頂点リスト書きだし
            if (Vertexes == null)
            {
                writer.Write((DWORD)0);
            }
            else
            {
                writer.Write((DWORD)Vertexes.LongLength);
                for (DWORD i = 0; i < Vertexes.LongLength; i++)
                {
                    if (Vertexes[i] == null)
                    {
                        throw new ArgumentNullException("Vertexes[" + i.ToString() + "]がnull");
                    }
                    Vertexes[i].Write(writer, CoordZ, scale);
                }
            }
            //面リスト書きだし
            if (FaceVertexes == null)
            {
                writer.Write((DWORD)0);
            }
            else
            {
                writer.Write((DWORD)FaceVertexes.LongLength);
                for (DWORD i = 0; i < FaceVertexes.LongLength; i++)
                {
                    writer.Write(FaceVertexes[i]);
                }
            }
            //材質リスト書きだし
            if (Materials == null)
            {
                writer.Write((DWORD)0);
            }
            else
            {
                writer.Write((DWORD)Materials.LongLength);
                for (DWORD i = 0; i < Materials.LongLength; i++)
                {
                    if (Materials[i] == null)
                    {
                        throw new ArgumentNullException("Materials[" + i.ToString() + "]がnull");
                    }
                    Materials[i].Write(writer);
                }
            }
            //ボーンリスト書きだし
            if (Bones == null)
            {
                writer.Write((WORD)0);
            }
            else
            {
                writer.Write((WORD)Bones.Length);
                for (WORD i = 0; i < Bones.Length; i++)
                {
                    if (Bones[i] == null)
                    {
                        throw new ArgumentNullException("Bones[" + i.ToString() + "]がnull");
                    }
                    Bones[i].Write(writer, CoordZ, scale);
                }
            }
            //IKリスト書きだし
            if (IKs == null)
            {
                writer.Write((WORD)0);
            }
            else
            {
                writer.Write((WORD)IKs.Length);
                for (WORD i = 0; i < IKs.Length; i++)
                {
                    if (IKs[i] == null)
                    {
                        throw new ArgumentNullException("IKs[" + i.ToString() + "]がnull");
                    }
                    IKs[i].Write(writer);
                }
            }
            //表情リスト書きだし
            if (Skins == null)
            {
                writer.Write((WORD)0);
            }
            else
            {
                writer.Write((WORD)Skins.Length);
                for (WORD i = 0; i < Skins.Length; i++)
                {
                    if (Skins[i] == null)
                    {
                        throw new ArgumentNullException("Skins[" + i.ToString() + "]がnull");
                    }
                    Skins[i].Write(writer, CoordZ, scale);
                }
            }
            //表情枠用表示リスト書きだし
            if (SkinIndex == null)
            {
                writer.Write((byte)0);
            }
            else
            {
                writer.Write((byte)SkinIndex.Length);

                for (byte i = 0; i < SkinIndex.Length; i++)
                {
                    writer.Write(SkinIndex[i]);
                }
            }
            //ボーン枠用枠名リスト
            if (BoneDispNames == null)
            {
                writer.Write((byte)0);
            }
            else
            {
                writer.Write((byte)BoneDispNames.Length);
                for (byte i = 0; i < BoneDispNames.Length; i++)
                {
                    if (BoneDispNames[i] == null)
                    {
                        throw new ArgumentNullException("BoneDispNames[" + i.ToString() + "]がnull");
                    }
                    BoneDispNames[i].Write(writer);
                }
            }
            //ボーン枠用表示リスト
            if (BoneDisps == null)
            {
                writer.Write((DWORD)0);
            }
            else
            {
                writer.Write((DWORD)BoneDisps.Length);
                for (DWORD i = 0; i < BoneDisps.Length; i++)
                {
                    if (BoneDisps[i] == null)
                    {
                        throw new ArgumentNullException("BoneDisps[" + i.ToString() + "]がnull");
                    }
                    BoneDisps[i].Write(writer);
                }
            }
            //英語表記フラグ
            writer.Write((byte)(Expantion ? 1 : 0));
            if (Expantion)
            {
                //英語ヘッダ
                Header.WriteExpantion(writer);
                //ボーンリスト(英語)
                if (Bones != null)
                {
                    for (WORD i = 0; i < Bones.Length; i++)
                    {
                        Bones[i].WriteExpantion(writer);
                    }
                }
                //スキンリスト(英語)
                if (Skins != null)
                {
                    for (WORD i = 0; i < Skins.Length; i++)
                    {
                        if (Skins[i].SkinType != 0)//baseのスキンには英名無し
                        {
                            Skins[i].WriteExpantion(writer);
                        }
                    }
                }
                //ボーン枠用枠名リスト(英語)
                if (BoneDispNames != null)
                {
                    for (byte i = 0; i < BoneDispNames.Length; i++)
                    {
                        BoneDispNames[i].WriteExpantion(writer);
                    }
                }
            }
            if (ToonExpantion)
            {
                //トゥーンテクスチャリスト
                for (int i = 0; i < ToonFileNames.Length; i++)
                {
                    writer.Write(GetBytes(ToonFileNames[i], 100));
                }
                if (PhysicsExpantion)
                {
                    //剛体リスト
                    if (RigidBodies == null)
                    {
                        writer.Write((DWORD)0);
                    }
                    else
                    {
                        writer.Write((DWORD)RigidBodies.LongLength);
                        for (long i = 0; i < RigidBodies.LongLength; i++)
                        {
                            if (RigidBodies[i] == null)
                            {
                                throw new ArgumentNullException("RididBodies[" + i.ToString() + "]がnull");
                            }
                            RigidBodies[i].WriteExpantion(writer, CoordZ, scale);
                        }
                    }
                    //ジョイントリスト
                    if (Joints == null)
                    {
                        writer.Write((DWORD)0);
                    }
                    else
                    {
                        writer.Write((DWORD)Joints.LongLength);
                        for (long i = 0; i < Joints.LongLength; i++)
                        {
                            if (Joints[i] == null)
                            {
                                throw new ArgumentNullException("Joints[" + i.ToString() + "]がnull");
                            }
                            Joints[i].WriteExpantion(writer, CoordZ, scale);
                        }
                    }
                }
            }
        }
Exemplo n.º 37
0
 public Exceptional<DirectoryObject> GetObjectsDirectory(GraphDBType myTypeOfDBObject, UInt16 shard)
 {
     return _IGraphFSSession.GetFSObject<DirectoryObject>(new ObjectLocation(myTypeOfDBObject.ObjectLocation, DBConstants.DBObjectsLocation, shard.ToString()));
 }
Exemplo n.º 38
0
 /// <summary> Adds a command argument. </summary>
 /// <param name="argument"> The argument. </param>
 public void AddArgument(UInt16 argument)
 {
     _arguments.Add(argument.ToString(CultureInfo.InvariantCulture));
 }
 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);
 }
Exemplo n.º 40
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);
        }
Exemplo n.º 41
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;
                    }

                }
            }
        }
Exemplo n.º 42
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(); }
	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";
	}
Exemplo n.º 44
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; }
Exemplo n.º 45
0
		public static SqlChars ToSqlChars(UInt16? p)         { return p.HasValue? new SqlChars(p.ToString().ToCharArray()): SqlChars.Null; }
Exemplo n.º 46
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);
        }
Exemplo n.º 47
0
        /// <summary>
        /// Expand Results File Name : Helper
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public override string GetExpandedResultsFileNameHelper(string fileName)
        {
            System.UInt16 sessionId = this.SessionId;
            string        dir;
            string        tempFileName;

            if (fileName != string.Empty)
            {
                dir          = System.IO.Path.GetDirectoryName(fileName);
                tempFileName = System.IO.Path.GetFileName(fileName);
            }
            else
            {
                dir          = string.Empty;
                tempFileName = string.Empty;
            }
            string sessionIdString = sessionId.ToString("000");

            tempFileName = tempFileName.Replace('.', '_');
            const string postfix           = "res";
            const string extension         = ".xml";
            string       emulatorMiddlefix = null;

            //
            // Precondition only one type of emulator may be set.
            //
            if (
                this.ScpEmulatorType != DvtkData.Results.ScpEmulatorType.Unknown &&
                this.ScuEmulatorType != DvtkData.Results.ScuEmulatorType.Unknown)
            {
                throw new System.ApplicationException(
                          "Only one type of emulator may be set using ScpEmulatorType and ScuEmulatorType.");
            }
            else if (this.ScpEmulatorType != DvtkData.Results.ScpEmulatorType.Unknown)
            {
                switch (this.ScpEmulatorType)
                {
                case DvtkData.Results.ScpEmulatorType.Printing:
                    emulatorMiddlefix = "pr_scp_em";
                    break;

                case DvtkData.Results.ScpEmulatorType.Storage:
                    emulatorMiddlefix = "st_scp_em";
                    break;

                case DvtkData.Results.ScpEmulatorType.Mpps:
                    emulatorMiddlefix = "mp_scp_em";
                    break;

                case DvtkData.Results.ScpEmulatorType.Worklist:
                    emulatorMiddlefix = "wl_scp_em";
                    break;

                case DvtkData.Results.ScpEmulatorType.QueryRetrieve:
                    emulatorMiddlefix = "qr_scp_em";
                    break;

                case DvtkData.Results.ScpEmulatorType.Unknown:
                    throw new System.NotSupportedException();
                }
            }
            else if (this.ScuEmulatorType != DvtkData.Results.ScuEmulatorType.Unknown)
            {
                switch (this.ScuEmulatorType)
                {
                case DvtkData.Results.ScuEmulatorType.Storage:
                    emulatorMiddlefix = "st_scu_em";
                    break;

                case DvtkData.Results.ScuEmulatorType.Unknown:
                    throw new System.NotSupportedException();
                }
            }
            else
            {
                throw new System.ApplicationException(
                          "No type of emulator was set using ScpEmulatorType and ScuEmulatorType.");
            }
            System.Collections.ArrayList fileNameElementsArray =
                new System.Collections.ArrayList();
            if (sessionIdString != string.Empty)
            {
                fileNameElementsArray.Add(sessionIdString);
            }
            if (tempFileName != string.Empty)
            {
                fileNameElementsArray.Add(tempFileName);
            }
            if (emulatorMiddlefix != string.Empty)
            {
                fileNameElementsArray.Add(emulatorMiddlefix);
            }
            if (postfix != string.Empty)
            {
                fileNameElementsArray.Add(postfix);
            }
            string[] fileNameElements =
                (string[])fileNameElementsArray.ToArray(typeof(string));
            tempFileName = string.Join("_", fileNameElements);
            tempFileName = System.IO.Path.ChangeExtension(tempFileName, extension);
            tempFileName = System.IO.Path.Combine(dir, tempFileName);
            return(tempFileName);
        }
Exemplo n.º 48
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();
        }
Exemplo n.º 49
0
        private void ReadWriteReg()
        {
            WDC_REG reg      = m_regs[0];
            DWORD   dwStatus = (DWORD)wdc_err.WD_STATUS_SUCCESS;
            BOOL    bIsRead  = (m_direction == RW.READ);

            if (!IsLegalDirection(0))
            {
                txtData.Text += "you have chosen to " + (bIsRead?
                                                         "read from" : "write to") + " a register which is " +
                                (bIsRead? "write-only" : "read-only") + Environment.NewLine;
                return;
            }

            switch (reg.dwSize)
            {
            case wdc_lib_consts.WDC_SIZE_8:
            {
                if (RW.READ == m_direction)
                {
                    dwStatus = (m_regType == ACTION_TYPE.CFG) ?
                               wdc_lib_decl.WDC_PciReadCfg8(m_device.Handle,
                                                            reg.dwOffset, ref m_bData) :
                               wdc_lib_decl.WDC_ReadAddr8(m_device.Handle,
                                                          reg.dwAddrSpace, reg.dwOffset, ref m_bData);
                }
                else
                {
                    dwStatus = (m_regType == ACTION_TYPE.CFG) ?
                               wdc_lib_decl.WDC_PciWriteCfg8(m_device.Handle,
                                                             reg.dwOffset, m_bData) :
                               wdc_lib_decl.WDC_WriteAddr8(m_device.Handle,
                                                           reg.dwAddrSpace, reg.dwOffset, m_bData);
                }
                break;
            }

            case wdc_lib_consts.WDC_SIZE_16:
            {
                if (RW.READ == m_direction)
                {
                    dwStatus = (m_regType == ACTION_TYPE.CFG) ?
                               wdc_lib_decl.WDC_PciReadCfg16(m_device.Handle,
                                                             reg.dwOffset, ref m_wData) :
                               wdc_lib_decl.WDC_ReadAddr16(m_device.Handle,
                                                           reg.dwAddrSpace, reg.dwOffset, ref m_wData);
                }
                else
                {
                    dwStatus = (m_regType == ACTION_TYPE.CFG) ?
                               wdc_lib_decl.WDC_PciWriteCfg16(m_device.Handle,
                                                              reg.dwOffset, m_wData) :
                               wdc_lib_decl.WDC_WriteAddr16(m_device.Handle,
                                                            reg.dwAddrSpace, reg.dwOffset, m_wData);
                }
                break;
            }

            case wdc_lib_consts.WDC_SIZE_32:
            {
                if (RW.READ == m_direction)
                {
                    dwStatus = (m_regType == ACTION_TYPE.CFG) ?
                               wdc_lib_decl.WDC_PciReadCfg32(m_device.Handle,
                                                             reg.dwOffset, ref m_u32Data) :
                               wdc_lib_decl.WDC_ReadAddr32(m_device.Handle,
                                                           reg.dwAddrSpace, reg.dwOffset, ref m_u32Data);
                }
                else
                {
                    dwStatus = (m_regType == ACTION_TYPE.CFG) ?
                               wdc_lib_decl.WDC_PciWriteCfg32(m_device.Handle,
                                                              reg.dwOffset, m_u32Data) :
                               wdc_lib_decl.WDC_WriteAddr32(m_device.Handle,
                                                            reg.dwAddrSpace, reg.dwOffset, m_u32Data);
                }
                break;
            }

            case wdc_lib_consts.WDC_SIZE_64:
            {
                if (RW.READ == m_direction)
                {
                    dwStatus = (m_regType == ACTION_TYPE.CFG) ?
                               wdc_lib_decl.WDC_PciReadCfg64(m_device.Handle,
                                                             reg.dwOffset, ref m_u64Data) :
                               wdc_lib_decl.WDC_ReadAddr64(m_device.Handle,
                                                           reg.dwAddrSpace, reg.dwOffset, ref m_u64Data);
                }
                else
                {
                    dwStatus = (m_regType == ACTION_TYPE.CFG) ?
                               wdc_lib_decl.WDC_PciWriteCfg64(m_device.Handle,
                                                              reg.dwOffset, m_u64Data) :
                               wdc_lib_decl.WDC_WriteAddr64(m_device.Handle,
                                                            reg.dwAddrSpace, reg.dwOffset, m_u64Data);
                }
                break;
            }
            }
            TraceLog((((DWORD)wdc_err.WD_STATUS_SUCCESS == dwStatus)?
                      (bIsRead? "read " : "wrote ") + "0x" +
                      ((reg.dwSize == wdc_lib_consts.WDC_SIZE_8)?
                       m_bData.ToString("X2"):
                       ((reg.dwSize == wdc_lib_consts.WDC_SIZE_16)?
                        m_wData.ToString("X4") :
                        ((reg.dwSize == wdc_lib_consts.WDC_SIZE_32)?
                         m_u32Data.ToString("X8") : m_u64Data.ToString("X16")))) +
                      (bIsRead? " from " : " to ") + "register " + reg.sName :
                      "failed to complete the transaction on register" + reg.sName),
                     (wdc_err)dwStatus);
        }
Exemplo n.º 50
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());
                }
        }
Exemplo n.º 51
0
        private bool Func_Modbus_Recv_Handle()
        {
            bool res = true;

            modbus_handling = true;
            String SerialIn = "";

            for (int i = 0; i < modbus_recv_cnt; i++)
            {
                //SerialIn += modbus_recv_data[i].ToString();
                if (modbus_recv_data[i] < 0x0f)
                {
                    SerialIn += "0x0";
                    SerialIn += Convert.ToString(modbus_recv_data[i], 16);
                }
                else
                {
                    SerialIn += "0x";
                    SerialIn += Convert.ToString(modbus_recv_data[i], 16);
                }

                SerialIn += " ";
            }

            if (checkBox_ShowTxt.Checked == true)
            {
                this.Invoke((EventHandler)(delegate
                {
                    this.textBox_ComRec.AppendText("Recv: ");
                    this.textBox_ComRec.AppendText(SerialIn);                           //在接收文本中添加串口接收数据
                    this.textBox_ComRec.AppendText("\r\n");

                    if (textBox_ComRec.TextLength > 32768)
                    {
                        textBox_ComRec.Text = "";
                    }
                }));
            }

            /*
             *      Send:
             *      [0]		   0x01: SubAddress
             *      [1]		   0x03: Read(WORD)
             *      [2]		   0x01: Register
             *      [3]		   0x01: Num(要读的WORD数)
             *      [4-7]0x00000001: Val(传递的参数)
             *      [8]		   0x**: CRCH
             *      [9]		   0x**: CRCL
             *
             *      Rec:
             *      [0]		   0x01: SubAddress
             *      [1]		   0x03: Read(WORD)
             *      [2]		   0x01: Register
             *      [3]		   0x01: Num
             *      [4]		   0x00: ValH[0]
             *      [5]		   0x01: ValL[0]
             *      [6]		   0x**: CRCH
             *      [7]		   0x**: CRCL
             */

            //send:01 03 01 01 00 00 00 01 4F 16->received:01 03 01 01 55 AA AA D9//读故障报警状态

            u16 CRC_Result_Cal   = 0;
            u16 CRC_Result_Trans = 0;
            u8  Register_Address = 0;

            modbus_is_busy = false;
            switch (modbus_recv_data[1])                                                                //功能码
            {
            case 0x03:                                                                                  //读寄存器的值(WORD)
            {
                CRC_Result_Cal   = Func_Get_CRC(modbus_recv_data, 6);                                   //CRC校验正确则发送数据给主站,否则等待主站再次发送数据
                CRC_Result_Trans = (u16)((((u16)modbus_recv_data[6]) << 8) | ((u16)modbus_recv_data[7]));
                if (CRC_Result_Cal == CRC_Result_Trans)
                {
                    u8  Need_Read_WORD_Num;
                    u32 Func_Val = 0;

                    Register_Address   = modbus_recv_data[2];                                                   //寄存器值
                    Need_Read_WORD_Num = modbus_recv_data[3];                                                   //要读的WORD数
                    Func_Val           = ((((u32)modbus_recv_data[4]) << 8) |
                                          (((u32)modbus_recv_data[5]) << 0));

                    Console.WriteLine("MBI Reg:{0} Num:{1} Val:{2}", Register_Address, Need_Read_WORD_Num, Func_Val);

                    switch (Register_Address)
                    {
                    case REG_IDENTIFY:                                                                                                  //测试modbus通信是否正常
                    {
                        Console.WriteLine("REG_IDENTIFY:{0:X}", Func_Val);
                        this.Invoke((EventHandler)(delegate
                                {
                                    label_Status.Text = Func_Val.ToString();
                                }));

                        break;
                    }

                    case REG_MOUSE_PRESS:
                    {
                        Console.WriteLine("REG_MOUSE:{0:X}", Func_Val);
                        break;
                    }

                    case REG_MOUSE_CLICK:
                    {
                        this.Invoke((EventHandler)(delegate
                                {
                                    if (button_ClickLeft.Enabled == false)
                                    {
                                        button_ClickLeft.Enabled = true;
                                    }
                                    if (button_ClickRight.Enabled == false)
                                    {
                                        button_ClickRight.Enabled = true;
                                    }
                                }));

                        break;
                    }

                    case REG_MOUSE_SPEED:
                    {
                        this.Invoke((EventHandler)(delegate
                                {
                                    if (button_SpeedUp.Enabled == false)
                                    {
                                        button_SpeedUp.Enabled = true;
                                    }
                                    if (button_SpeedDown.Enabled == false)
                                    {
                                        button_SpeedDown.Enabled = true;
                                    }
                                    if (mouse_speed_chk == false)
                                    {
                                        mouse_speed_chk = true;
                                    }
                                    label_MouseSpeed.Text = Func_Val.ToString();
                                }));

                        break;
                    }

                    case REG_KEYBOARD:
                    case REG_SYSTEM_REBOOT:
                    case REG_USB_RECONNECT:
                    {
                        break;
                    }

                    default:
                    {
                        MessageBox.Show("error reg!!!: " + Register_Address.ToString(), "提示");
                        res = false;
                        break;
                    }
                    }
                    modbus_send_cmd_is_busy = false;

                    if (Func_KB_FIFO_HasData() == true)
                    {
                        modbus_send_cmd_is_busy = true;
                        Func_Modbus_Send_03(REG_KEYBOARD, 1, Func_KB_FIFO_Output());
                    }
                }
                else
                {
                    MessageBox.Show("error crc!!!: " + CRC_Result_Cal.ToString(), "提示");
                    res = false;
                }
                break;
            }

            case 0x06:
            {
                break;
            }

            default:
            {
                MessageBox.Show("error func!!!: " + modbus_recv_data[1].ToString(), "提示");
                res = false;
                break;
            }
            }
            modbus_recv_data[1] = 0xFF;                                     //取完后立马清掉,表示已经用过了

            modbus_recv_cnt = 0;
            modbus_handling = false;

            if (res == true)
            {
                modbus_success_cnt++;
            }
            else
            {
                modbus_fail_cnt++;
                modbus_send_cmd_is_busy = false;
            }
            this.Invoke((EventHandler)(delegate
            {
                label_CmdSuccessCnt.Text = "CmdCnt: ";
                label_CmdSuccessCnt.Text += modbus_success_cnt.ToString();
                label_CmdSuccessCnt.Text += " | ";
                label_CmdSuccessCnt.Text += modbus_fail_cnt.ToString();
            }));

            return(res);
        }
Exemplo n.º 52
0
        //
        // Helper for Enum.Format(,,"x")
        //
        private static String DoFormatX(ulong rawValue, RuntimeImports.RhCorElementType corElementType)
        {
            switch (corElementType)
            {
            case RuntimeImports.RhCorElementType.ELEMENT_TYPE_I1:
            {
                Byte result = (byte)(sbyte)rawValue;

                return(result.ToString("X2", null));
            }

            case RuntimeImports.RhCorElementType.ELEMENT_TYPE_U1:
            {
                Byte result = (byte)rawValue;

                return(result.ToString("X2", null));
            }

            case RuntimeImports.RhCorElementType.ELEMENT_TYPE_BOOLEAN:
            {
                // direct cast from bool to byte is not allowed
                Byte result = (byte)rawValue;

                return(result.ToString("X2", null));
            }

            case RuntimeImports.RhCorElementType.ELEMENT_TYPE_I2:
            {
                UInt16 result = (UInt16)(Int16)rawValue;

                return(result.ToString("X4", null));
            }

            case RuntimeImports.RhCorElementType.ELEMENT_TYPE_U2:
            {
                UInt16 result = (UInt16)rawValue;

                return(result.ToString("X4", null));
            }

            case RuntimeImports.RhCorElementType.ELEMENT_TYPE_CHAR:
            {
                UInt16 result = (UInt16)(Char)rawValue;

                return(result.ToString("X4", null));
            }

            case RuntimeImports.RhCorElementType.ELEMENT_TYPE_U4:
            {
                UInt32 result = (UInt32)rawValue;

                return(result.ToString("X8", null));
            }

            case RuntimeImports.RhCorElementType.ELEMENT_TYPE_I4:
            {
                UInt32 result = (UInt32)(int)rawValue;

                return(result.ToString("X8", null));
            }

            case RuntimeImports.RhCorElementType.ELEMENT_TYPE_U8:
            {
                UInt64 result = (UInt64)rawValue;

                return(result.ToString("X16", null));
            }

            case RuntimeImports.RhCorElementType.ELEMENT_TYPE_I8:
            {
                UInt64 result = (UInt64)(Int64)rawValue;

                return(result.ToString("X16", null));
            }

            default:
                Contract.Assert(false, "Invalid Object type in Format");
                throw new InvalidOperationException(SR.InvalidOperation_UnknownEnumType);
            }
        }
Exemplo n.º 53
0
        private static String InternalFormattedHexString(Object value)
        {
            TypeCode typeCode = Convert.GetTypeCode(value);

            switch (typeCode)
            {
            case TypeCode.SByte:
            {
                Byte result = (byte)(sbyte)value;

                return(result.ToString("X2", null));
            }

            case TypeCode.Byte:
            {
                Byte result = (byte)value;

                return(result.ToString("X2", null));
            }

            case TypeCode.Boolean:
            {
                // direct cast from bool to byte is not allowed
                Byte result = Convert.ToByte((bool)value);

                return(result.ToString("X2", null));
            }

            case TypeCode.Int16:
            {
                UInt16 result = (UInt16)(Int16)value;

                return(result.ToString("X4", null));
            }

            case TypeCode.UInt16:
            {
                UInt16 result = (UInt16)value;

                return(result.ToString("X4", null));
            }

            case TypeCode.Char:
            {
                UInt16 result = (UInt16)(Char)value;

                return(result.ToString("X4", null));
            }

            case TypeCode.UInt32:
            {
                UInt32 result = (UInt32)value;

                return(result.ToString("X8", null));
            }

            case TypeCode.Int32:
            {
                UInt32 result = (UInt32)(int)value;

                return(result.ToString("X8", null));
            }

            case TypeCode.UInt64:
            {
                UInt64 result = (UInt64)value;

                return(result.ToString("X16", null));
            }

            case TypeCode.Int64:
            {
                UInt64 result = (UInt64)(Int64)value;

                return(result.ToString("X16", null));
            }

            // All unsigned types will be directly cast
            default:
                Contract.Assert(false, "Invalid Object type in Format");
                throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_UnknownEnumType"));
            }
        }
Exemplo n.º 54
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;
        }
Exemplo n.º 55
0
        public static int Main(string[] args)
        {
            // Test value semantics.
            System.Int32 intA = 1001;
            System.Int32 intB = 1000;
            if (intA == intB)
            {
                Console.WriteLine("Same value!\n");
            }
            else
            {
                Console.WriteLine("Not the same value!\n");
            }

            // Working with UInt16 as a wrapper.
            System.UInt16 myUInt16 = 30000;
            Console.WriteLine("Max for an UInt16 is: {0}", UInt16.MaxValue);
            Console.WriteLine("Min for an UInt16 is: {0}", UInt16.MinValue);
            Console.WriteLine("Your value is: {0}", myUInt16.ToString());
            Console.WriteLine("I am a: {0}", myUInt16.GetType().ToString());

            // Now in UInt16 shorthand (e.g. a ushort).
            ushort myOtherUInt16 = 12000;

            Console.WriteLine("\nYour value is: {0}", myOtherUInt16.ToString());
            Console.WriteLine("I am a: {0}", myOtherUInt16.GetType().ToString());

            // Boxing and unboxing.
            Console.WriteLine("\nNow for some boxing...");

            // Make a simple value.
            short s = 25;

            Console.WriteLine("short s = {0}", s);
            Console.WriteLine("short is a: {0}\n", s.GetType().ToString());

            // Box the value into a reference.
            object objShort = s;

            Console.WriteLine("Boxed object is a: {0}\n", objShort.GetType().ToString());

            // Now, unbox the reference back into a short:
            short anotherShort = (short)objShort;

            Console.WriteLine("short anotherShort = {0}", anotherShort);
            Console.WriteLine("Unboxed object is a: {0}", anotherShort.GetType().ToString());

            // Bad unboxing!
            try
            {
                // The type contained in the box is NOT a
                // string, but a short!
                string str = (string)objShort;
            }
            catch (InvalidCastException e)
            {
                Console.WriteLine("\nOOPS!\n{0}", e.ToString());
            }

            // Auto-box.
            Console.WriteLine("\n\nThe Auto Box");
            int x = 99;

            Foo(x);
            return(0);
        }