Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Program.ReaderXP.Options.TagSelected.flags         = SelectMaskFlags.DISABLE_ALL;
            Program.ReaderXP.Options.TagSelected.epcMask       = new S_MASK(textBoxTagID.Text);
            Program.ReaderXP.Options.TagSelected.epcMaskLength = (uint)Program.ReaderXP.Options.TagSelected.epcMask.Length * 8;
            if (Program.ReaderXP.StartOperation(Operation.TAG_SELECTED, true) != Result.OK)
            {
                MessageBox.Show("Selected tag failed");
                return;
            }

            UInt16 configword = 0;

            configword &= 0xfe00; // reset permanent bits 1111 1110 0000 0000

            if (checkBox7.Checked)
            {
                configword |= 1 << 8;
            }

            if (checkBox8.Checked)
            {
                configword |= 1 << 7;
            }

            if (checkBox9.Checked)
            {
                configword |= 1 << 6;
            }

            if (checkBox10.Checked)
            {
                configword |= 1 << 5;
            }

            if (checkBox11.Checked)
            {
                configword |= 1 << 4;
            }

            if (checkBox12.Checked)
            {
                configword |= 1 << 3;
            }

            if (checkBox13.Checked)
            {
                configword |= 1 << 2;
            }

            if (checkBox14.Checked)
            {
                configword |= 1 << 1;
            }

            if (checkBox15.Checked)
            {
                configword |= 1;
            }

            Program.ReaderXP.Options.TagWriteEPC.retryCount     = 7;
            Program.ReaderXP.Options.TagWriteEPC.accessPassword = UInt32.Parse(textBoxPassword.Text, NumberStyles.HexNumber);
            Program.ReaderXP.Options.TagWriteEPC.offset         = 0x20 - 2;
            Program.ReaderXP.Options.TagWriteEPC.count          = 1;
            Program.ReaderXP.Options.TagWriteEPC.epc            = new S_EPC(configword.ToString("X4"));

            int writeretry = Convert.ToInt16(textBox1.Text);
            int cnt;

            for (cnt = 0; cnt <= writeretry; cnt++)
            {
                if (Program.ReaderXP.StartOperation(Operation.TAG_WRITE_EPC, true) == Result.OK)
                {
                    MessageBox.Show("Write Config Success");
                    break;
                }
            }

            if (cnt > writeretry)
            {
                MessageBox.Show("Write Config Fail");
            }
        }
Exemplo n.º 2
0
    public Boolean runTest()
    {
        Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
        int    iCountErrors       = 0;
        int    iCountTestcases    = 0;
        String strLoc             = "Loc_000oo";
        String strValue           = String.Empty;
        Co5373ToUInt16_ubArr_i cc = new Co5373ToUInt16_ubArr_i();

        try {
            do
            {
                UInt16 ui16 = 0;
                int    iIndex;
                Byte[] byArr3 = null;
                strLoc = "Loc_85yfd";
                iIndex = 0;
                iCountTestcases++;
                try
                {
                    ui16 = BitConverter.ToUInt16(null, iIndex);
                    iCountErrors++;
                    printerr("Error_289fy! ArgumentNullException Expected, got value==" + ui16);
                }
                catch (ArgumentNullException aexc)
                {
                    Console.WriteLine("Info_478g: Caught Expected ArgumentNullException, exc==" + aexc.Message);
                }
                catch (Exception exc)
                {
                    iCountErrors++;
                    printerr("Error_27ycq! ArgumentNullException expected, got exc==" + exc.ToString());
                }
                strLoc    = "Loc_29yfv";
                byArr3    = new Byte[2];
                byArr3[0] = (Byte)0x78;
                byArr3[1] = (Byte)0x56;
                iIndex    = -1;
                iCountTestcases++;
                Random random = new Random();
                for (int i = 0; i < 20; i++)
                {
                    try
                    {
                        ui16 = BitConverter.ToUInt16(byArr3, random.Next(Int32.MinValue, 0));
                        iCountErrors++;
                        printerr("Error_2fd93! Expected ArgumentOutOfRangeException, got value==" + ui16.ToString());
                    }
                    catch (ArgumentOutOfRangeException aexc)
                    {
                    }
                    catch (Exception exc)
                    {
                        iCountErrors++;
                        printerr("Error_28bhc! ArgumenOutOfRangeException expected, exc==" + exc.ToString());
                    }
                }
                strLoc = "Loc_10jcx";
                iCountTestcases++;
                byArr3    = new Byte[3];
                byArr3[0] = (Byte)0x78;
                byArr3[1] = (Byte)0x56;
                byArr3[2] = (Byte)0x34;
                iIndex    = 2;
                try
                {
                    ui16 = BitConverter.ToUInt16(byArr3, iIndex);
                    iCountErrors++;
                    printerr("Error_28vhc! Expected ArgumentOutOfRangeException, got value==" + ui16.ToString());
                }
                catch (ArgumentException aexc)
                {
                }
                catch (Exception exc)
                {
                    iCountErrors++;
                    printerr("Error_y72fn! ArgumentOutOfRangeException expected, exc==" + exc.ToString());
                }
                try
                {
                    ui16 = BitConverter.ToUInt16(byArr3, Int32.MinValue);
                    iCountErrors++;
                    printerr("Error_28vhc! Expected ArgumentOutOfRangeException, got value==" + ui16.ToString());
                }
                catch (ArgumentException aexc)
                {
                }
                catch (Exception exc)
                {
                    iCountErrors++;
                    printerr("Error_y72fn! ArgumentOutOfRangeException expected, exc==" + exc.ToString());
                }
                try
                {
                    ui16 = BitConverter.ToUInt16(byArr3, Int32.MaxValue);
                    iCountErrors++;
                    printerr("Error_28vhc! Expected ArgumentOutOfRangeException, got value==" + ui16.ToString());
                }
                catch (ArgumentException aexc)
                {
                }
                catch (Exception exc)
                {
                    iCountErrors++;
                    printerr("Error_y72fn! ArgumentOutOfRangeException expected, exc==" + exc.ToString());
                }
                strLoc = "Loc_982vn";
                iCountTestcases++;
                byArr3    = new Byte[1];
                byArr3[0] = (Byte)0x78;
                iIndex    = 0;
                try
                {
                    ui16 = BitConverter.ToUInt16(byArr3, 0);
                    iCountErrors++;
                    printerr("Error_298cz! ArgumentException Expected , got value==" + ui16);
                }
                catch (ArgumentException aexc)
                {
                    Console.WriteLine("Caught Expected ArgumentException: exc==" + aexc.Message);
                }
                catch (Exception exc)
                {
                    iCountErrors++;
                    printerr("Error_298vh! ArgumentException Expected, got exc==" + exc.ToString());
                }
                strLoc = "Loc_87hgg";
                byArr3 = new Byte[4];
                if (BitConverter.IsLittleEndian)
                {
                    byArr3[0] = (Byte)0x78;
                    byArr3[1] = (Byte)0x56;
                    byArr3[2] = (Byte)0x34;
                    byArr3[3] = (Byte)0x12;
                }
                else
                {
                    byArr3[3] = (Byte)0x78;
                    byArr3[2] = (Byte)0x56;
                    byArr3[1] = (Byte)0x34;
                    byArr3[0] = (Byte)0x12;
                }
                iIndex = 1;
                ui16   = BitConverter.ToUInt16(byArr3, iIndex);
                iCountTestcases++;
                if (ui16 != 0x3456)
                {
                    iCountErrors++;
                    printerr("Error_287cx! Expected==" + 0x3456 + " , got==" + ui16);
                }
                strLoc      = "Loc_29hhx";
                byArr3      = new Byte[200];
                byArr3[0]   = (Byte)0x0;
                byArr3[1]   = (Byte)0x0;
                byArr3[198] = (Byte)0xff;
                byArr3[199] = (Byte)0xff;
                iIndex      = 0;
                ui16        = BitConverter.ToUInt16(byArr3, iIndex);
                iCountTestcases++;
                if (ui16 != 0)
                {
                    iCountErrors++;
                    printerr("Error_2h90s! Expected==0 , got value==" + ui16);
                }
                iIndex = 198;
                ui16   = BitConverter.ToUInt16(byArr3, iIndex);
                iCountTestcases++;
                if (ui16 != UInt16.MaxValue)
                {
                    iCountErrors++;
                    printerr("Error_29s19! Expected==" + UInt16.MaxValue + " , got value==" + ui16);
                }
                ui16 = BitConverter.ToUInt16(byArr3, 15);
            } while (false);
        } catch (Exception exc_general) {
            ++iCountErrors;
            Console.WriteLine(s_strTFAbbrev + " : Error Err_8888yyy!  strLoc==" + strLoc + ", exc_general==" + exc_general);
        }
        if (iCountErrors == 0)
        {
            Console.WriteLine("paSs.   " + s_strTFPath + " " + s_strTFName + " ,iCountTestcases==" + iCountTestcases);
            return(true);
        }
        else
        {
            Console.WriteLine("FAiL!   " + s_strTFPath + " " + s_strTFName + " ,iCountErrors==" + iCountErrors + " , BugNums?: " + s_strActiveBugNums);
            return(false);
        }
    }
Exemplo n.º 3
0
        public override MTKTestError RunTest()
        {
            //UInt16[] divFactor = { 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192 };
            EquipmentScriptInterpreter XOCalScript = new EquipmentScriptInterpreter(ScriptPath);
            MTKTestError CommandRetVal;
            int          DelayPerCommand = 20, loopCounter = 0;;
            //UInt16 arryIndex = 0;//, msPerSecond = 1000;
            bool        ContinueCalibration = true, CalibrationSuccess = false, fineTune = false, firstTime = true, firstFineTune = true;
            UInt16      trimRegister = 0x0000, prevTrimRegister = 0x0000, dFactor = 0x0080;
            int         freqDeviation = 0, prevFreqDeviation = 0, freqDeviationMod = 0, prevFreqDeviationMod = 0, signReversalCount = 0;
            FreqDevSign currSign, prevSign = FreqDevSign.Negative;
            TRIncDec    TRDir = TRIncDec.Decrement;

            this.InitializeTestResult();
            TestStatusUpdate(MTKTestMessageType.Information, "Calibrating...");

            if (XOCalScript.RunCommands(ScriptCommand.OpenSerialPortCMD) != ScriptError.NoError)
            {
                TestStatusUpdate(MTKTestMessageType.Failure, "FAIL");
                this.Log.PrintLog(this, "Cannot open Frequency Counter port." + Environment.NewLine + "Result: FAILED", LogDetailLevel.LogRelevant);
                return(MTKTestError.TestFailed);
            }
            if (XOCalScript.RunCommands(ScriptCommand.InitCMD) != ScriptError.NoError)
            {
                TestStatusUpdate(MTKTestMessageType.Failure, "FAIL");
                this.Log.PrintLog(this, "Cannot communicate with Frequency Counter." + Environment.NewLine + "Result: FAILED", LogDetailLevel.LogRelevant);
                return(MTKTestError.TestFailed);
            }

            //  Command #1
            string Command = "RRS";

            CommandRetVal = SendCommand(DUTSerialPort, Command, DelayPerCommand);
            if (CommandRetVal != MTKTestError.NoError)
            {
                return(CommandRetVal);
            }

            do
            {
                Command       = "WTR " + trimRegister.ToString("X4");
                CommandRetVal = SendCommand(DUTSerialPort, Command, DelayPerCommand);
                if (CommandRetVal != MTKTestError.NoError)
                {
                    return(CommandRetVal);
                }
                Thread.Sleep(200);

                if (XOCalScript.RunCommands(ScriptCommand.MeasureCMD) != ScriptError.NoError)
                {
                    TestStatusUpdate(MTKTestMessageType.Failure, "FAIL");
                    this.Log.PrintLog(this, "Cannot communicate with Frequency Counter." + Environment.NewLine + "Result: FAILED", LogDetailLevel.LogRelevant);
                    return(MTKTestError.TestFailed);
                }

                prevFreqDeviation    = freqDeviation;
                prevFreqDeviationMod = freqDeviationMod;
                freqDeviation        = XOCalScript.MeasuredFrequency - DesiredCrystalFrequencyHz;
                freqDeviationMod     = (int)Math.Sqrt(freqDeviation * freqDeviation);
                if (freqDeviation >= 0)
                {
                    currSign = FreqDevSign.Positive;
                }
                else
                {
                    currSign = FreqDevSign.Negative;
                }
                if (firstTime)
                {
                    prevSign         = currSign;
                    prevTrimRegister = trimRegister;
                }

                if ((prevSign != currSign) || (signReversalCount >= 2))
                {
                    if (fineTune == true)
                    {
                        dFactor           = (UInt16)(dFactor >> 1);
                        signReversalCount = 0;
                        this.Log.PrintLog(this, "Checking next LSB.", LogDetailLevel.LogEverything);
                    }
                    else
                    {
                        int bitCnt = 0;
                        while (bitCnt < 8)
                        {
                            if ((((trimRegister & 0xFF) >> bitCnt) & 0x0001) == 0x0001)
                            {
                                break;
                            }
                            bitCnt++;
                        }
                        dFactor = (UInt16)(dFactor >> (8 - bitCnt));
                    }
                    if (fineTune == false)
                    {
                        this.Log.PrintLog(this, "Fine tuning.", LogDetailLevel.LogEverything);
                    }
                    fineTune      = true;
                    firstFineTune = true;
                    if (prevFreqDeviationMod < freqDeviationMod)
                    {
                        trimRegister = prevTrimRegister;
                        TRDir        = TRIncDec.Increment;
                        //signReversalCount--;
                    }
                    else
                    {
                        TRDir = TRIncDec.Decrement;
                    }
                    //if (signReversalCount >= 3)
                    if (dFactor == 0x0)
                    {
                        ContinueCalibration = false;
                        CalibrationSuccess  = false;
                        break;
                    }
                }

                prevSign         = currSign;
                prevTrimRegister = trimRegister;
                if (fineTune)
                {
                    if ((prevFreqDeviationMod < freqDeviationMod) && (firstFineTune == false))
                    {
                        if (TRDir == TRIncDec.Increment)
                        {
                            TRDir = TRIncDec.Decrement;
                        }
                        else
                        {
                            TRDir = TRIncDec.Increment;
                        }
                        signReversalCount++;
                    }
                    if (TRDir == TRIncDec.Increment)
                    {
                        trimRegister = (UInt16)((trimRegister & 0xFF00) | (((trimRegister & 0x00FF) + dFactor) & 0x00FF));
                        //trimRegister++;
                    }
                    else if (TRDir == TRIncDec.Decrement)
                    {
                        //trimRegister -= dFactor;
                        trimRegister = (UInt16)((trimRegister & 0xFF00) | (((trimRegister & 0x00FF) - dFactor) & 0x00FF));
                        //trimRegister--;
                    }
                    firstFineTune = false;
                }
                else
                {
                    if (prevTrimRegister == 0xFFFF)
                    {
                        ContinueCalibration = false;
                        break;
                    }
                    if (trimRegister < 0xF0F0)
                    {
                        trimRegister = (UInt16)((trimRegister + 0x1010));
                    }
                    else
                    {
                        trimRegister = 0xFFFF;
                    }
                }

                if ((freqDeviation < MarginOfErrorHz) && (freqDeviation > (-1 * MarginOfErrorHz)))
                {
                    ContinueCalibration = false;
                    CalibrationSuccess  = true;
                    break;
                }

                //prevTrimRegister = trimRegister;
                firstTime = false;
                loopCounter++;
                this.Log.PrintLog(this, "Iteration: " + loopCounter.ToString(), LogDetailLevel.LogEverything);
            } while (ContinueCalibration);

            if (XOCalScript.RunCommands(ScriptCommand.CloseSerialPortCMD) != ScriptError.NoError)
            {
                TestStatusUpdate(MTKTestMessageType.Failure, "FAIL");
                this.Log.PrintLog(this, "Cannot close Frequency Counter port.", LogDetailLevel.LogRelevant);
                this.Log.PrintLog(this, "Result: FAILED", LogDetailLevel.LogRelevant);
                return(MTKTestError.TestFailed);
            }

            MTKTestError RetVal;

            if (CalibrationSuccess)
            {
                Command       = "STR";
                CommandRetVal = SendCommand(DUTSerialPort, Command, DelayPerCommand);
                if (CommandRetVal != MTKTestError.NoError)
                {
                    return(CommandRetVal);
                }
                TestStatusUpdate(MTKTestMessageType.Success, "PASS");
                RetVal = MTKTestError.NoError;
                this.Log.PrintLog(this, "Trim Register Value: " + trimRegister.ToString("X4"), LogDetailLevel.LogRelevant);
                this.Log.PrintLog(this, "Result: PASS", LogDetailLevel.LogRelevant);
                TestResult.Result = "PASS";
            }
            else
            {
                TestStatusUpdate(MTKTestMessageType.Failure, "FAIL");
                RetVal            = MTKTestError.TestFailed;
                TestResult.Result = "FAIL";
                this.Log.PrintLog(this, "Result: FAIL", LogDetailLevel.LogRelevant);
            }
            return(RetVal);
        }
Exemplo n.º 4
0
        //_________________________________________________________________________
        public string ConvertVal(byte[] btData, CONST.TYPE_DATA TypeData)
        {
            //btData.Reverse();
            if (btData.Length <= 0)
            {
                return("Нет данных");
            }
            switch (TypeData)
            {
            case CONST.TYPE_DATA.AC10:
            case CONST.TYPE_DATA.AC20:
            case CONST.TYPE_DATA.AC30:
            case CONST.TYPE_DATA.BIN:
            case CONST.TYPE_DATA.TLP:
            case CONST.TYPE_DATA.DT: return(BitConverter.ToString(btData));

            case CONST.TYPE_DATA.@float: float f = BitConverter.ToSingle(btData, 0); return(f.ToString());

            case CONST.TYPE_DATA.@double: double d = BitConverter.ToDouble(btData, 0); return(d.ToString());

            case CONST.TYPE_DATA.@short: short s = BitConverter.ToInt16(btData, 0); return(s.ToString());

            case CONST.TYPE_DATA.@ushort: ushort us = BitConverter.ToUInt16(btData, 0); return(us.ToString());

            case CONST.TYPE_DATA.@int: int i = BitConverter.ToInt32(btData, 0); return(i.ToString());

            case CONST.TYPE_DATA.@uint: uint ui = BitConverter.ToUInt32(btData, 0); return(ui.ToString());

            case CONST.TYPE_DATA.@long: long l = BitConverter.ToInt64(btData, 0); return(l.ToString());

            case CONST.TYPE_DATA.@ulong: ulong ul = BitConverter.ToUInt64(btData, 0); return(ul.ToString());

            case CONST.TYPE_DATA.INT16: Int16 i16 = BitConverter.ToInt16(btData, 0); return(i16.ToString());

            case CONST.TYPE_DATA.INT32: Int32 ui32 = BitConverter.ToInt16(btData, 0); return(ui32.ToString());

            case CONST.TYPE_DATA.INT8: char c = BitConverter.ToChar(btData, 0); return(c.ToString());

            case CONST.TYPE_DATA.UINT16: UInt16 ui16 = BitConverter.ToUInt16(btData, 0); return(ui16.ToString());

            case CONST.TYPE_DATA.UINT32: UInt32 i32 = BitConverter.ToUInt16(btData, 0); return(i32.ToString());

            case CONST.TYPE_DATA.UINT8: byte bt = (byte)BitConverter.ToChar(btData, 0); return(bt.ToString());
            }
            return("Нет типа");
            //dynamic Val;
            //switch (TYPE_DATA)
            //{
            //case CONST.TYPE_DATA.AC10:
            //case CONST.TYPE_DATA.AC20:
            //case CONST.TYPE_DATA.AC30:
            //case CONST.TYPE_DATA.BIN:
            //case CONST.TYPE_DATA.TLP:
            //case CONST.TYPE_DATA.DT:	 return BitConverter.ToString(btData);
            //case CONST.TYPE_DATA.FLOAT: Val = BitConverter.ToSingle(btData, 0); break;
            //case CONST.TYPE_DATA.INT16: Val = BitConverter.ToInt16(btData, 0); break;
            //case CONST.TYPE_DATA.INT32: Val = BitConverter.ToInt16(btData, 0); break;
            //case CONST.TYPE_DATA.INT8: Val = BitConverter.ToChar(btData, 0); break;
            //case CONST.TYPE_DATA.UINT16: Val = BitConverter.ToUInt16(btData, 0); break;
            //case CONST.TYPE_DATA.UINT32: Val = BitConverter.ToUInt16(btData, 0); break;
            //case CONST.TYPE_DATA.UINT8: Val = (byte)BitConverter.ToChar(btData, 0); break;
            //default: return "ErrType";
            //}
            //return Val.ToString();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Upload the test result of current station to SFCS by serial number.
        /// </summary>
        /// <param name="SerialNumber"></param> serial number of BLE Device.
        /// <param name="Model"></param> part number of BLE Device.
        /// <param name="WorkerID"></param> worker ID.
        /// <param name="Station"></param> current station ID.
        /// <param name="ErrorCode"></param> errorcode of BLE Device.
        /// <param name="TestResult"></param> "Pass" or "Fail".
        /// <returns></returns> true: upload successfully. false: failed to upload the test result.
        public override bool UploadTestResult(string SerialNumber, string Model, string TesterID, UInt16 errorcode, string SocketId, string TestResult, string TestStation, string MFI_ID)
        {
            bool   resultUploaded = false;
            string upload_info;

            SocketId = SocketId + "Socket#";

            if (Connect() != true)
            {
                //MessageBox.Show(LastError, "Shopfloor Error");
                return(false);
            }



            if (!IsValidSerialNumber("UploadTestResult ", SerialNumber) || (!SqlConnected && !Connect()))
            {
                return(false);
            }


            if (this.sFCS_Enum != SFCS_enum.Local)
            {
                upload_info = SFCSconnection.Save_Result(SerialNumber, Model, TesterID, errorcode.ToString("X4"),
                                                         SocketId, TestResult, TestStation, MFI_ID);
            }
            else
            {
                upload_info = SFCSconnectionLocal.Save_Result(SerialNumber, Model, TesterID, errorcode.ToString("X4"),
                                                              SocketId, TestResult, TestStation, MFI_ID);
            }


            if (upload_info.Contains("Pass"))
            {
                resultUploaded = true;
            }
            else
            {
                LastError = "Failed to save result to server: " + upload_info;
            }
            //switch (upload_info)
            //{
            //    case 0:
            //        resultUploaded = true;
            //        break;
            //    case 9:
            //        resultUploaded = false;
            //        connect_error = "SFCS: Cannot find SFCS database.";
            //        break;
            //    case 10:
            //        resultUploaded = false;
            //        connect_error = "SFCS: SFCS connection time out.";
            //        break;
            //    case 11:
            //        resultUploaded = false;
            //        connect_error = "SFCS: Failed to connect SFCS.";
            //        break;
            //    case 12:
            //        resultUploaded = false;
            //        connect_error = "SFCS: Not enough database space for uploading the result.";
            //        break;
            //    case 13:
            //        resultUploaded = false;
            //        connect_error = "SFCS: infomation for uploading cannot meet database integrity.";
            //        break;
            //    default:
            //        resultUploaded = false;
            //        connect_error = "SFCS: Unkown error when trying to upload the test result.";
            //        break;
            //}
            return(resultUploaded);
        }
Exemplo n.º 6
0
        private void ReadTags(PropertyItem[] pitems)
        {
            Encoding ascii = Encoding.ASCII;

            _tags = new Dictionary <int, ExifTag>();

            foreach (PropertyItem pitem in pitems)
            {
                ExifTag tag = SupportedTags.Tag(pitem.Id);

                if (tag == null)
                {
                    continue;
                }

                string value = "";

                if (pitem.Type == 0x1)
                {
                    #region BYTE (8-bit unsigned int)
                    if (pitem.Value.Length == 4)
                    {
                        value = "Version " + pitem.Value[0].ToString() + "." + pitem.Value[1].ToString();
                    }
                    else if (pitem.Id == 0x5 && pitem.Value[0] == 0)
                    {
                        value = "Sea level";
                    }
                    else
                    {
                        value = pitem.Value[0].ToString();
                    }
                    #endregion
                }
                else if (pitem.Type == 0x2)
                {
                    #region ASCII (8 bit ASCII code)

                    value = ascii.GetString(pitem.Value).Trim('\0');

                    if (pitem.Id == 0x1 || pitem.Id == 0x13)
                    {
                        if (value == "N")
                        {
                            value = "North latitude";
                        }
                        else if (value == "S")
                        {
                            value = "South latitude";
                        }
                        else
                        {
                            value = "reserved";
                        }
                    }

                    if (pitem.Id == 0x3 || pitem.Id == 0x15)
                    {
                        if (value == "E")
                        {
                            value = "East longitude";
                        }
                        else if (value == "W")
                        {
                            value = "West longitude";
                        }
                        else
                        {
                            value = "reserved";
                        }
                    }

                    if (pitem.Id == 0x9)
                    {
                        if (value == "A")
                        {
                            value = "Measurement in progress";
                        }
                        else if (value == "V")
                        {
                            value = "Measurement Interoperability";
                        }
                        else
                        {
                            value = "reserved";
                        }
                    }

                    if (pitem.Id == 0xA)
                    {
                        if (value == "2")
                        {
                            value = "2-dimensional measurement";
                        }
                        else if (value == "3")
                        {
                            value = "3-dimensional measurement";
                        }
                        else
                        {
                            value = "reserved";
                        }
                    }

                    if (pitem.Id == 0xC || pitem.Id == 0x19)
                    {
                        if (value == "K")
                        {
                            value = "Kilometers per hour";
                        }
                        else if (value == "M")
                        {
                            value = "Miles per hour";
                        }
                        else if (value == "N")
                        {
                            value = "Knots";
                        }
                        else
                        {
                            value = "reserved";
                        }
                    }

                    if (pitem.Id == 0xE || pitem.Id == 0x10 || pitem.Id == 0x17)
                    {
                        if (value == "T")
                        {
                            value = "True direction";
                        }
                        else if (value == "M")
                        {
                            value = "Magnetic direction";
                        }
                        else
                        {
                            value = "reserved";
                        }
                    }
                    #endregion
                }
                else if (pitem.Type == 0x3)
                {
                    #region 3 = SHORT (16-bit unsigned int)

                    UInt16 uintval = BitConverter.ToUInt16(pitem.Value, 0);

                    // orientation // lookup table
                    switch (pitem.Id)
                    {
                    case 0x8827:     // ISO speed rating
                        value = "ISO-" + uintval.ToString();
                        break;

                    case 0xA217:     // sensing method
                    {
                        switch (uintval)
                        {
                        case 1: value = "Not defined"; break;

                        case 2: value = "One-chip color area sensor"; break;

                        case 3: value = "Two-chip color area sensor"; break;

                        case 4: value = "Three-chip color area sensor"; break;

                        case 5: value = "Color sequential area sensor"; break;

                        case 7: value = "Trilinear sensor"; break;

                        case 8: value = "Color sequential linear sensor"; break;

                        default: value = " reserved"; break;
                        }
                    }
                    break;

                    case 0x8822:     // Exposure program
                        switch (uintval)
                        {
                        case 0: value = "Not defined"; break;

                        case 1: value = "Manual"; break;

                        case 2: value = "Normal program"; break;

                        case 3: value = "Aperture priority"; break;

                        case 4: value = "Shutter priority"; break;

                        case 5: value = "Creative program (biased toward depth of field)"; break;

                        case 6: value = "Action program (biased toward fast shutter speed)"; break;

                        case 7: value = "Portrait mode (for closeup photos with the background out of focus)"; break;

                        case 8: value = "Landscape mode (for landscape photos with the background in focus)"; break;

                        default: value = "reserved"; break;
                        }
                        break;

                    case 0x9207:     // metering mode
                        switch (uintval)
                        {
                        case 0: value = "unknown"; break;

                        case 1: value = "Average"; break;

                        case 2: value = "Center Weighted Average"; break;

                        case 3: value = "Spot"; break;

                        case 4: value = "MultiSpot"; break;

                        case 5: value = "Pattern"; break;

                        case 6: value = "Partial"; break;

                        case 255: value = "Other"; break;

                        default: value = "reserved"; break;
                        }
                        break;

                    case 0x9208:     // Light source
                    {
                        switch (uintval)
                        {
                        case 0: value = "unknown"; break;

                        case 1: value = "Daylight"; break;

                        case 2: value = "Fluorescent"; break;

                        case 3: value = "Tungsten (incandescent light)"; break;

                        case 4: value = "Flash"; break;

                        case 9: value = "Fine weather"; break;

                        case 10: value = "Cloudy weather"; break;

                        case 11: value = "Shade"; break;

                        case 12: value = "Daylight fluorescent (D 5700 – 7100K)"; break;

                        case 13: value = "Day white fluorescent (N 4600 – 5400K)"; break;

                        case 14: value = "Cool white fluorescent (W 3900 – 4500K)"; break;

                        case 15: value = "White fluorescent (WW 3200 – 3700K)"; break;

                        case 17: value = "Standard light A"; break;

                        case 18: value = "Standard light B"; break;

                        case 19: value = "Standard light C"; break;

                        case 20: value = "D55"; break;

                        case 21: value = "D65"; break;

                        case 22: value = "D75"; break;

                        case 23: value = "D50"; break;

                        case 24: value = "ISO studio tungsten"; break;

                        case 255: value = "ISO studio tungsten"; break;

                        default: value = "other light source"; break;
                        }
                    }
                    break;

                    case 0x9209:     // Flash
                    {
                        switch (uintval)
                        {
                        case 0x0: value = "Flash did not fire"; break;

                        case 0x1: value = "Flash fired"; break;

                        case 0x5: value = "Strobe return light not detected"; break;

                        case 0x7: value = "Strobe return light detected"; break;

                        case 0x9: value = "Flash fired, compulsory flash mode"; break;

                        case 0xD: value = "Flash fired, compulsory flash mode, return light not detected"; break;

                        case 0xF: value = "Flash fired, compulsory flash mode, return light detected"; break;

                        case 0x10: value = "Flash did not fire, compulsory flash mode"; break;

                        case 0x18: value = "Flash did not fire, auto mode"; break;

                        case 0x19: value = "Flash fired, auto mode"; break;

                        case 0x1D: value = "Flash fired, auto mode, return light not detected"; break;

                        case 0x1F: value = "Flash fired, auto mode, return light detected"; break;

                        case 0x20: value = "No flash function"; break;

                        case 0x41: value = "Flash fired, red-eye reduction mode"; break;

                        case 0x45: value = "Flash fired, red-eye reduction mode, return light not detected"; break;

                        case 0x47: value = "Flash fired, red-eye reduction mode, return light detected"; break;

                        case 0x49: value = "Flash fired, compulsory flash mode, red-eye reduction mode"; break;

                        case 0x4D: value = "Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected"; break;

                        case 0x4F: value = "Flash fired, compulsory flash mode, red-eye reduction mode, return light detected"; break;

                        case 0x59: value = "Flash fired, auto mode, red-eye reduction mode"; break;

                        case 0x5D: value = "Flash fired, auto mode, return light not detected, red-eye reduction mode"; break;

                        case 0x5F: value = "Flash fired, auto mode, return light detected, red-eye reduction mode"; break;

                        default: value = "reserved"; break;
                        }
                    }
                    break;

                    case 0x0128:     //ResolutionUnit
                    {
                        switch (uintval)
                        {
                        case 2: value = "Inch"; break;

                        case 3: value = "Centimeter"; break;

                        default: value = "No Unit"; break;
                        }
                    }
                    break;

                    case 0xA409:     // Saturation
                    {
                        switch (uintval)
                        {
                        case 0: value = "Normal"; break;

                        case 1: value = "Low saturation"; break;

                        case 2: value = "High saturation"; break;

                        default: value = "Reserved"; break;
                        }
                    }
                    break;

                    case 0xA40A:     // Sharpness
                    {
                        switch (uintval)
                        {
                        case 0: value = "Normal"; break;

                        case 1: value = "Soft"; break;

                        case 2: value = "Hard"; break;

                        default: value = "Reserved"; break;
                        }
                    }
                    break;

                    case 0xA408:     // Contrast
                    {
                        switch (uintval)
                        {
                        case 0: value = "Normal"; break;

                        case 1: value = "Soft"; break;

                        case 2: value = "Hard"; break;

                        default: value = "Reserved"; break;
                        }
                    }
                    break;

                    case 0x103:     // Compression
                    {
                        switch (uintval)
                        {
                        case 1: value = "Uncompressed"; break;

                        case 6: value = "JPEG compression (thumbnails only)"; break;

                        default: value = "Reserved"; break;
                        }
                    }
                    break;

                    case 0x106:     // PhotometricInterpretation
                    {
                        switch (uintval)
                        {
                        case 2: value = "RGB"; break;

                        case 6: value = "YCbCr"; break;

                        default: value = "Reserved"; break;
                        }
                    }
                    break;

                    case 0x112:     // Orientation
                    {
                        /*
                         * switch (uintval)
                         * {
                         *  case 1: value = "The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side."; break;
                         *  case 2: value = "The 0th row is at the visual top of the image, and the 0th column is the visual right-hand side."; break;
                         *  case 3: value = "The 0th row is at the visual bottom of the image, and the 0th column is the visual right-hand side."; break;
                         *  case 4: value = "The 0th row is at the visual bottom of the image, and the 0th column is the visual left-hand side."; break;
                         *  case 5: value = "The 0th row is the visual left-hand side of the image, and the 0th column is the visual top."; break;
                         *  case 6: value = "The 0th row is the visual right-hand side of the image, and the 0th column is the visual top."; break;
                         *  case 7: value = "The 0th row is the visual right-hand side of the image, and the 0th column is the visual bottom."; break;
                         *  case 8: value = "The 0th row is the visual left-hand side of the image, and the 0th column is the visual bottom."; break;
                         *  default: value = "Reserved"; break;
                         * }
                         * */
                        value = uintval.ToString();
                    }
                    break;

                    case 0x213:     // YCbCrPositioning
                    {
                        switch (uintval)
                        {
                        case 1: value = "centered"; break;

                        case 6: value = "co-sited"; break;

                        default: value = "Reserved"; break;
                        }
                    }
                    break;

                    case 0xA001:     // ColorSpace
                    {
                        switch (uintval)
                        {
                        case 1: value = "sRGB"; break;

                        case 0xFFFF: value = "Uncalibrated"; break;

                        default: value = "Reserved"; break;
                        }
                    }
                    break;

                    case 0xA401:     // CustomRendered
                    {
                        switch (uintval)
                        {
                        case 0: value = "Normal process"; break;

                        case 1: value = "Custom process"; break;

                        default: value = "Reserved"; break;
                        }
                    }
                    break;

                    case 0xA402:     // ExposureMode
                    {
                        switch (uintval)
                        {
                        case 0: value = "Auto exposure"; break;

                        case 1: value = "Manual exposure"; break;

                        case 2: value = "Auto bracket"; break;

                        default: value = "Reserved"; break;
                        }
                    }
                    break;

                    case 0xA403:     // WhiteBalance
                    {
                        switch (uintval)
                        {
                        case 0: value = "Auto white balance"; break;

                        case 1: value = "Manual white balance"; break;

                        default: value = "Reserved"; break;
                        }
                    }
                    break;

                    case 0xA406:     // SceneCaptureType
                    {
                        switch (uintval)
                        {
                        case 0: value = "Standard"; break;

                        case 1: value = "Landscape"; break;

                        case 2: value = "Portrait"; break;

                        case 3: value = "Night scene"; break;

                        default: value = "Reserved"; break;
                        }
                    }
                    break;

                    case 0xA40C:     // SubjectDistanceRange
                    {
                        switch (uintval)
                        {
                        case 0: value = "unknown"; break;

                        case 1: value = "Macro"; break;

                        case 2: value = "Close view"; break;

                        case 3: value = "Distant view"; break;

                        default: value = "Reserved"; break;
                        }
                    }
                    break;

                    case 0x1E:     // GPSDifferential
                    {
                        switch (uintval)
                        {
                        case 0: value = "Measurement without differential correction"; break;

                        case 1: value = "Differential correction applied"; break;

                        default: value = "Reserved"; break;
                        }
                    }
                    break;

                    case 0xA405:     // FocalLengthIn35mmFilm
                        value = uintval.ToString() + " mm";
                        break;

                    default:    //
                        value = uintval.ToString();
                        break;
                    }
                    #endregion
                }
                else if (pitem.Type == 0x4)
                {
                    #region 4 = LONG (32-bit unsigned int)
                    value = BitConverter.ToUInt32(pitem.Value, 0).ToString();
                    #endregion
                }
                else if (pitem.Type == 0x5)
                {
                    #region 5 = RATIONAL (Two LONGs, unsigned)

                    URational rat = new URational(pitem.Value);

                    switch (pitem.Id)
                    {
                    case 0x9202:     // ApertureValue
                        value = "F/" + Math.Round(Math.Pow(Math.Sqrt(2), rat.ToDouble()), 2).ToString();
                        break;

                    case 0x9205:     // MaxApertureValue
                        value = "F/" + Math.Round(Math.Pow(Math.Sqrt(2), rat.ToDouble()), 2).ToString();
                        break;

                    case 0x920A:     // FocalLength
                        value = rat.ToDouble().ToString() + " mm";
                        break;

                    case 0x829D:     // F-number
                        value = "F/" + rat.ToDouble().ToString();
                        break;

                    case 0x11A:     // Xresolution
                        value = rat.ToDouble().ToString();
                        break;

                    case 0x11B:     // Yresolution
                        value = rat.ToDouble().ToString();
                        break;

                    case 0x829A:     // ExposureTime
                        value = rat.ToString() + " sec";
                        break;

                    case 0x2:     // GPSLatitude
                        value = new GPSRational(pitem.Value).ToString();
                        break;

                    case 0x4:     // GPSLongitude
                        value = new GPSRational(pitem.Value).ToString();
                        break;

                    case 0x6:     // GPSAltitude
                        value = rat.ToDouble() + " meters";
                        break;

                    case 0xA404:     // Digital Zoom Ratio
                        value = rat.ToDouble().ToString();
                        if (value == "0")
                        {
                            value = "none";
                        }
                        break;

                    case 0xB:     // GPSDOP
                        value = rat.ToDouble().ToString();
                        break;

                    case 0xD:     // GPSSpeed
                        value = rat.ToDouble().ToString();
                        break;

                    case 0xF:     // GPSTrack
                        value = rat.ToDouble().ToString();
                        break;

                    case 0x11:     // GPSImgDir
                        value = rat.ToDouble().ToString();
                        break;

                    case 0x14:     // GPSDestLatitude
                        value = new GPSRational(pitem.Value).ToString();
                        break;

                    case 0x16:     // GPSDestLongitude
                        value = new GPSRational(pitem.Value).ToString();
                        break;

                    case 0x18:     // GPSDestBearing
                        value = rat.ToDouble().ToString();
                        break;

                    case 0x1A:     // GPSDestDistance
                        value = rat.ToDouble().ToString();
                        break;

                    case 0x7:     // GPSTimeStamp
                        value = new GPSRational(pitem.Value).ToString(":");
                        break;

                    default:
                        value = rat.ToString();
                        break;
                    }

                    #endregion
                }
                else if (pitem.Type == 0x7)
                {
                    #region UNDEFINED (8-bit)
                    switch (pitem.Id)
                    {
                    case 0xA300:     //FileSource
                    {
                        if (pitem.Value[0] == 3)
                        {
                            value = "DSC";
                        }
                        else
                        {
                            value = "reserved";
                        }
                        break;
                    }

                    case 0xA301:     //SceneType
                        if (pitem.Value[0] == 1)
                        {
                            value = "A directly photographed image";
                        }
                        else
                        {
                            value = "reserved";
                        }
                        break;

                    case 0x9000:    // Exif Version
                        value = ascii.GetString(pitem.Value).Trim('\0');
                        break;

                    case 0xA000:     // Flashpix Version
                        value = ascii.GetString(pitem.Value).Trim('\0');
                        if (value == "0100")
                        {
                            value = "Flashpix Format Version 1.0";
                        }
                        else
                        {
                            value = "reserved";
                        }
                        break;

                    case 0x9101:     //ComponentsConfiguration
                        value = GetComponentsConfig(pitem.Value);
                        break;

                    case 0x927C:     //MakerNote
                        value = ascii.GetString(pitem.Value).Trim('\0');
                        break;

                    case 0x9286:     //UserComment
                        value = ascii.GetString(pitem.Value).Trim('\0');
                        break;

                    case 0x1B:     //GPS Processing Method
                        value = ascii.GetString(pitem.Value).Trim('\0');
                        break;

                    case 0x1C:     //GPS Area Info
                        value = ascii.GetString(pitem.Value).Trim('\0');
                        break;

                    default:
                        value = "-";
                        break;
                    }
                    #endregion
                }
                else if (pitem.Type == 0x9)
                {
                    #region 9 = SLONG (32-bit int)
                    value = BitConverter.ToInt32(pitem.Value, 0).ToString();
                    #endregion
                }
                else if (pitem.Type == 0xA)
                {
                    #region 10 = SRATIONAL (Two SLONGs, signed)

                    Rational rat = new Rational(pitem.Value);

                    switch (pitem.Id)
                    {
                    case 0x9201:     // ShutterSpeedValue
                        value = "1/" + Math.Round(Math.Pow(2, rat.ToDouble()), 2).ToString();
                        break;

                    case 0x9203:     // BrightnessValue
                        value = Math.Round(rat.ToDouble(), 4).ToString();
                        break;

                    case 0x9204:     // ExposureBiasValue
                        value = Math.Round(rat.ToDouble(), 2).ToString() + " eV";
                        break;

                    default:
                        value = rat.ToString();
                        break;
                    }
                    #endregion
                }

                tag.Value = value;

                _tags.Add(tag.Id, tag);
            }
        }
Exemplo n.º 7
0
        public bool Search(ISearchProvider provider)
        {
            var request = new QRequestSearch(this.statement);             // (IQuelleSearchRequest)
            IQuelleSearchResult response = provider != null?provider.Search(request) : null;

            if (response != null)
            {
                var messages = response.messages;
                var errors   = new List <String>();
                var warnings = new List <String>();

                if (messages != null)
                {
                    foreach (var entry in messages)
                    {
                        if (entry.Key == "errors")
                        {
                            foreach (var message in entry.Value)
                            {
                                if (!errors.Contains(message))
                                {
                                    errors.Add(message);
                                }
                            }
                        }
                    }
                    foreach (var entry in messages)
                    {
                        if (entry.Key != "errors")
                        {
                            foreach (var message in entry.Value)
                            {
                                if (!warnings.Contains(message))
                                {
                                    warnings.Add(message);
                                }
                            }
                        }
                    }

                    foreach (var error in errors)
                    {
                        Console.Out.WriteLine("Error: " + error);
                    }

                    foreach (var warning in warnings)
                    {
                        Console.Out.WriteLine("Warning: " + warning);
                    }
                }
            }
            if (errors.Count == 0 && response.matches != null)
            {
                foreach (var book in response.matches)
                {
                    UInt16 b        = book.Key;
                    var    chapters = response.matches[book.Key];
                    foreach (var chapter in book.Value)
                    {
                        UInt16 c      = chapter.Key;
                        var    verses = Quelle.DriverDefault.Utility.ExpandBitArray(chapter.Value);
                        foreach (var verse in verses)
                        {
                            UInt16 v = verse;
                            Console.Out.WriteLine(b.ToString() + ':' + c.ToString() + ':' + v.ToString());
                        }
                    }
                }
            }

            return(response != null && (response.messages == null || response.messages.Count == 0));
        }
Exemplo n.º 8
0
        private void ResponseCmd(ESMonitor.Model.TaskNotice model)
        {
            DevCtrlResponseCmd cmd = new DevCtrlResponseCmd();

            bool flag = cmd.DecodeFrame(model.Data, model.Length);

            if (flag)
            {
                switch (cmd.CmdByte)
                {
                case 0x1F:     //读取CMP
                {
                    double cmp = 0;
                    cmd.DecodeCMPReadCmd(ref cmp);
                    _json.AddItem("CMPState", "1");
                    _json.AddItem("CMP", cmp.ToString(CultureInfo.CurrentCulture));
                }

                break;

                case 0x2F:
                {
                    if (cmd.CmdType == 0xFB)
                    {
                        if (cmd.Data[0] == 0xFF)
                        {
                            _json.AddItem("coordinate", "null");
                            break;
                        }
                        byte[] data = new byte[24];
                        for (int i = 0; i < 24; i++)
                        {
                            if (cmd.Data[i] == 0x00)
                            {
                                data[i] = 0x30;
                            }
                            else
                            {
                                data[i] = cmd.Data[i];
                            }
                        }
                        string coordinate     = Encoding.ASCII.GetString(data, 0, 24).Insert(12, ",");
                        string url            = string.Format("http://api.map.baidu.com/geoconv/v1/?coords={0}&from=1&to=5&ak=0DpSiAEhexZzZR7c7pkYFq7E", coordinate);
                        var    request        = (HttpWebRequest)WebRequest.Create(url);
                        var    response       = request.GetResponse();
                        var    responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
                        JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
                        var    obj       = (Dictionary <string, object>)((object[])((Dictionary <string, object>)jsonSerializer.DeserializeObject(responseString))["result"])[0];
                        double longitude = double.Parse(obj["x"].ToString());
                        double latitude  = double.Parse(obj["y"].ToString());
                        coordinate = longitude.ToString("F6") + ";" + latitude.ToString("F6");

                        _json.AddItem("coordinate", coordinate);
                        break;
                    }
                    UInt16 cycleTime = 0;
                    cmd.DecodeCMPCycleSetCmd(ref cycleTime);
                    _json.AddItem("Cycle", cycleTime.ToString());
                }
                break;

                case 0x3F:
                {
                    byte state = 0;
                    cmd.DecodeCMStopCmd(ref state);
                    _json.AddItem("State", state.ToString());
                }
                break;

                case 0x4F:
                {
                    byte state = 0;
                    cmd.DecodeBGTestStartCmd(ref state);
                    _json.AddItem("State", state.ToString());
                }
                break;

                case 0x5F:
                {
                    byte state = 0;
                    cmd.DecodeBGTestStopCmd(ref state);
                    _json.AddItem("State", state.ToString());
                }
                break;

                case 0x6F:
                {
                    byte state = 0;
                    cmd.DecodeBGTestResultCmd(ref state);
                    _json.AddItem("State", state.ToString());
                }
                break;

                case 0x7F:
                {
                    byte state = 0;
                    cmd.DecodeSPANTestStartCmd(ref state);
                    _json.AddItem("State", state.ToString());
                }
                break;

                case 0x8F:
                {
                    byte state = 0;
                    cmd.DecodeSPANTestStopCmd(ref state);
                    _json.AddItem("State", state.ToString());
                }
                break;

                case 0x9F:
                {
                    byte state = 0;
                    cmd.DecodeSPANTestResultCmd(ref state);
                    _json.AddItem("State", state.ToString());
                }
                break;

                case 0xAF:
                {
                    byte state = 0;
                    cmd.DecodeSetOUT1Cmd(ref state);
                    _json.AddItem("State", state.ToString());
                }
                break;

                case 0xBF:
                {
                    byte state = 0;
                    cmd.DecodeSetOUT2Cmd(ref state);
                    _json.AddItem("State", state.ToString());
                }
                break;

                case 0x1D:
                {
                    double noise = 0;
                    cmd.DecodeUpInstNoiseOpenCmd(ref noise);
                    _json.AddItem("Noise", noise.ToString(CultureInfo.CurrentCulture));
                }
                break;

                case 0x2D:
                {
                    cmd.DecodeUpInstNoiseCloseCmd();
                }
                break;

                case 0x3D:
                {
                    double noise = 0;
                    cmd.DecodeUpInstNoiseCmd(ref noise);
                    _json.AddItem("Noise", noise.ToString(CultureInfo.CurrentCulture));
                }
                break;

                case 0x4D:
                {
                    double noise = 0;
                    cmd.DecodeUpOneSecNoiseOpenCmd(ref noise);
                    _json.AddItem("Noise", noise.ToString(CultureInfo.CurrentCulture));
                }
                break;

                case 0x5D:
                {
                    cmd.DecodeUpOneSecNoiseCloseCmd();
                }
                break;

                case 0x6D:
                {
                    double noise = 0;
                    cmd.DecodeUpOneSecNoiseCmd(ref noise);
                    _json.AddItem("NoiseState", "1");
                    _json.AddItem("Noise", noise.ToString(CultureInfo.CurrentCulture));
                }
                break;

                case 0x7D:
                {
                    bool state;
                    state = cmd.DecodeSetZWCmd();
                    _json.AddItem("State", (Convert.ToByte(state)).ToString());
                }
                break;

                case 0x8D:
                {
                    bool state = false;
                    cmd.DecodeSetCWCmd();
                    _json.AddItem("State", (Convert.ToByte(state)).ToString());
                }
                break;

                case 0x9D:
                {
                    bool state = false;
                    cmd.DecodeSetAWCmd();
                    _json.AddItem("State", (Convert.ToByte(state)).ToString());
                }
                break;

                case 0xAD:
                {
                    bool state = false;
                    cmd.DecodeSetFGCmd();
                    _json.AddItem("State", (Convert.ToByte(state)).ToString());
                }
                break;

                case 0xBD:
                {
                    bool state = false;
                    cmd.DecodeSetSGCmd();
                    _json.AddItem("State", (Convert.ToByte(state)).ToString());
                }
                break;

                case 0xCD:
                {
                    bool state = false;
                    cmd.DecodeSetIGCmd();
                    _json.AddItem("State", (Convert.ToByte(state)).ToString());
                }
                break;

                case 0x1B:
                {
                    byte state = 0;
                    flag = cmd.DecodeWindDirWriteDevAddrCmd(ref state);
                    _json.AddItem("State", state.ToString());
                }
                break;

                case 0x2B:
                {
                    byte   addr    = 0;
                    UInt16 windDir = 0;
                    cmd.DecodeReadWindDirCmd(ref addr, ref windDir);
                    _json.AddItem("WindDirState", "1");
                    _json.AddItem("WindDir", windDir.ToString());
                }
                break;

                case 0x1A:
                {
                    byte state = 0;
                    cmd.DecodeWindSpeedWriteDevAddrCmd(ref state);
                    _json.AddItem("State", state.ToString());
                }
                break;

                case 0x2A:
                {
                    byte   addr      = 0;
                    double windSpeed = 0;
                    cmd.DecodeReadWindSpeedCmd(ref addr, ref windSpeed);
                    _json.AddItem("WindSpeedState", "1");
                    _json.AddItem("WindSpeed", windSpeed.ToString());
                }
                break;

                case 0x19:
                {
                    double temperature = 0, humidity = 0;
                    flag = cmd.DecodeReadESDataCmd(ref temperature, ref humidity);
                    _json.AddItem("ESState", "1");
                    _json.AddItem("Temp", temperature.ToString());
                    _json.AddItem("Humidity", "1");
                    _json.AddItem("Humidity", humidity.ToString());
                }
                break;

                case 0x08:
                {
                    ESData esModel = new ESData();

                    cmd.DecodeReadAllDataCmd(ref esModel);

                    _json.AddItem("PMState", esModel.PmState.ToString());
                    _json.AddItem("Pm25", esModel.Pm25.ToString());
                    _json.AddItem("Pm100", esModel.Pm100.ToString());

                    _json.AddItem("CMPState", esModel.CmpState.ToString());
                    _json.AddItem("CMP", esModel.Cmp.ToString());

                    _json.AddItem("NoiseState", esModel.NoiseState.ToString());
                    _json.AddItem("Noise", esModel.Noise.ToString());

                    _json.AddItem("WindDirState", esModel.WindDirState.ToString());
                    _json.AddItem("WindDir", esModel.WindDir.ToString());

                    _json.AddItem("WindSpeedState", esModel.WindSpeedState.ToString());
                    _json.AddItem("WindSpeed", esModel.WindSpeed.ToString());

                    _json.AddItem("ESState", esModel.ESState.ToString());
                    _json.AddItem("Temp", esModel.Temperature.ToString());
                    _json.AddItem("Humidity", esModel.Humidity.ToString());
                    _json.AddItem("Time", model.UpdateTime.ToString());
                }
                break;

                case 0x17:
                {
                    byte state = 0;
                    cmd.DecodeSwitchAutoReport(ref state);
                    _json.AddItem("State", state.ToString());
                }
                break;
                }

                _json.ItemOk();
            }
            else
            {
                _json.success = false;
                _json.error   = "解析命令错误";
            }
        }
Exemplo n.º 9
0
        public void ATA_Write16(UInt32 addr, UInt16 value)
        {
            if (addr != DEV9Header.ATA_R_CMD & (regStatus & (DEV9Header.ATA_STAT_BUSY | DEV9Header.ATA_STAT_DRQ)) != 0)
            {
                Log_Error("*DEVICE BUSY, DROPPING WRITE");
                return;
            }
            switch (addr)
            {
            case DEV9Header.ATA_R_FEATURE:
                Log_Verb("*ATA_R_FEATURE 16bit write at address " + addr.ToString("x") + " value " + value.ToString("x"));
                IDE_ClearHOB();
                regFeatureHOB = regFeature;
                regFeature    = (byte)value;
                break;

            case DEV9Header.ATA_R_NSECTOR:
                Log_Verb("*ATA_R_NSECTOR 16bit write at address " + addr.ToString("x") + " value " + value.ToString("x"));
                IDE_ClearHOB();
                regNsectorHOB = regNsector;
                regNsector    = (byte)value;
                break;

            case DEV9Header.ATA_R_SECTOR:
                Log_Verb("*ATA_R_SECTOR 16bit write at address " + addr.ToString("x") + " value " + value.ToString("x"));
                IDE_ClearHOB();
                regSectorHOB = regSector;
                regSector    = (byte)value;
                break;

            case DEV9Header.ATA_R_LCYL:
                Log_Verb("*ATA_R_LCYL 16bit write at address " + addr.ToString("x") + " value " + value.ToString("x"));
                IDE_ClearHOB();
                regLcylHOB = regLcyl;
                regLcyl    = (byte)value;
                break;

            case DEV9Header.ATA_R_HCYL:
                Log_Verb("*ATA_R_HCYL 16bit write at address " + addr.ToString("x") + " value " + value.ToString("x"));
                IDE_ClearHOB();
                regHcylHOB = regHcyl;
                regHcyl    = (byte)value;
                break;

            case DEV9Header.ATA_R_SELECT:
                Log_Verb("*ATA_R_SELECT 16bit write at address " + addr.ToString("x") + " value " + value.ToString("x"));
                regSelect = (byte)value;
                //bus->ifs[0].select = (val & ~0x10) | 0xa0;
                //bus->ifs[1].select = (val | 0x10) | 0xa0;
                break;

            case DEV9Header.ATA_R_CONTROL:
                Log_Verb("*ATA_R_CONTROL 16bit write at address " + addr.ToString("x") + " value " + value.ToString("x"));
                dev9.Dev9Wu16((int)DEV9Header.ATA_R_CONTROL, value);
                if ((value & 0x2) != 0)
                {
                    //Supress all IRQ
                    dev9.spd.regIntStat &= unchecked ((UInt16) ~DEV9Header.ATA_INTR_INTRQ);
                    regControlEnableIRQ  = false;
                }
                else
                {
                    regControlEnableIRQ = true;
                }
                if ((value & 0x4) != 0)
                {
                    Log_Verb("*ATA_R_CONTROL RESET");
                    ResetBegin();
                    ResetEnd(false);
                }
                if ((value & 0x80) != 0)
                {
                    regControlHOBRead = true;
                }
                break;

            case DEV9Header.ATA_R_CMD:
                Log_Verb("*ATA_R_CMD 16bit write at address " + addr.ToString("x") + " value " + value.ToString("x"));
                regCommand           = value;
                regControlHOBRead    = false;
                dev9.spd.regIntStat &= unchecked ((UInt16) ~DEV9Header.ATA_INTR_INTRQ);
                IDE_ExecCmd(value);
                break;

            default:
                Log_Error("*UNKOWN 16bit write at address " + addr.ToString("x") + " value " + value.ToString("x"));
                break;
            }
        }
Exemplo n.º 10
0
        public void processHardlineTeleport(ref byte[] packet)
        {
            // we dont care where the journey goes
            // just want to see IF the journey will do :)
            // for this just ack and send 0x42 packet
            byte[] sourceHardline = new byte[2];
            sourceHardline[0] = packet[0];
            sourceHardline[1] = packet[1];

            byte[] sourceDistrict = new byte[2];
            sourceDistrict[0] = packet[4];
            sourceDistrict[1] = packet[5];

            byte[] destHardline = new byte[2];
            destHardline[0] = packet[8];
            destHardline[1] = packet[9];

            byte[] destDistrict = new byte[2];
            destDistrict[0] = packet[12];
            destDistrict[1] = packet[13];

            UInt16 sourceHL  = NumericalUtils.ByteArrayToUint16(sourceHardline, 1);
            UInt16 sourceDIS = NumericalUtils.ByteArrayToUint16(sourceDistrict, 1);

            UInt16 destHL  = NumericalUtils.ByteArrayToUint16(destHardline, 1);
            UInt16 destDIS = NumericalUtils.ByteArrayToUint16(destDistrict, 1);

            // This should do the magic - we just catch
            Store.dbManager.WorldDbHandler.updateLocationByHL(destDIS, destHL);
            Store.dbManager.WorldDbHandler.updateSourceHlForObjectTracking(sourceDIS, sourceHL, Store.currentClient.playerData.lastClickedObjectId);

            #if DEBUG
            ServerPackets serverPak = new ServerPackets();
            serverPak.sendSystemChatMessage(Store.currentClient, "User wants teleport from : HL ID: " + sourceHL.ToString() + " (DIS: " + sourceDIS.ToString() + " ) TO HL ID: " + destHL.ToString() + " (DIS: " + destDIS.ToString() + ") ", "MODAL");
            #endif

            // Tell client we want to unload the World
            PacketContent pak = new PacketContent();
            pak.addUint16((UInt16)RPCResponseHeaders.SERVER_LOAD_RPC_RESET, 0);
            Store.currentClient.messageQueue.addRpcMessage(pak.returnFinalPacket());
            Store.currentClient.FlushQueue();
        }
Exemplo n.º 11
0
        /// <summary>
        /// Unlock the PCM by requesting a 'seed' and then sending the corresponding 'key' value.
        /// </summary>
        public async Task <bool> UnlockEcu(int keyAlgorithm)
        {
            await this.device.SetTimeout(TimeoutScenario.ReadProperty);

            this.device.ClearMessageQueue();

            this.logger.AddDebugMessage("Sending seed request.");
            Message seedRequest = this.messageFactory.CreateSeedRequest();

            if (!await this.TrySendMessage(seedRequest, "seed request"))
            {
                this.logger.AddUserMessage("Unable to send seed request.");
                return(false);
            }

            bool   seedReceived = false;
            UInt16 seedValue    = 0;

            for (int attempt = 1; attempt < MaxReceiveAttempts; attempt++)
            {
                Message seedResponse = await this.device.ReceiveMessage();

                if (seedResponse == null)
                {
                    this.logger.AddDebugMessage("No response to seed request.");
                    return(false);
                }

                if (this.messageParser.IsUnlocked(seedResponse.GetBytes()))
                {
                    this.logger.AddUserMessage("PCM is already unlocked");
                    return(true);
                }

                this.logger.AddDebugMessage("Parsing seed value.");
                Response <UInt16> seedValueResponse = this.messageParser.ParseSeed(seedResponse.GetBytes());
                if (seedValueResponse.Status == ResponseStatus.Success)
                {
                    seedValue    = seedValueResponse.Value;
                    seedReceived = true;
                    break;
                }

                this.logger.AddDebugMessage("Unable to parse seed response. Attempt #" + attempt.ToString());
            }

            if (!seedReceived)
            {
                this.logger.AddUserMessage("No seed reponse received, unable to unlock PCM.");
                return(false);
            }

            if (seedValue == 0x0000)
            {
                this.logger.AddUserMessage("PCM Unlock not required");
                return(true);
            }

            UInt16 key = KeyAlgorithm.GetKey(keyAlgorithm, seedValue);

            this.logger.AddDebugMessage("Sending unlock request (" + seedValue.ToString("X4") + ", " + key.ToString("X4") + ")");
            Message unlockRequest = this.messageFactory.CreateUnlockRequest(key);

            if (!await this.TrySendMessage(unlockRequest, "unlock request"))
            {
                this.logger.AddDebugMessage("Unable to send unlock request.");
                return(false);
            }

            for (int attempt = 1; attempt < MaxReceiveAttempts; attempt++)
            {
                Message unlockResponse = await this.device.ReceiveMessage();

                if (unlockResponse == null)
                {
                    this.logger.AddDebugMessage("No response to unlock request. Attempt #" + attempt.ToString());
                    continue;
                }

                string          errorMessage;
                Response <bool> result = this.messageParser.ParseUnlockResponse(unlockResponse.GetBytes(), out errorMessage);
                if (errorMessage == null)
                {
                    return(result.Value);
                }

                this.logger.AddUserMessage(errorMessage);
            }

            this.logger.AddUserMessage("Unable to process unlock response.");
            return(false);
        }
Exemplo n.º 12
0
        public static ColorPalette Import(string filePath)
        {
            ColorPalette colorPalette = new ColorPalette();

            colorPalette.name = Path.GetFileNameWithoutExtension(filePath);

            byte[] data = File.ReadAllBytes(filePath);
            if (data.Length < 12 || data[0] != 'A' || data[1] != 'S' || data[2] != 'E' || data[3] != 'F')
            {
                throw new UnityException("The file " + filePath + " doesn't seem to be in Adobe Swatch Exchange (ASE) format.");
            }

            UInt32 blocks = GetInt32(data, 8);

            int offset = 12;

            for (int b = 0; b < blocks; b++)
            {
                UInt16 blockType = GetInt16(data, offset);
                offset += sizeof(UInt16);

                UInt32 blockLength = GetInt32(data, offset);
                offset += sizeof(UInt32);

                switch (blockType)
                {
                case 0xC001:                 // Group Start Block (ignored)
                    break;

                case 0xC002:                 // Group End Block (ignored)
                    break;

                case 0x0001:                 // Color
                    ParserColorResult colorResult = ReadColor(data, offset, b);
                    if (colorResult.success)
                    {
                        colorPalette.colorInfoList.Add(new ColorInfo(colorResult.name, colorResult.color));
                    }
                    break;

                default:
                    throw new UnityException("Warning: Block " + b + " is of an unknown type 0x" + blockType.ToString("X") + " (file corrupt?)");
                }

                offset += (int)blockLength;
            }

            if (colorPalette.colorInfoList == null || colorPalette.colorInfoList.Count == 0)
            {
                throw new UnityException("Error parsing the .ase file at path: " + filePath + ". Are you sure you selected a valid file?");
            }

            return(colorPalette);
        }
Exemplo n.º 13
0
 public void WriteValue(string section, string key, UInt16 value)
 {
     NativeMethods.WritePrivateProfileString(section, key, value.ToString(CultureInfo.InvariantCulture), Path);
 }
Exemplo n.º 14
0
    public Boolean runTest()
    {
        Console.WriteLine(s_strTFPath + " " + s_strTFName + " ,for " + s_strComponentBeingTested + "  ,Source ver " + s_strDtTmVer);
        String     strBaseLoc;
        XenoUInt16 xeno = new XenoUInt16();
        UInt16     i    = ((UInt16)0);

        try
        {
            NumberFormatInfo nfi = NumberFormatInfo.CurrentInfo;
            m_strLoc = "Loc_normalTests";
            String testStr = "";
            UInt16 testUI;
            while (xeno.HasMoreValues())
            {
                i = ((UInt16)xeno.GetNextValue());
                iCountTestcases++;
                testStr = i.ToString("d");
                testUI  = UInt16.Parse(testStr, NumberStyles.Any, nfi);
                if (testUI != i)
                {
                    Console.WriteLine("Fail! " + testUI + " != " + i);
                    iCountErrors++;
                }
                iCountTestcases++;
                testUI = UInt16.Parse(testStr.PadLeft(i, ' '), NumberStyles.Any, nfi);
                if (testUI != i)
                {
                    Console.WriteLine("Fail! (pad left)" + testUI + " != " + i);
                    iCountErrors++;
                }
                iCountTestcases++;
                testUI = UInt16.Parse(testStr.PadRight(i, ' '), NumberStyles.Any, nfi);
                if (testUI != i)
                {
                    Console.WriteLine("Fail! (pad right)" + testUI + " != " + i);
                    iCountErrors++;
                }
                iCountTestcases++;
                testUI = UInt16.Parse(testStr.PadRight(i, ' ').PadLeft(i, ' '), NumberStyles.Any, nfi);
                if (testUI != i)
                {
                    Console.WriteLine("Fail! (pad right+left) " + testUI + " != " + i);
                    iCountErrors++;
                }
                try {
                    iCountTestcases++;
                    testStr = i.ToString("E");
                    testUI  = UInt16.Parse(testStr, NumberStyles.AllowCurrencySymbol, nfi);
                    iCountErrors++;
                    Console.WriteLine("Failed! NumberStyle.AllowCurrencySymbol::No exception Thrown! String = '" + testStr + "'");
                }
                catch (FormatException fe) {}
                catch (Exception e) {
                    iCountErrors++;
                    Console.WriteLine("Failed! Wrong exception: '" + e + "'");
                }
            }
            try {
                iCountTestcases++;
                testStr = i.ToString("E", nfi);
                testUI  = UInt16.Parse(testStr, NumberStyles.AllowLeadingSign);
                iCountErrors++;
                Console.WriteLine("Failed! No exception Thrown! String = '" + testStr + "'");
            }
            catch (FormatException fe) {}
            catch (Exception e) {
                iCountErrors++;
                Console.WriteLine("Failed! Wrong exception: '" + e + "'");
            }
            try {
                iCountTestcases++;
                UInt16 UI = UInt16.Parse(null, NumberStyles.Any, nfi);
                iCountErrors++;
                Console.WriteLine("Failed! No exception Thrown! String = '" + testStr + "'");
            }
            catch (ArgumentException ae) {}
            catch (Exception e) {
                iCountErrors++;
                Console.WriteLine("Failed! Wrong exception: '" + e + "'");
            }
        }
        catch (Exception exc_general)
        {
            ++iCountErrors;
            Console.WriteLine("Error Err_8888yyy (" + s_strTFAbbrev + ")!  Unexpected exception thrown sometime after m_strLoc==" + m_strLoc + " ,exc_general==" + exc_general);
        }
        Console.Write(Environment.NewLine);
        Console.WriteLine("Total Tests Ran: " + iCountTestcases + " Failed Tests: " + iCountErrors);
        if (iCountErrors == 0)
        {
            Console.WriteLine("paSs.   " + s_strTFPath + " " + s_strTFName + "  ,iCountTestcases==" + iCountTestcases);
            return(true);
        }
        else
        {
            Console.WriteLine("FAiL!   " + s_strTFPath + " " + s_strTFName + "  ,iCountErrors==" + iCountErrors + " ,BugNums?: " + s_strActiveBugNums);
            return(false);
        }
    }
Exemplo n.º 15
0
 public static string ToString(UInt16 value)
 {
     return value.ToString(null, NumberFormatInfo.InvariantInfo);
 }
Exemplo n.º 16
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g e t P C L F o n t S e l e c t                                    //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Return the PCL font selection sequence.                            //
        // ... except for the root '<esc>(' prefix.                           //
        //                                                                    //
        //--------------------------------------------------------------------//

        public String getPCLFontSelect(PCLFonts.eVariant variant,
                                       Double height,
                                       Double pitch)
        {
            String seq;

            if (_proportional)
            {
                seq = "s1p";
            }
            else
            {
                seq = "s0p";
            }

            if (_scalable)
            {
                // Scalable; the size parameter defines the required size.

                if (_proportional)
                {
                    // Scalable; proportionally-spaced
                    seq += height.ToString() + "v";
                }
                else
                {
                    // Scalable; fixed-pitch
                    if (pitch != 0.0)
                    {
                        seq += pitch.ToString() + "h";
                    }
                    else
                    {
                        Double calcPitch = (7200 /
                                            (height * _contourRatio));
                        seq += calcPitch.ToString("F2") + "h";
                    }
                }
            }
            else
            {
                // Bitmap; the size is pre-defined.

                if (_proportional)
                {
                    // Bitmap; proportionally-spaced
                    seq += _pointSize.ToString() + "v";
                }
                else
                {
                    // Bitmap; fixed-pitch
                    seq += _pointSize.ToString() + "v" +
                           _pitch.ToString() + "h";
                }
            }

            if (variant == PCLFonts.eVariant.Italic)
            {
                seq += _styleItalic.ToString() + "s" +
                       _weightItalic.ToString() + "b";
            }
            else if (variant == PCLFonts.eVariant.Bold)
            {
                seq += _styleBold.ToString() + "s" +
                       _weightBold.ToString() + "b";
            }
            else if (variant == PCLFonts.eVariant.BoldItalic)
            {
                seq += _styleBoldItalic.ToString() + "s" +
                       _weightBoldItalic.ToString() + "b";
            }
            else
            {
                seq += _styleRegular.ToString() + "s" +
                       _weightRegular.ToString() + "b";
            }

            seq += _typeface + "T";

            return(seq);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Returns a string representation  of the object
        /// </summary>
        /// <returns>a string represetnation</returns>
        public override string ToString()
        {
            string description = fcs.ToString();

            description += ", seqNo: " + seqNo.ToString();
            AddressingMode dstMode = fcs.DstAddrMode;
            AddressingMode srcMode = fcs.SrcAddrMode;

            switch (dstMode)
            {
            case AddressingMode.None:
                description += ", no dst";
                break;

            case AddressingMode.Reserved:
                description += ", bad dst";
                break;

            case AddressingMode.Short:
                description += ", dstPanId: " + dstPanId.ToString();
                description += ", dstAddrShort: " + HexConverter.ConvertUintToHex(dstAddrShort, 4);
                break;

            case AddressingMode.Extended:
                description += ", dstPanId: " + dstPanId.ToString();
                description += ", dstAddrExt: " + HexConverter.ConvertUint64ToHex(dstAddrExt, 16);
                break;

            default:
                description += ", bad dst";
                break;
            }

            switch (srcMode)
            {
            case AddressingMode.None:
                description += ", no src";
                break;

            case AddressingMode.Reserved:
                description += ", bad src";
                break;

            case AddressingMode.Short:
                if (!fcs.PanIdCompression)
                {
                    description += ", srcPanId: " + srcPanId.ToString();
                }
                description += ", srcAddrShort: " + HexConverter.ConvertUintToHex(srcAddrShort, 4);
                break;

            case AddressingMode.Extended:
                if (!fcs.PanIdCompression)
                {
                    description += ", srcPanId: " + srcPanId.ToString();
                }
                description += ", srcAddrExt: " + HexConverter.ConvertUint64ToHex(srcAddrExt, 16);
                break;

            default:
                description += ", bad src";
                break;
            }

            // FIXME: secHeader
            return(description);
        }
Exemplo n.º 18
0
        public string GetValue()
        {
            UInt16 result = TrainerFacade.Instance.GameMem.ReadUInt16(Address);

            return(result.ToString());
        }
Exemplo n.º 19
0
        private void var_refresh()
        {
            /* TODO:  This portion should be a critical section, to ensure */
            /* receival of new bytes during the following block is prohibited */
            byte[] usart_bytes;
            int    usart_data_offset;
            int    n_bytes_from_usart;

            lock (bufferLock)
            {
                if (bytes_from_usart == null)
                {
                    return;
                }
                if (num_bytes_from_usart == 0)
                {
                    return;
                }
                n_bytes_from_usart = num_bytes_from_usart;
                usart_data_offset  = bytes_from_usart_offset;
                usart_bytes        = new byte[n_bytes_from_usart];
                System.Buffer.BlockCopy(bytes_from_usart, 0, usart_bytes, 0, n_bytes_from_usart);
                bytes_from_usart = null;
            }
            /* End of proposed critical section */
            num_bytes_from_usart = 0;
            try
            {
                int  valid_bytes_available = n_bytes_from_usart - bytes_from_usart_offset;
                bool end_of_data           = false;
                while (!end_of_data)
                {
                    if ((usart_bytes != null) && (valid_bytes_available >= 2))
                    {
                        if ((usart_bytes[usart_data_offset] == Convert.ToByte(navx_msg_start_char)) &&
                            (usart_bytes[usart_data_offset + 1] == Convert.ToByte(navx_binary_msg_indicator)))
                        {
                            /* Valid packet start found */
                            if ((usart_bytes[usart_data_offset + 2] == navx_board_id_msg_length - 2) &&
                                (usart_bytes[usart_data_offset + 3] == Convert.ToByte(navx_board_id_msg_type)))
                            {
                                /* Mag Cal Data Response received */
                                byte[] bytes = new byte[navx_board_id_msg_length];
                                System.Buffer.BlockCopy(usart_bytes, usart_data_offset, bytes, 0, navx_board_id_msg_length);
                                valid_bytes_available -= navx_board_id_msg_length;
                                usart_data_offset     += navx_board_id_msg_length;
                                byte   boardtype   = bytes[4];
                                byte   hwrev       = bytes[5];
                                byte   fw_major    = bytes[6];
                                byte   fw_minor    = bytes[7];
                                UInt16 fw_revision = BitConverter.ToUInt16(bytes, 8);
                                byte[] unique_id   = new byte[12];
                                for (int i = 0; i < 12; i++)
                                {
                                    unique_id[i] = bytes[10 + i];
                                }

                                if (boardtype == 50)
                                {
                                    if (hwrev == 33)
                                    {
                                        boardType.Text = "navX-MXP";
                                    }
                                    else if (hwrev == 40)
                                    {
                                        boardType.Text = "navX-Micro";
                                    }
                                }
                                else
                                {
                                    boardType.Text = boardtype.ToString();
                                }
                                boardVersion.Text    = hwrev.ToString();
                                firmwareVersion.Text = fw_major.ToString() + "." + fw_minor.ToString() + "." + fw_revision.ToString();
                                boardID.Text         = BitConverter.ToString(unique_id);
                                label1.Enabled       = true;
                                label2.Enabled       = true;
                                label3.Enabled       = true;
                                label8.Enabled       = true;
                            }
                            else
                            {
                                // Start of packet found, but not wanted
                                valid_bytes_available -= 1;
                                usart_data_offset     += 1;
                                // Keep scanning through the remainder of the buffer
                            }
                        }
                        else
                        {
                            // Data available, but first char is not a valid start of message.
                            // Keep scanning through the remainder of the buffer
                            valid_bytes_available -= 1;
                            usart_data_offset     += 1;
                        }
                    }
                    else
                    {
                        // At end of buffer, stop scanning
                        end_of_data = true;
                    }
                }
                //empty_serial_data_counter++;
                if (empty_serial_data_counter >= 10)
                {
                    close_port();
                    dialog_in_progress = true;
                    MessageBox.Show("No serial data.", "Warning!");
                    dialog_in_progress = false;
                }
            }
            catch (Exception ex)
            {
                close_port();
                dialog_in_progress = true;
                MessageBox.Show("Serial port error.  " + ex.Message, "Warning!");
                dialog_in_progress = false;
            }
        }
Exemplo n.º 20
0
 private void UpdateUIAction(UInt16 mailId, UInt16 volume, UInt16 weight)
 {
     this.textBoxID.Text     = mailId.ToString();
     this.textBoxVolume.Text = volume.ToString();
     this.textBoxWeight.Text = weight.ToString();
 }
        public override void MTL_Alarm_Report(object sender, ValueChangedEventArgs args)
        {
            var recevie_function =
                scApp.getFunBaseObj <MtlToOHxC_AlarmReport_PH2>(eqpt.EQPT_ID) as MtlToOHxC_AlarmReport_PH2;
            var send_function =
                scApp.getFunBaseObj <MtlToOHxC_ReplyAlarmReport_PH2>(eqpt.EQPT_ID) as MtlToOHxC_ReplyAlarmReport_PH2;

            try
            {
                recevie_function.Read(bcfApp, eqpt.EqptObjectCate, eqpt.EQPT_ID);
                LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(MTSValueDefMapActionNewPH2), Device: SCAppConstants.DeviceName.DEVICE_NAME_MTx,
                              Data: recevie_function.ToString(),
                              XID: eqpt.EQPT_ID);
                UInt16 error_code = recevie_function.ErrorCode;
                ProtocolFormat.OHTMessage.ErrorStatus status = (ProtocolFormat.OHTMessage.ErrorStatus)recevie_function.ErrorStatus;
                ushort hand_shake = recevie_function.Handshake;

                send_function.Handshake = hand_shake;
                send_function.Write(bcfApp, eqpt.EqptObjectCate, eqpt.EQPT_ID);
                eqpt.SynchronizeTime = DateTime.Now;
                if (hand_shake == 1)
                {
                    scApp.LineService.ProcessAlarmReport(eqpt.NODE_ID, eqpt.EQPT_ID, eqpt.Real_ID, "", error_code.ToString(), status);
                }

                LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(MTSValueDefMapActionNewPH2), Device: SCAppConstants.DeviceName.DEVICE_NAME_MTx,
                              Data: send_function.ToString(),
                              XID: eqpt.EQPT_ID);
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception");
            }
            finally
            {
                scApp.putFunBaseObj <MtlToOHxC_AlarmReport_PH2>(recevie_function);
                scApp.putFunBaseObj <MtlToOHxC_ReplyAlarmReport_PH2>(send_function);
            }
        }
Exemplo n.º 22
0
        public void UpdateActualValueLabel(MemoryModifier m)
        {
            int bytesToRead = -1;

            switch (modAddress.type)
            {
            case (int)ModAddress.dataTypes.Byte:
            {
                bytesToRead = 1;
                byte av = m.ReadFromAddress(modAddress.address, bytesToRead)[0];
                lbl_actual_value.Text = av.ToString();
                break;
            }

            case (int)ModAddress.dataTypes.UInt16:
            {
                bytesToRead = 2;
                UInt16 av = BitConverter.ToUInt16(m.ReadFromAddress(modAddress.address, bytesToRead), 0);
                lbl_actual_value.Text = av.ToString();
                break;
            }

            case (int)ModAddress.dataTypes.Int16:
            {
                bytesToRead = 2;
                Int16 av = BitConverter.ToInt16(m.ReadFromAddress(modAddress.address, bytesToRead), 0);
                lbl_actual_value.Text = av.ToString();
                break;
            }

            case (int)ModAddress.dataTypes.UInt32:
            {
                bytesToRead = 4;
                UInt32 av = BitConverter.ToUInt32(m.ReadFromAddress(modAddress.address, bytesToRead), 0);
                lbl_actual_value.Text = av.ToString();
                break;
            }

            case (int)ModAddress.dataTypes.Int32:
            {
                bytesToRead = 4;
                Int32 av = BitConverter.ToInt32(m.ReadFromAddress(modAddress.address, bytesToRead), 0);
                lbl_actual_value.Text = av.ToString();
                break;
            }

            case (int)ModAddress.dataTypes.UInt64:
            {
                bytesToRead = 8;
                UInt64 av = BitConverter.ToUInt64(m.ReadFromAddress(modAddress.address, bytesToRead), 0);
                lbl_actual_value.Text = av.ToString();
                break;
            }

            case (int)ModAddress.dataTypes.Int64:
            {
                bytesToRead = 8;
                Int64 av = BitConverter.ToInt64(m.ReadFromAddress(modAddress.address, bytesToRead), 0);
                lbl_actual_value.Text = av.ToString();
                break;
            }

            case (int)ModAddress.dataTypes.Float:
            {
                bytesToRead = 4;
                float av = BitConverter.ToSingle(m.ReadFromAddress(modAddress.address, bytesToRead), 0);
                lbl_actual_value.Text = av.ToString();
                break;
            }

            case (int)ModAddress.dataTypes.Double:
            {
                bytesToRead = 8;
                double av = BitConverter.ToDouble(m.ReadFromAddress(modAddress.address, bytesToRead), 0);
                lbl_actual_value.Text = av.ToString();
                break;
            }

            default: bytesToRead = -1; break;
            }
        }
Exemplo n.º 23
0
        public void Display()
        {
            int count = 0;

            Logger.LogNormal("Pattern header length:" + patternHeaderLength.ToString("x08"));
            Logger.LogNormal("Packing type:" + packingType.ToString("x02"));
            Logger.LogNormal("Number of rows in pattern:" + numberOfRowsInPattern.ToString("x04"));
            Logger.LogNormal("Packed patterndata size:" + packedPatterndataSize.ToString("x04"));
            Logger.LogNormal("Packed pattern data:" + System.Text.Encoding.ASCII.GetString(packedPatternData));

            note       = new Byte[packedPatterndataSize];
            instrument = new Byte[packedPatterndataSize];

            for (int i = 0; i < packedPatterndataSize; i++)
            {
                note[count]       = 0x00;
                instrument[count] = 0x00;

                if ((packedPatternData[i] & 0x80) == 0x80)
                {
                    Byte flag = packedPatternData[i];

                    //Debug.Log( "MSB use:" + packedPatternData[i].ToString( "x02" ) );

                    if ((flag & 0x01) == 0x01)
                    {
                        i++;

                        note[count] = packedPatternData[i];
                        //Debug.Log( "	Note:" + packedPatternData[i].ToString( "d" ) );
                    }

                    if ((flag & 0x02) == 0x02)
                    {
                        i++;

                        instrument[count] = packedPatternData[i];
                        //Debug.Log( "	Instrument:" + packedPatternData[i].ToString( "d" ) );
                    }

                    if ((flag & 0x04) == 0x04)
                    {
                        i++;

                        Logger.LogNormal("	Volume column byte:"+ packedPatternData[i].ToString("d"));
                    }

                    if ((flag & 0x08) == 0x08)
                    {
                        i++;

                        Logger.LogNormal("	Effect type:"+ packedPatternData[i].ToString("d"));
                    }

                    if ((flag & 0x10) == 0x10)
                    {
                        Logger.LogNormal("	Guess what!");
                    }
                }
                else
                {
                    note[count] = packedPatternData[i];
                    //Debug.Log( "	Note:" + packedPatternData[i].ToString( "d" ) );

                    i++;
                    instrument[count] = packedPatternData[i];
                    //Debug.Log( "	Instrument:" + packedPatternData[i].ToString( "d" ) );

                    i++;
                    Logger.LogNormal("	Volume column byte:"+ packedPatternData[i].ToString("d"));

                    i++;
                    Logger.LogNormal("	Effect type:"+ packedPatternData[i].ToString("d"));

                    i++;
                    Logger.LogNormal("	Effect parameter:"+ packedPatternData[i].ToString("d"));
                }

                count++;
            }
        }
Exemplo n.º 24
0
        private void buttonGenerate_Click_1(object sender, EventArgs e)
        {
            m_alRememberNodeNames.Clear();

            textBoxResult.Clear();
            textBoxResult2.Clear();
            textBoxDescSum.Clear();

            TreeNode RootNode = treeView1.Nodes[0];

            textBoxResult.AppendText("//******** START OF AUTO-GENERATED HEADER DO NOT EDIT!!! *********" + Environment.NewLine);
            textBoxResult.AppendText("//********          Generated with Treebuilder.exe       *********" + Environment.NewLine + Environment.NewLine);


            // some Defines
            textBoxResult.AppendText(" #define\tMENUESIZE\t" + treeView1.GetNodeCount(true) + "\t// number of menu itmes (array size)" + Environment.NewLine);
            textBoxResult.AppendText(" #define\tMAX_ITEM_NAME_CHARLENGTH\t" + GetSubNodeMaxNameLength(treeView1.Nodes[0]) + "\t// max name length" + Environment.NewLine);

            m_Generateduuid  = GetSubNodeUID(RootNode);
            m_Generateduuid += Convert.ToUInt16(treeView1.GetNodeCount(true));
            m_Generateduuid += Convert.ToUInt16(treeView1.GetNodeCount(true));
            textBoxResult.AppendText(" #define\tMENUGENUID\t" + m_Generateduuid.ToString("") + "\t// Generation UID" + Environment.NewLine);



            // Parameter enum
            if (checkBoxCreateEnum.Checked)
            {
                textBoxResult.AppendText("// Enum definitions" + Environment.NewLine);
                textBoxResult.AppendText(
                    "typedef enum" + Environment.NewLine +
                    "{" + Environment.NewLine);
                UpdateParComboBox(treeView1.Nodes[0]);
                foreach (string s in comboBoxParType.Items)
                {
                    textBoxResult.AppendText("\t" + s + "," + Environment.NewLine);
                }
                textBoxResult.AppendText(
                    "} eParameterType_t;" + Environment.NewLine);
            }
            textBoxResult.AppendText(Environment.NewLine);

            // Parameter externals
            textBoxResult.AppendText("// Parameter externals" + Environment.NewLine);
            textBoxResult.AppendText("typedef struct " + textBoxParStructName.Text + "_tag" + Environment.NewLine);
            textBoxResult.AppendText("{" + Environment.NewLine);

            parcount = 0; // will be counted by following fn, which is recursively called.
            ProcessParameterExternals(treeView1.Nodes[0]);
            textBoxResult.AppendText("} " + textBoxParStructName.Text + "_t;" + Environment.NewLine);
            textBoxResult.AppendText(Environment.NewLine);
            textBoxResult.AppendText("extern " + textBoxParStructName.Text + "_t " + textBoxParStructName.Text + ";" + Environment.NewLine);
            textBoxResult.AppendText(Environment.NewLine);

            textBoxResult.AppendText(" #define\tMENUE_PARCOUNT\t" + parcount + "\t// number of parameters" + Environment.NewLine);
            textBoxResult.AppendText(Environment.NewLine);

            textBoxResult.AppendText("// Action Prototypes" + Environment.NewLine);
            ProcessActionPrototypes(treeView1.Nodes[0]);
            textBoxResult.AppendText(Environment.NewLine);


            // Process the text definitions
            textBoxResult.AppendText("// Text definitions" + Environment.NewLine);
            textBoxResult.AppendText("#ifndef MENUE_TEXT_VARDEF" + Environment.NewLine);
            textBoxResult.AppendText("#define MENUE_TEXT_VARDEF \\" + Environment.NewLine);
            textBoxResult.AppendText("" + ProcessNode(tbdef, RootNode) + " \\" + Environment.NewLine);
            m_NodeCounterForID = 0; // fixme rename
            tNodeTagInfo nt;

            nt           = (tNodeTagInfo)RootNode.Tag;
            nt.ID        = m_NodeCounterForID++;
            RootNode.Tag = nt;
            processTextDefinitions(RootNode);
            textBoxResult.AppendText(Environment.NewLine);
            textBoxResult.AppendText("#endif" + Environment.NewLine);


            // Parameter list
            textBoxResult.AppendText(Environment.NewLine);
            textBoxResult.AppendText("// Parameter definitions" + Environment.NewLine);
            textBoxResult.AppendText("#ifndef MENUE_PARAM_VARDEF" + Environment.NewLine);
            textBoxResult.AppendText("#define MENUE_PARAM_VARDEF \\" + Environment.NewLine);
            textBoxResult.AppendText(textBoxParStructName.Text + "_t " + textBoxParStructName.Text + " = { \\" + Environment.NewLine);
            ProcessParameters(treeView1.Nodes[0]);
            //textBoxResult.AppendText("/*CRC*/\t0 \\" + Environment.NewLine);
            textBoxResult.AppendText("};" + Environment.NewLine);
            textBoxResult.AppendText("#endif" + Environment.NewLine);
            textBoxResult.AppendText(Environment.NewLine);


            // Process the MENUE LIST
            textBoxResult.AppendText("\t\t\t//Name\tAct\tPar\tJmp\tParent\tMemory" + Environment.NewLine);
            textBoxResult.AppendText("#ifndef MENUE_MENUE_VARDEF" + Environment.NewLine);
            textBoxResult.AppendText("#define MENUE_MENUE_VARDEF \\" + Environment.NewLine);
            textBoxResult.AppendText("MenuItem_t m_items[MENUESIZE] = { \\" + Environment.NewLine);
            textBoxResult.AppendText("\t" + ProcessNode(tbmen, RootNode) + " \\" + Environment.NewLine);
            processMenuList(RootNode);
            textBoxResult.AppendText("};" + Environment.NewLine);
            textBoxResult.AppendText("#endif" + Environment.NewLine);
            textBoxResult.AppendText(Environment.NewLine);

            textBoxResult.AppendText("//******** END OF AUTO-GENERATED HEADER DO NOT EDIT!!! *********" + Environment.NewLine + Environment.NewLine);


            textBoxResult2.AppendText("//******** INSERT INTO C FILE *********" + Environment.NewLine);
            textBoxResult2.AppendText("// Text definitions" + Environment.NewLine);
            textBoxResult2.AppendText("\tMENUE_TEXT_VARDEF" + Environment.NewLine);
            textBoxResult2.AppendText("// Parameter definitions" + Environment.NewLine);
            textBoxResult2.AppendText("\tMENUE_PARAM_VARDEF" + Environment.NewLine);
            textBoxResult2.AppendText("// Menue definitions" + Environment.NewLine);
            textBoxResult2.AppendText("\tMENUE_MENUE_VARDEF" + Environment.NewLine);
            textBoxResult2.AppendText(Environment.NewLine + "//******** INSERT INTO C FILE *********" + Environment.NewLine);


            processDescriptionText(RootNode);

            GetSubNodeUID(RootNode);
            labelGUID.Text = m_Generateduuid.ToString("00000");
        }
Exemplo n.º 25
0
 public static string ToString(UInt16 value)
 {
     return(value.ToString("D", CultureInfo.InvariantCulture.NumberFormat));
 }
Exemplo n.º 26
0
 public override string ToString()
 {
     return(Major.ToString() + "." + Minor.ToString() + "." + Patch.ToString());
 }
Exemplo n.º 27
0
        /// <summary>
        /// 根据VID和PID及设备安装类GUID定位即插即用设备实体
        /// </summary>
        /// <param name="VendorID">供应商标识,MinValue忽视</param>
        /// <param name="ProductID">产品编号,MinValue忽视</param>
        /// <param name="ClassGuid">设备安装类Guid,Empty忽视</param>
        /// <returns>设备列表</returns>
        /// <remarks>
        /// HID:{745a17a0-74d3-11d0-b6fe-00a0c90f57da}
        /// Imaging Device:{6bdd1fc6-810f-11d0-bec7-08002be2092f}
        /// Keyboard:{4d36e96b-e325-11ce-bfc1-08002be10318}
        /// Mouse:{4d36e96f-e325-11ce-bfc1-08002be10318}
        /// Network Adapter:{4d36e972-e325-11ce-bfc1-08002be10318}
        /// USB:{36fc9e60-c465-11cf-8056-444553540000}
        /// </remarks>
        public static PnPEntityInfo[] WhoPnPEntity(UInt16 VendorID, UInt16 ProductID, Guid ClassGuid)
        {
            List <PnPEntityInfo> PnPEntities = new List <PnPEntityInfo>();

            // 枚举即插即用设备实体
            String VIDPID;

            if (VendorID == UInt16.MinValue)
            {
                if (ProductID == UInt16.MinValue)
                {
                    VIDPID = "'%VID[_]____&PID[_]____%'";
                }
                else
                {
                    VIDPID = "'%VID[_]____&PID[_]" + ProductID.ToString("X4") + "%'";
                }
            }
            else
            {
                if (ProductID == UInt16.MinValue)
                {
                    VIDPID = "'%VID[_]" + VendorID.ToString("X4") + "&PID[_]____%'";
                }
                else
                {
                    VIDPID = "'%VID[_]" + VendorID.ToString("X4") + "&PID[_]" + ProductID.ToString("X4") + "%'";
                }
            }

            String QueryString;

            if (ClassGuid == Guid.Empty)
            {
                QueryString = "SELECT * FROM Win32_PnPEntity WHERE PNPDeviceID LIKE" + VIDPID;
            }
            else
            {
                QueryString = "SELECT * FROM Win32_PnPEntity WHERE PNPDeviceID LIKE" + VIDPID + " AND ClassGuid='" + ClassGuid.ToString("B") + "'";
            }

            ManagementObjectCollection PnPEntityCollection = new ManagementObjectSearcher(QueryString).Get();

            if (PnPEntityCollection != null)
            {
                foreach (ManagementObject Entity in PnPEntityCollection)
                {
                    String PNPDeviceID = Entity["PNPDeviceID"] as String;
                    Match  match       = Regex.Match(PNPDeviceID, "VID_[0-9|A-F]{4}&PID_[0-9|A-F]{4}");
                    if (match.Success)
                    {
                        PnPEntityInfo Element;

                        Element.PNPDeviceID = PNPDeviceID;                                        // 设备ID
                        Element.Name        = Entity["Name"] as String;                           // 设备名称
                        Element.Description = Entity["Description"] as String;                    // 设备描述
                        Element.Service     = Entity["Service"] as String;                        // 服务
                        Element.Status      = Entity["Status"] as String;                         // 设备状态
                        Element.VendorID    = Convert.ToUInt16(match.Value.Substring(4, 4), 16);  // 供应商标识
                        Element.ProductID   = Convert.ToUInt16(match.Value.Substring(13, 4), 16); // 产品编号
                        Element.ClassGuid   = new Guid(Entity["ClassGuid"] as String);            // 设备安装类GUID

                        PnPEntities.Add(Element);
                    }
                }
            }

            if (PnPEntities.Count == 0)
            {
                return(null);
            }
            else
            {
                return(PnPEntities.ToArray());
            }
        }
Exemplo n.º 28
0
 public GString(UInt16 nbr)
 {
     this._str = nbr.ToString();
 }
Exemplo n.º 29
0
 /// <summary> Adds a command argument. </summary>
 /// <param name="argument"> The argument. </param>
 public void AddArgument(UInt16 argument)
 {
     _arguments.Add(argument.ToString(CultureInfo.InvariantCulture));
 }
Exemplo n.º 30
0
        public void processObjectInteraction(StaticWorldObject staticWorldObject, GameObjectItem item)
        {
            WorldSocket.gameServerEntities.Add(staticWorldObject);
            UInt16 typeId = NumericalUtils.ByteArrayToUint16(staticWorldObject.type, 1);

            Store.currentClient.playerData.newViewIdCounter++; // It is just for a test Later we will change this to have a List with Views and Object IDs

            NumericalUtils.uint16ToByteArrayShort(Store.currentClient.playerData.assignSpawnIdCounter());
            ServerPackets packets = new ServerPackets();

            packets.sendSystemChatMessage(Store.currentClient, "Door ID " + staticWorldObject.mxoId + " Type ID " + typeId.ToString() + " POS X:" + staticWorldObject.pos_x.ToString() + " Y:" + staticWorldObject.pos_y.ToString() + " Z:" + staticWorldObject.pos_z.ToString() + typeId, "BROADCAST");


            switch (typeId)
            {
            case 343:
            case 346:
            case 359:
            case 365:
            case 414:
            case 415:
            case 416:
            case 576:
            case 6958:
            case 6965:
            case 6963:
            case 6964:
            case 6972:
                // ObjectAttribute364
                ObjectAttributes364 door364 = new ObjectAttributes364("DOOR364", typeId, staticWorldObject.mxoId);
                door364.DisableAllAttributes();
                door364.Orientation.enable();
                door364.Position.enable();
                door364.CurrentState.enable();
                // Set Values
                door364.Position.setValue(NumericalUtils.doublesToLtVector3d(staticWorldObject.pos_x, staticWorldObject.pos_y, staticWorldObject.pos_z));
                door364.CurrentState.setValue(StringUtils.hexStringToBytes("34080000"));
                door364.Orientation.setValue(StringUtils.hexStringToBytes(staticWorldObject.quat));
                //door364.Orientation.setValue(StringUtils.hexStringToBytes("000000000000803F0000000000000000")); // ToDo: Replace it with staticWorldObject.quat when it is okay

                // ToDo: We make a little Entity "Hack" so that we have a unique id : metrid + fullmxostatic_id is entity
                String entityMxOHackString = "" + staticWorldObject.metrId + "" + staticWorldObject.mxoId;
                UInt64 entityId            = UInt64.Parse(entityMxOHackString);

                packets.sendSpawnStaticObject(Store.currentClient, door364, entityId);

                break;

            case 6601:
            case 6994:
            case 341:
            case 417:
            case 419:

                ObjectAttributes363 door363 = new ObjectAttributes363("DOOR363", typeId, staticWorldObject.mxoId);
                door363.DisableAllAttributes();
                door363.Orientation.enable();
                door363.Position.enable();
                door363.CurrentState.enable();
                // Set Values
                door363.Position.setValue(NumericalUtils.doublesToLtVector3d(staticWorldObject.pos_x, staticWorldObject.pos_y, staticWorldObject.pos_z));
                door363.Orientation.setValue(StringUtils.hexStringToBytes(staticWorldObject.quat));
                //door363.Orientation.setValue(StringUtils.hexStringToBytes("000000000000803F0000000000000000")); // ToDo: Replace it with staticWorldObject.quat when it is okay
                door363.CurrentState.setValue(StringUtils.hexStringToBytes("34080000"));

                // ToDo: We make a little Entity "Hack" so that we have a unique id : metrid + fullmxostatic_id is entity
                String entity363MxOHackString = "" + staticWorldObject.metrId + "" + staticWorldObject.mxoId;
                UInt64 entity363Id            = UInt64.Parse(entity363MxOHackString);

                packets.sendSpawnStaticObject(Store.currentClient, door363, entity363Id);
                break;

            case 592:
                new TeleportHandler().processHardlineExitRequest();
                break;

            default:
                new ServerPackets().sendSystemChatMessage(Store.currentClient, "Unknown Object Interaction with Object Type " + staticWorldObject.type + " and Name " + item.getName(), "MODAL");
                break;
            }
        }
Exemplo n.º 31
0
        private static void VerifyUInt16ImplicitCastToBigInteger(UInt16 value)
        {
            BigInteger bigInteger = value;

            Assert.Equal(value, bigInteger);
            Assert.Equal(value.ToString(), bigInteger.ToString());
            Assert.Equal(value, (UInt16)bigInteger);

            if (value != UInt16.MaxValue)
            {
                Assert.Equal((UInt16)(value + 1), (UInt16)(bigInteger + 1));
            }

            if (value != UInt16.MinValue)
            {
                Assert.Equal((UInt16)(value - 1), (UInt16)(bigInteger - 1));
            }

            VerifyBigIntegerUsingIdentities(bigInteger, 0 == value);
        }
Exemplo n.º 32
0
 public static string ToString(UInt16 value)
 {
     return(value.ToString(CultureInfo.InvariantCulture));
 }
Exemplo n.º 33
0
 public static string ToString(UInt16 value)
 {
     return value.ToString();
 }
Exemplo n.º 34
0
 private static string AllPrimitivesMethod(
     bool boolean,
     string str,
     char character,
     byte unsignedbyte,
     sbyte signedbyte,
     Int16 int16,
     UInt16 uint16,
     Int32 int32,
     UInt32 uint32,
     Int64 int64,
     UInt64 uint64,
     Single single,
     Double dbl)
 {
     StringBuilder builder = new StringBuilder();
     builder.Append(boolean.ToString() + ", ");
     builder.Append(str + ", ");
     builder.Append(character.ToString() + ", ");
     builder.Append(unsignedbyte.ToString() + ", ");
     builder.Append(signedbyte.ToString() + ", ");
     builder.Append(int16.ToString() + ", ");
     builder.Append(uint16.ToString() + ", ");
     builder.Append(int32.ToString() + ", ");
     builder.Append(uint32.ToString() + ", ");
     builder.Append(int64.ToString() + ", ");
     builder.Append(uint64.ToString() + ", ");
     builder.Append(single.ToString() + ", ");
     builder.Append(dbl);
     return builder.ToString();
 }