コード例 #1
1
ファイル: OnException.cs プロジェクト: vlaci/Anotar
 public object WithRefsWithReturn(
     ref string param1,
     ref int param2,
     ref short param3,
     ref long param4,
     ref uint param5,
     ref ushort param6,
     ref ulong param7,
     ref bool param8,
     ref double param9,
     ref decimal param10,
     ref int? param11,
     ref object param12,
     ref char param13,
     ref DateTime param14,
     ref Single param15,
     ref IntPtr param16,
     ref UInt16 param17,
     ref UInt32 param18,
     ref UInt64 param19,
     ref UIntPtr param20
     )
 {
     throw new Exception("Foo");
 }
コード例 #2
0
ファイル: Person.cs プロジェクト: VelocityDB/VelocityDB
 public Person(string firstName, string lastName, UInt16 age, Person bestFriend = null)
 {
   this.firstName = firstName;
   this.lastName = lastName;
   this.age = age;
   this.bestFriend = bestFriend;
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: RainsSoft/kcp-csharp
    static void test_v2(string host, UInt16 port)
    {
        var wait_response = true;

        KcpProject.v2.UdpSocket client = null;

        // 创建一个实例
        client = new KcpProject.v2.UdpSocket((byte[] buf) =>
        {
            wait_response = false;
            Console.WriteLine("recv message: {0}", System.Text.ASCIIEncoding.ASCII.GetString(buf));
        });

        // 绑定端口
        client.Connect(host, port);

        // 发送消息
        client.Send("Hello KCP.");

        // update.
        while (wait_response)
        {
            client.Update();
            System.Threading.Thread.Sleep(10);
        }
    }
コード例 #4
0
ファイル: Converter.cs プロジェクト: xclouder/godbattle
 public static UInt16 GetBigEndian(UInt16 value) {
     if (BitConverter.IsLittleEndian) {
         return swapByteOrder(value);
     } else {
         return value;
     }
 }
コード例 #5
0
ファイル: uint16tostring4.cs プロジェクト: CheneyWu/coreclr
    public bool DoPosTest(string testDesc, string id, UInt16 uintA, string format, String expectedValue, NumberFormatInfo _NFI)
    {
        bool retVal = true;
        string errorDesc;

        string actualValue;

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

            if (actualValue != expectedValue)
            {
                errorDesc =
                    string.Format("The string representation of {0} is not the value {1} as expected: actual({2})",
                    uintA, expectedValue, actualValue);
                errorDesc += "\nThe format info is \"" + ((format == null) ? "null" : format) + "\" speicifed";
                TestLibrary.TestFramework.LogError(id + "_001", errorDesc);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            errorDesc = "Unexpect exception:" + e;
            errorDesc += "\nThe UInt16 integer is " + uintA + ", format info is \"" + format + "\" speicifed.";
            TestLibrary.TestFramework.LogError(id + "_002", errorDesc);
            retVal = false;
        }
        return retVal;
    }
コード例 #6
0
ファイル: PixelDataRgb48.cs プロジェクト: hungdluit/aforge
 /// <summary>
 /// See <see cref="INonIndexedPixel.SetColor"/> for more details.
 /// </summary>
 public void SetColor(Color color)
 {
     color = QuantizationHelper.ConvertAlpha(color);
     red = (UInt16) (color.R << 5);
     green = (UInt16) (color.G << 5);
     blue = (UInt16) (color.B << 5);
 }
コード例 #7
0
 public byte ReadRegister(UInt16 adr)
 {
     switch (adr)
     {
         case 0x00:
             return (byte)((pra | ~ddra) & 0x3f | IECLines & the_cpu_1541.IECLines);
         case 0x01: return (byte)(prb | ~ddrb);
         case 0x02: return ddra;
         case 0x03: return ddrb;
         case 0x04: return (byte)ta;
         case 0x05: return (byte)(ta >> 8);
         case 0x06: return (byte)tb;
         case 0x07: return (byte)(tb >> 8);
         case 0x08: tod_halt = false; return tod_10ths;
         case 0x09: return tod_sec;
         case 0x0a: return tod_min;
         case 0x0b: tod_halt = true; return tod_hr;
         case 0x0c: return sdr;
         case 0x0d:
             {
                 byte ret = icr; // Read and clear ICR
                 icr = 0;
                 the_cpu.ClearNMI();
                 return ret;
             }
         case 0x0e: return cra;
         case 0x0f: return crb;
     }
     return 0;	// Can't happen
 }
コード例 #8
0
 public void ResetArray(System.UInt16 val = 0)
 {
     for (int i = 0; i < _array.Length; ++i)
     {
         _array[i] = val;
     }
 }
コード例 #9
0
			public IndexBuffer(IDataStream stream, ulong vcn, FolderNTFS folder) {
				_folder = folder;
				_clusterStart = vcn * (ulong)(_folder._record.SectorsPerCluster * _folder._record.BytesPerSector);
				String magic = Util.GetASCIIString(stream, _clusterStart + 0x0, 4);

				if (!magic.Equals("INDX")) {
					throw new Exception("Magic INDX value not present");
				}

				_entriesStart = (ushort)(Util.GetUInt16(stream, _clusterStart + 0x18) + 0x18);
				_entriesEnd = (ushort)(Util.GetUInt16(stream, _clusterStart + 0x1c) + _entriesStart);

				ushort updateSequenceOffset = Util.GetUInt16(stream, _clusterStart + 0x04);
				ushort updateSequenceLength = Util.GetUInt16(stream, _clusterStart + 0x06);

				ushort updateSequenceNumber = Util.GetUInt16(stream, _clusterStart + updateSequenceOffset);
				ushort[] updateSequenceArray = new ushort[updateSequenceLength - 1];
				ushort read = 1;
				while (read < updateSequenceLength) {
					updateSequenceArray[read - 1] = Util.GetUInt16(stream, _clusterStart + updateSequenceOffset + (ushort)(read * 2));
					read++;
				}

				_stream = new FixupStream(stream, _clusterStart, _entriesEnd, updateSequenceNumber, updateSequenceArray, (ulong)folder.BytesPerSector);

				if (_entriesEnd == _entriesStart) {
					throw new Exception("Entry size was 0");
				}
			}
コード例 #10
0
ファイル: Monitor.cs プロジェクト: Cilph/ProgCom
        public Monitor(Int32[] arr, UInt16 ptr, UInt16 chars, UInt16 colPtr, UInt16 modePointer)
        {
            mem = arr;
            pointer = ptr;
            charSetPtr = chars;
            colors = new Color[16];
            modePtr = modePointer;
            for (int i = 0; i < 16; ++i) {
                colors[i] = new Color();
                colors[i].a = 1.0f;
            }
            colorPointer = colPtr;

            image = new Texture2D(256, 256, TextureFormat.ARGB32, false);
            windowPos = new Rect();
            if ((windowPos.x == 0) && (windowPos.y == 0))//windowPos is used to position the GUI window, lets set it in the center of the screen
            {
                windowPos = new Rect(Screen.width / 2, Screen.height / 2, 100, 100);
            }
            //Set all the pixels to black. If you don't do this the image contains random junk.
            for (int y = 0; y < image.height; y++) {
                for (int x = 0; x < image.width; x++) {
                    image.SetPixel(x, y, Color.black);
                }
            }
            image.Apply();
        }
コード例 #11
0
ファイル: SeekThermal.cs プロジェクト: apextw/winusbdotnet
        public CalibratedThermalFrame ProcessFrame(ThermalFrame calibrationFrame)
        {
            UInt16[] output = new UInt16[Width * Height];

            for(int i=0;i<output.Length;i++)
            {
                int v = BitConverter.ToUInt16(RawData, i * 2);
                int c = BitConverter.ToUInt16(calibrationFrame.RawData, i * 2);

                if (v < 0x800)
                {
                    // Dead pixel, clamp it to zero.
                    v = 0;
                }
                else
                {
                    v = v - c + 0x8000;
                    if (v < 0) v = 0;
                    if (v > 0xFFFF) v = 0xFFFF;
                }
                output[i] = (UInt16)v;
           
            }
            return new CalibratedThermalFrame(output);
        }
コード例 #12
0
		public GroupFoundEventArgs (Byte connection, UInt16 start, UInt16 end, Byte[] uuid)
		{
			this.connection = connection;
			this.start = start;
			this.end = end;
			this.uuid = uuid;
		}
コード例 #13
0
    void Update()
    {
        if (connected)
        {
            // When connected to Arduino
            if (_txUINT8 != (UINT8)txUINT8)
            {
                _txUINT8 = (UINT8)txUINT8;
                SetDirty();                 // It must call to run OnPush
            }
            if (_txINT8 != (INT8)txINT8)
            {
                _txINT8 = (INT8)txINT8;
                SetDirty();                 // It must call to run OnPush
            }
            if (_txUINT16 != (UINT16)txUINT16)
            {
                _txUINT16 = (UINT16)txUINT16;
                SetDirty();                 // It must call to run OnPush
            }
            if (_txINT16 != (INT16)txINT16)
            {
                _txINT16 = (INT16)txINT16;
                SetDirty();                 // It must call to run OnPush
            }
            if (_txUINT32 != (UINT32)txUINT32)
            {
                _txUINT32 = (UINT32)txUINT32;
                SetDirty();                 // It must call to run OnPush
            }
            if (_txINT32 != (INT32)txINT32)
            {
                _txINT32 = (INT32)txINT32;
                SetDirty();                 // It must call to run OnPush
            }
            if (_txFLOAT32 != (FLOAT32)txFLOAT32)
            {
                _txFLOAT32 = (FLOAT32)txFLOAT32;
                SetDirty();                 // It must call to run OnPush
            }
            if (txSTRING.Equals(_txSTRING) == false)
            {
                _txSTRING = (STRING)txSTRING;
                SetDirty();                 // It must call to run OnPush
            }

            rxUINT8   = _rxUINT8;
            rxINT8    = _rxINT8;
            rxUINT16  = _rxUINT16;
            rxINT16   = _rxINT16;
            rxUINT32  = _rxUINT32;
            rxINT32   = _rxINT32;
            rxFLOAT32 = _rxFLOAT32;
            rxSTRING  = _rxSTRING;
        }
        else
        {
            // When disconnected to Arduino
        }
    }
コード例 #14
0
ファイル: GraphDSExtensionsWebDAV.cs プロジェクト: Vadi/sones
        /// <summary>
        /// Start the WebDAV interface using the given ip address, port and HTTPSecurity parameters.
        /// </summary>
        /// <param name="myIPAddress">The IPAddress for binding the interface at</param>
        /// <param name="myPort">The port for binding the interface at</param>
        /// <param name="myHttpWebSecurity">A HTTPSecurity class for checking security parameters like user credentials</param>
        public static Exceptional<HTTPServer<GraphDSWebDAV_Service>> StartWebDAV(this AGraphDSSharp myAGraphDSSharp, IPAddress myIPAddress, UInt16 myPort, HTTPSecurity myHttpWebSecurity = null)
        {
            try
            {
                // Initialize WebDAV service
                var _HttpWebServer = new HTTPServer<GraphDSWebDAV_Service>(
                    myIPAddress,
                    myPort,
                    new GraphDSWebDAV_Service(myAGraphDSSharp),
                    myAutoStart: true)
                {
                    HTTPSecurity = myHttpWebSecurity,
                };

                // Register the WebDAV service within the list of services
                // to stop before shutting down the GraphDSSharp instance
                myAGraphDSSharp.ShutdownEvent += new GraphDSSharp.ShutdownEventHandler((o, e) =>
                {
                    _HttpWebServer.StopAndWait();
                });

                return new Exceptional<HTTPServer<GraphDSWebDAV_Service>>(_HttpWebServer);

            }
            catch (Exception e)
            {
                return new Exceptional<HTTPServer<GraphDSWebDAV_Service>>(new GeneralError(e.Message, new System.Diagnostics.StackTrace(e)));
            }
        }
コード例 #15
0
ファイル: NotifyEvent.cs プロジェクト: xornand/bond
        private static void DoNotify(NotifyEventProxy<EpoxyConnection> proxy, int requestNum, string payload, UInt16 delay)
        {
            var request = new PingRequest { Payload = payload, DelayMilliseconds = delay };
            proxy.NotifyAsync(request);

            Console.WriteLine($"P Event #{requestNum} Delay: {delay}");
        }
コード例 #16
0
ファイル: Device.cs プロジェクト: Cliveburr/AutoHome
        public bool SendMessage(UInt16 ip, byte code, string body = null)
        {
            if (!IsConnected())
                return false;

            var hasBody = !string.IsNullOrEmpty(body);

            var msg = new byte[hasBody ? 5 + body.Length : 3];

            var ipbs = BitConverter.GetBytes(ip);
            msg[0] = ipbs[0];
            msg[1] = ipbs[1];

            if (hasBody)
                code |= 1 << 7;
            msg[2] = (byte)code;

            if (hasBody)
            {
                var lbodybs = BitConverter.GetBytes(body.Length);
                msg[3] = lbodybs[0];
                msg[4] = lbodybs[1];

                var bodybs = System.Text.Encoding.ASCII.GetBytes(body);

                Array.Copy(bodybs, 0, msg, 5, body.Length);
            }

            return _device.Write(msg) > 0;
        }
コード例 #17
0
        public TelemetryPacket(String telemetry)
        {
            isPayload = checkIfFromPayload(telemetry); // This should be done first before conversions

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

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

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

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

            packetString = String.Join(",",packetArray);
        }
コード例 #18
0
    public void ResizeArrayTo(int size)
    {
        if (size == _array.Length)
        {
            return;
        }

        System.UInt16[] newArray = new System.UInt16[size];

        if (size < _array.Length)
        {
            for (int i = 0; i < size; ++i)
            {
                newArray[i] = _array[i];
            }
        }
        else
        {
            for (int i = 0; i < _array.Length; ++i)
            {
                newArray[i] = _array[i];
            }

            for (int i = _array.Length; i < size; ++i)
            {
                newArray[i] = 0;
            }
        }

        _array = newArray;
    }
コード例 #19
0
ファイル: MeshSerializer.cs プロジェクト: lcbasu/Unity
    public static void ReadVector2Array16bit(Vector2[] arr, BinaryReader buf)
    {
        int n = arr.Length;

        if (n == 0)
        {
            return;
        }

        // Read bounding box
        Vector2 bmin;
        Vector2 bmax;

        bmin.x = buf.ReadSingle();
        bmax.x = buf.ReadSingle();
        bmin.y = buf.ReadSingle();
        bmax.y = buf.ReadSingle();

        // Decode vectors as 16 bit integer components between the bounds
        for (int i = 0; i < n; ++i)
        {
            System.UInt16 ix = buf.ReadUInt16();
            System.UInt16 iy = buf.ReadUInt16();
            float         xx = ix / 65535.0f * (bmax.x - bmin.x) + bmin.x;
            float         yy = iy / 65535.0f * (bmax.y - bmin.y) + bmin.y;
            arr[i] = new Vector2(xx, yy);
        }
    }
コード例 #20
0
ファイル: TextWorker.cs プロジェクト: vsnicarevs/peninsula
        /// <summary>  
        /// 图像信息读入(+2重载)
        /// </summary>  
        /// <param name="_fileName">文件名</param>  
        /// <param name="_width">图像的宽</param>  
        /// <param name="_height">图像的高</param> 
        /// <param name="_useless">无用字符消除</param>
        /// <param name="_front">首行缩进</param>  
        /// <param name="_behind">尾行缩进</param>  
        /// <param name="_needDecode">需要解码</param>
        /// <returns>得到的byte数组</returns>   
        public static byte[] Readin(String _fileName, UInt16 _width, UInt16 _height, UInt16 _useless, UInt16 _front, UInt16 _behind, Boolean _needDecode)
        {
            try
            {
                // Create an instance of StreamReader to read from a file.
                // The using statement also closes the StreamReader.
                using (StreamReader sr = new StreamReader(_fileName))
                {
                    String line, info = "";
                    // Read and display lines from the file until the end of
                    // the file is reached.
                    while ((line = sr.ReadLine()) != null)
                    {
                        if (_useless != 0)
                        {
                            _useless--;
                        }
                        else
                        {
                            info += UsefulReadout(line, _front, _behind) + " ";
                        }

                    }
                    return ConvertInfo(info, _width, _height, _needDecode);
                }
            }
            catch (Exception e)
            {
                // Let the user know what went wrong.
                MessageSender.e = e;
                return new byte[1];
            }
        }
コード例 #21
0
ファイル: wnd1.cs プロジェクト: Ermelber/EveryFileExplorer
 public wnd1(EndianBinaryReader er)
     : base(er)
 {
     long basepos = er.BaseStream.Position - 0x4C;
     InflationLeft = er.ReadUInt16() / 16f;
     InflationRight = er.ReadUInt16() / 16f;
     InflationTop = er.ReadUInt16() / 16f;
     InflationBottom = er.ReadUInt16() / 16f;
     FrameSizeLeft = er.ReadUInt16();
     FrameSizeRight = er.ReadUInt16();
     FrameSizeTop = er.ReadUInt16();
     FrameSizeBottom = er.ReadUInt16();
     NrFrames = er.ReadByte();
     byte tmp = er.ReadByte();
     UseLTMaterial = (tmp & 1) == 1;
     UseVtxColorForAllWindow = (tmp & 2) == 2;
     Kind = (WindowKind)((tmp >> 2) & 3);
     DontDrawContent = (tmp & 8) == 16;
     Padding = er.ReadUInt16();
     ContentOffset = er.ReadUInt32();
     FrameOffsetTableOffset = er.ReadUInt32();
     er.BaseStream.Position = basepos + ContentOffset;
     Content = new WindowContent(er);
     er.BaseStream.Position = basepos + FrameOffsetTableOffset;
     WindowFrameOffsets = er.ReadUInt32s(NrFrames);
     WindowFrames = new WindowFrame[NrFrames];
     for (int i = 0; i < NrFrames; i++)
     {
         er.BaseStream.Position = basepos + WindowFrameOffsets[i];
         WindowFrames[i] = new WindowFrame(er);
     }
     er.BaseStream.Position = basepos + SectionSize;
 }
コード例 #22
0
ファイル: co8549uint16.cs プロジェクト: ArildF/masters
	private void WorkOnInstanceAndLocal()
	{
		int localInt, i, j;
                for ( i = 0; i < 100; i++ )
                {
                   int index = randomNumGen.Next(0, ValueArraySize); 
		   instanceInt_1 = ValueArray[index];
                   Thread.Sleep(index);  
                   localInt = instanceInt_1; 
                   for ( j = 0; j < ValueArraySize; j++ )
                     if ( ValueArray[j] == localInt )
                          break;
                   if (j == ValueArraySize )
                     throw new Exception("WorkOnInstanceAndLocal: Atomicity of Read/Write violated - " + localInt);
                }	
		UInt16 localInt_1;
		localInt_1 = 1 + 1;
		if(localInt_1 != 2)
			throw new Exception("Loc_7453fg! Major Error here");
		localInt_1 = UInt16.MaxValue + UInt16.MinValue;
		if(localInt_1 != UInt16.MaxValue)
			throw new Exception("Loc_98745sg! Major Error here");
		localInt_1 = Int16.MaxValue * 2;
		if(localInt_1 != 65534)
			throw new Exception("Loc_3975sg! Major Error here, " + localInt_1);
		localInt_1 = UInt16.Parse("32");
		if(localInt_1 != 32)
			throw new Exception("Loc_975esg! Major Error here, " + localInt_1);
		localInt_1 = UInt16.MaxValue;
		if(localInt_1.GetHashCode() != 65535)
			throw new Exception("Loc_874325dg! Major Error here, " + localInt_1.GetHashCode());
		if(localInt_1.ToString() != "65535")
			throw new Exception("Loc_8754s! Major Error here, " + localInt_1.ToString());
	}
コード例 #23
0
ファイル: EXTSST.cs プロジェクト: arthurzam/peulot-heshbon
 public void decode()
 {
     MemoryStream stream = new MemoryStream(Data);
     BinaryReader reader = new BinaryReader(stream);
     this.NumStrings = reader.ReadUInt16();
     ReadStringOffset(reader);
 }
コード例 #24
0
 public override int HandleInterrupt()
 {
     switch (AttachedCPU.A) {
         case 0:
             mBuffer.Clear();
             break;
         case 1:
             lock (mBuffer) {
                 if (mBuffer.Count != 0)
                     AttachedCPU.C = mBuffer.Dequeue();
                 else
                     AttachedCPU.C = 0;
             }
             break;
         case 2:
             lock (mActiveKeys) {
                 if (mActiveKeys.Contains(AttachedCPU.B))
                     AttachedCPU.C = 1;
                 else
                     AttachedCPU.C = 0;
                 break;
             }
         case 3:
             mMessage = AttachedCPU.B;
             break;
     }
     return 0;
 }
コード例 #25
0
ファイル: CRCManager.cs プロジェクト: liroyma/SpeedDetector
        public static byte[] CheckCRC(List<byte> listdata)
        {
            byte[] data = ASCIItoHEX(listdata);

            UInt16[] testPtr = new UInt16[data.Length];

            for (int i = 0; i < data.Length; i++)
            {
                testPtr[i] = (UInt16)data[i];
            }

            UInt16 index;
            UInt16 crc = 0xFFFF;

            for (int i = 0; i < testPtr.Length; i++)
            {
                index = (UInt16)((crc ^ testPtr[i]) & 0x00FF);
                crc = (UInt16)(((crc >> 8) & 0x00FF) ^ CRC_TABLE[index]);
            }

            if (testPtr.Length != 0)
            {
                crc = (UInt16)(((crc & 0x00FF) << 8) | ((crc & 0xFF00) >> 8));
            }

            if (crc != 0)
                return null;
            else
                return data.Take(data.Length - 2).ToArray();
        }
コード例 #26
0
ファイル: Item.cs プロジェクト: dzikun/WarEmu
 public Item(Creature_item CItem)
 {
     _SlotId = CItem.SlotId;
     _ModelId = CItem.ModelId;
     _EffectId = CItem.EffectId;
     _Count = 1;
 }
コード例 #27
0
ファイル: ProgDat.cs プロジェクト: winterheart/game-utilities
 public OProg(byte[] data, byte[] footer, int id,int type)
 {
     this.type = type;
     this.data = data;
     this.footer = footer;
     this.id = id;
     return;
     u0=BinHelper.read_U16LE(footer, 0);
     exitsCnt=BinHelper.read_U16LE(footer, 2);
     if (type == 1)
     {
         entry=exitsCnt;
         exitsCnt = 0;
         unpack();
         return;
     }
     actorsCnt=BinHelper.read_U16LE(footer, 4);
     u6=BinHelper.read_U16LE(footer, 6);
     exits=BinHelper.read_U16LE(footer, 8);
     actors=BinHelper.read_U16LE(footer, 0x0A);
     sprites=BinHelper.read_U16LE(footer, 0x0C);
     entry=BinHelper.read_U16LE(footer, 0x0E);
     if (u0 != 0 || u6 != exits)
         throw new Exception("Unknown prog values");
     unpack();
 }
コード例 #28
0
ファイル: CRCManager.cs プロジェクト: liroyma/SpeedDetector
        public static byte[] AddCRC(byte[] data)
        {
            UInt16[] testPtr = new UInt16[data.Length];

            for (int i = 0; i < testPtr.Length; i++)
            {
                testPtr[i] = (UInt16)data[i];
            }

            UInt16 index;
            UInt16 crc = 0xffff;

            for (int i = 0; i < testPtr.Length; i++)
            {
                index = (UInt16)((crc ^ testPtr[i]) & 0x00ff);
                crc = (UInt16)(((crc >> 8) & 0x00ff) ^ CRC_TABLE[index]);
            }

            if (testPtr.Length != 0)
            {
                crc = (UInt16)(((crc & 0x00ff) << 8) | ((crc & 0xff00) >> 8));
            }

            byte[] tmp = new byte[2];
            tmp[0] = (byte)(((crc) >> 8) & 0x00ff);
            tmp[1] = (byte)((crc) & 0x00ff);

            List<byte> newdata = new List<byte>();
            newdata.AddRange(data);
            newdata.AddRange(tmp);

            return HEXtoASCII(newdata.ToArray());
        }
コード例 #29
0
    public static System.UInt16 UInt16Parse(string value)
    {
        System.UInt16 number = 0;
        bool          result = System.UInt16.TryParse(value, out number);

        return((true == result)?number:(System.UInt16) 0);
    }
コード例 #30
0
 public override byte[] GetBuffer()
 {
     crc = 0x0;
     byte[] buffer = base.GetBuffer();
     crc = CRC(buffer);
     return base.GetBuffer();
 }
コード例 #31
0
 public SFSDirectory(UInt16 Id)
 {
     DirectoryID = Id;
     IsRoot = false;
     SubDirectories = new List<SFSDirectory>();
     Files = new List<SFSFile>();
 }
コード例 #32
0
 public SensorInfo(RiftSharp.Win32Usb.HidCaps caps, UInt16 vendor, UInt16 product, string serial)
 {
     this.Capabilities = caps;
     this.VendorId = vendor;
     this.ProductId = product;
     this.SerialNumber = serial;
 }
コード例 #33
0
ファイル: Pr3.cs プロジェクト: Viktoriya611pst/Vika
 private void button1_Click(object sender, EventArgs e)
 {
     listBox2.Visible = false;
     label6.Visible = false;
     label7.Visible = false;
     textBox2.Visible = false;
     try
     {
         vec = UInt16.Parse(vk.Text);
     }
     catch (Exception)
     {
         button2.Visible = false;
         label5.Visible = false;
         listBox1.Visible = false;
         MessageBox.Show("Некорректная длина вектора", "ErrorLength", MessageBoxButtons.OK, MessageBoxIcon.Error);
         vk.Focus();
         return;
     }
     button2.Visible = true;
     label5.Visible = true;
     listBox1.Visible = true;
     forming(ref A, vec);
     write_Vector(A, listBox1);
     button2.Focus();
 }
コード例 #34
0
ファイル: Program.cs プロジェクト: hotab/ProgrammingOSLab2
 public static string GetMemoryType(UInt16 t)
 {
     switch (t)
     {
         case 1:
             return "Other";
         case 2:
             return "Unknown";
         case 3:
             return "VRAM";
         case 4:
             return "DRAM";
         case 5:
             return "SRAM";
         case 6:
             return "WRAM";
         case 7:
             return "EDO RAM";
         case 8:
             return "Burst Synchronous DRAM";
         case 9:
             return "Pipelined Burst SRAM";
         case 10:
             return "CDRAM";
         case 11:
             return "3DRAM";
         case 12:
             return "SDRAM";
         case 13:
             return "SGRAM";
     }
     return "Unknown";
 }
コード例 #35
0
        public NetworkAddressKey(ImmutableArray<byte> IPv6Address, UInt16 Port)
        {
            this.IPv6Address = IPv6Address;
            this.Port = Port;

            this._hashCode = Port.GetHashCode() ^ new BigInteger(IPv6Address.ToArray()).GetHashCode();
        }
コード例 #36
0
    private ClientOnLineItem GetClientOnLineItem(System.UInt16 u3dId)
    {
        ClientOnLineItem item = null;

        m_clientOnLineItemDict.TryGetValue(u3dId, out item);
        return(item);
    }
コード例 #37
0
ファイル: MeshSerializer.cs プロジェクト: lcbasu/Unity
    // Writes mesh to an array of bytes.
    public static byte[] WriteMesh(Mesh mesh, bool saveTangents)
    {
        if (!mesh)
        {
            print("No mesh given!");
            return(null);
        }

        Vector3[] verts    = mesh.vertices;
        Vector3[] normals  = mesh.normals;
        Vector4[] tangents = mesh.tangents;
        Vector2[] uvs      = mesh.uv;
        int[]     tris     = mesh.triangles;

        // figure out vertex format
        byte format = 1;

        if (normals.Length > 0)
        {
            format |= 2;
        }
        if (saveTangents && tangents.Length > 0)
        {
            format |= 4;
        }
        if (uvs.Length > 0)
        {
            format |= 8;
        }

        MemoryStream stream = new MemoryStream();
        BinaryWriter buf    = new BinaryWriter(stream);

        // write header
        System.UInt16 vertCount = System.Convert.ToUInt16(verts.Length);
        System.UInt16 triCount  = System.Convert.ToUInt16(tris.Length / 3);
        buf.Write(vertCount);
        buf.Write(triCount);
        buf.Write(format);
        // vertex components
        WriteVector3Array16bit(verts, buf);
        WriteVector3ArrayBytes(normals, buf);
        if (saveTangents)
        {
            WriteVector4ArrayBytes(tangents, buf);
        }
        WriteVector2Array16bit(uvs, buf);
        // triangle indices
        foreach (var idx in tris)
        {
            System.UInt16 idx16 = System.Convert.ToUInt16(idx);
            buf.Write(idx16);
        }
        buf.Close();

        return(stream.ToArray());
    }
コード例 #38
0
    private void RemoveClientOnLineItem(System.UInt16 u3dId)
    {
        ClientOnLineItem item = null;

        if (m_clientOnLineItemDict.TryGetValue(u3dId, out item) && item != null)
        {
            m_clientOnLineItemDict.Remove(u3dId);
        }
    }
コード例 #39
0
 public static string MKIN(this System.UInt16 value)
 {
     byte[] bytes = System.BitConverter.GetBytes(value);
     if ((System.BitConverter.IsLittleEndian))
     {
         System.Array.Reverse(bytes);
     }
     return(System.Text.Encoding.Default.GetString(bytes));
 }
コード例 #40
0
 private void AddClientOnLineItem(System.UInt16 u3dId, ClientOnLineItem item)
 {
     if (item == null)
     {
         return;
     }
     if (m_clientOnLineItemDict.ContainsKey(u3dId) == false)
     {
         m_clientOnLineItemDict.Add(u3dId, item);
     }
 }
コード例 #41
0
    public void onLoginFailed(System.UInt16 failedcode)
    {
//		if(failedcode == 20)
//		{
//			print("login is failed(登陆失败), err=" + KBEngineApp.app.serverErr(failedcode) + ", " + System.Text.Encoding.ASCII.GetString(KBEngineApp.app.serverdatas()));
//		}
//		else
//		{
//			print("login is failed(登陆失败), err=" + KBEngineApp.app.serverErr(failedcode));
//		}
    }
コード例 #42
0
 public void onLoginFailed(System.UInt16 failedcode)
 {
     ServerMediator.loginSucess = false;
     if (failedcode == 20)
     {
         err("login is failed(登陆失败), err=" + KBEngineApp.app.serverErr(failedcode) + ", " + System.Text.Encoding.ASCII.GetString(KBEngineApp.app.serverdatas()));
     }
     else
     {
         err("login is failed(登陆失败), err=" + KBEngineApp.app.serverErr(failedcode));
     }
 }
コード例 #43
0
    private void U3DClientOffLine_Callback(INotification notification)
    {
        System.UInt16    u3dId = (System.UInt16)notification.Body;
        ClientOnLineItem item  = GetClientOnLineItem(u3dId);

        if (item != null)
        {
            SingletonMgr.ObjectManager.ReleaseGameObjectItem(item.gameObject); //回收
            RemoveClientOnLineItem(u3dId);
        }
        m_onlineCountText.text     = ActorManager.Instance.GetActor <WorldActor>().OnLineCount.ToString();
        m_linkSocketCountText.text = ActorManager.Instance.GetActor <WorldActor>().LinkSocketCount.ToString();
    }
コード例 #44
0
ファイル: DetourNode.cs プロジェクト: jungrok5/CypherCore
        public dtNode findNode(dtPolyRef id)
        {
            uint        bucket = (uint)(dtHashRef(id) & (m_hashSize - 1));
            dtNodeIndex i      = m_first[bucket];

            while (i != DT_NULL_IDX)
            {
                if (m_nodes[i].id == id)
                {
                    return(m_nodes[i]);
                }
                i = m_next[i];
            }
            return(null);
        }
コード例 #45
0
    void MovePortals(Player p, int x, int y, int z)
    {
        List <Vec3U16> coords = Portal.GetAllCoords(p.level.MapName);

        int count = 0;

        foreach (Vec3U16 pos in coords)
        {
            if (!Portal.ExistsInDB(p.level.MapName))
            {
                continue;
            }
            PortalExit exit = Portal.Get(p.level.MapName, pos.X, pos.Y, pos.Z);

            BlockID block = p.level.FastGetBlock(pos.X, pos.Y, pos.Z);

            int x2 = pos.X + x;
            int y2 = pos.Y + y;
            int z2 = pos.Z + z;

            int dx = exit.X + x;
            int dy = exit.Y + y;
            int dz = exit.Z + z;

            if (!p.level.IsValidPos(x2, y2, z2))
            {
                p.Message("%cPortal at %b" + pos.X + " " + pos.Y + " " + pos.Z + " %cwas outside of the map bounds, deleting.");
                Portal.Delete(p.level.name, pos.X, pos.Y, pos.Z);
                p.level.UpdateBlock(p, pos.X, pos.Y, pos.Z, Block.Air);
                continue;
            }

            // Create new portals
            Portal.Set(p.level.name, (ushort)x2, (ushort)y2, (ushort)z2, (ushort)dx, (ushort)dy, (ushort)dz, exit.Map);
            p.level.UpdateBlock(p, (ushort)x2, (ushort)y2, (ushort)z2, block);

            // Delete old portals
            Portal.Delete(p.level.name, pos.X, pos.Y, pos.Z);
            p.level.UpdateBlock(p, pos.X, pos.Y, pos.Z, Block.Air);

            count++;
        }

        p.Message("%SSuccessfully moved %b" + count + " %Sportals.");
    }
コード例 #46
0
    public override void Save()
    {
        System.UInt16 num = 0;
        _data = "";

        for (int i = 0; i < _array.Length; ++i)
        {
            num = _array[i];
            if (_array[i] == 0)
            {
                num = System.UInt16.MaxValue;
            }

            _data += (System.Char)num;
        }

        base.Save();
    }
コード例 #47
0
    public string GetLocalizedText()
    {
        System.UInt16 identifier = GetUserDefaultUILanguage();

        switch (identifier)
        {
        case 0x409:
            return(english);

        case 0x804:
            return(chineseSimplified);

        case 0xc04:
        case 0x1404:
        case 0x404:
            return(chineseTraditional);

        case 0x40C:
            return(french);

        case 0x407:
            return(german);

        case 0x410:
            return(italian);

        case 0x411:
            return(japanese);

        case 0x412:
            return(korean);

        case 0x416:
        case 0x816:
            return(portuguese);

        case 0xC0A:
            return(spanish);

        default:
            return(english);
        }
    }
コード例 #48
0
    void MoveMessageBlocks(Player p, int x, int y, int z)
    {
        List <Vec3U16> coords = MessageBlock.GetAllCoords(p.level.MapName);

        int count = 0;

        foreach (Vec3U16 pos in coords)
        {
            string message = MessageBlock.Get(p.level.MapName, pos.X, pos.Y, pos.Z);

            if (message == null)
            {
                continue;
            }
            BlockID block = p.level.FastGetBlock(pos.X, pos.Y, pos.Z);

            int x2 = pos.X + x;
            int y2 = pos.Y + y;
            int z2 = pos.Z + z;

            if (!p.level.IsValidPos(x2, y2, z2))
            {
                p.Message("%cMB at %b" + pos.X + " " + pos.Y + " " + pos.Z + " %cwas outside of the map bounds, deleting.");
                MessageBlock.Delete(p.level.name, pos.X, pos.Y, pos.Z);
                p.level.UpdateBlock(p, pos.X, pos.Y, pos.Z, Block.Air);
                continue;
            }

            // Create new MBs
            MessageBlock.Set(p.level.name, (ushort)x2, (ushort)y2, (ushort)z2, message);
            p.level.UpdateBlock(p, (ushort)x2, (ushort)y2, (ushort)z2, block);

            // Delete old MBs
            MessageBlock.Delete(p.level.name, pos.X, pos.Y, pos.Z);
            p.level.UpdateBlock(p, pos.X, pos.Y, pos.Z, Block.Air);

            count++;
        }

        p.Message("%SSuccessfully moved %b" + count + " %SMBs.");
    }
コード例 #49
0
    public void onCreateAccountResult(System.UInt16 retcode, byte[] datas)
    {
        _loginController.progress = 0.1f;
        //注册失败,账号已经存在。
        if (retcode == 7)
        {
            //createAccount is error(注册账号错误)! err=SERVER_ERR_ACCOUNT_CREATE_FAILED [创建账号失败(已经存在一个相同的账号)。]
//			print("createAccount is error(注册账号错误)! err=" + KBEngineApp.app.serverErr(retcode));
        }

        if (retcode == 0)
        {
            UserInfo.GetSingleton().userName = userName;
            UserInfo.GetSingleton().userPwd  = userPwd;
            UserInfo.write2File();

            login(UserInfo.GetSingleton().userName, UserInfo.GetSingleton().userPwd);

//			print("createAccount is successfully!(注册账号成功!)");
        }
    }
コード例 #50
0
ファイル: MeshSerializer.cs プロジェクト: lcbasu/Unity
    public static void WriteVector3Array16bit(Vector3[] arr, BinaryWriter buf)
    {
        if (arr.Length == 0)
        {
            return;
        }

        // Calculate bounding box of the array
        Bounds bounds = new Bounds(arr[0], new Vector3(0.001f, 0.001f, 0.001f));

        foreach (var v in arr)
        {
            bounds.Encapsulate(v);
        }

        // Write bounds to stream
        Vector3 bmin = bounds.min;
        Vector3 bmax = bounds.max;

        buf.Write(bmin.x);
        buf.Write(bmax.x);
        buf.Write(bmin.y);
        buf.Write(bmax.y);
        buf.Write(bmin.z);
        buf.Write(bmax.z);

        // Encode vectors as 16 bit integer components between the bounds
        foreach (var v in arr)
        {
            float         xx = Mathf.Clamp((v.x - bmin.x) / (bmax.x - bmin.x) * 65535.0f, 0.0f, 65535.0f);
            float         yy = Mathf.Clamp((v.y - bmin.y) / (bmax.y - bmin.y) * 65535.0f, 0.0f, 65535.0f);
            float         zz = Mathf.Clamp((v.z - bmin.z) / (bmax.z - bmin.z) * 65535.0f, 0.0f, 65535.0f);
            System.UInt16 ix = System.Convert.ToUInt16(xx);
            System.UInt16 iy = System.Convert.ToUInt16(yy);
            System.UInt16 iz = System.Convert.ToUInt16(zz);
            buf.Write(ix);
            buf.Write(iy);
            buf.Write(iz);
        }
    }
コード例 #51
0
ファイル: DetourNode.cs プロジェクト: ywscr/Tools
        public dtNode getNode(dtPolyRef id, byte state = 0)
        {
            uint        bucket = (uint)(dtHashRef(id) & (m_hashSize - 1));
            dtNodeIndex i      = m_first[bucket];
            dtNode      node   = null;

            while (i != DT_NULL_IDX)
            {
                if (m_nodes[i].id == id && m_nodes[i].state == state)
                {
                    return(m_nodes[i]);
                }
                i = m_next[i];
            }

            if (m_nodeCount >= m_maxNodes)
            {
                return(null);
            }

            i = (dtNodeIndex)m_nodeCount;
            m_nodeCount++;

            // Init node
            node       = m_nodes[i];
            node.pidx  = 0;
            node.cost  = 0;
            node.total = 0;
            node.id    = id;
            node.state = state;
            node.flags = 0;

            m_next[i]       = m_first[bucket];
            m_first[bucket] = i;

            return(node);
        }
コード例 #52
0
ファイル: MeshSerializer.cs プロジェクト: lcbasu/Unity
    public static void WriteVector2Array16bit(Vector2[] arr, BinaryWriter buf)
    {
        if (arr.Length == 0)
        {
            return;
        }

        // Calculate bounding box of the array
        Vector2 bmin = arr[0] - new Vector2(0.001f, 0.001f);
        Vector2 bmax = arr[0] + new Vector2(0.001f, 0.001f);

        foreach (var v in arr)
        {
            bmin.x = Mathf.Min(bmin.x, v.x);
            bmin.y = Mathf.Min(bmin.y, v.y);
            bmax.x = Mathf.Max(bmax.x, v.x);
            bmax.y = Mathf.Max(bmax.y, v.y);
        }

        // Write bounds to stream
        buf.Write(bmin.x);
        buf.Write(bmax.x);
        buf.Write(bmin.y);
        buf.Write(bmax.y);

        // Encode vectors as 16 bit integer components between the bounds
        foreach (var v in arr)
        {
            float         xx = (v.x - bmin.x) / (bmax.x - bmin.x) * 65535.0f;
            float         yy = (v.y - bmin.y) / (bmax.y - bmin.y) * 65535.0f;
            System.UInt16 ix = System.Convert.ToUInt16(xx);
            System.UInt16 iy = System.Convert.ToUInt16(yy);
            buf.Write(ix);
            buf.Write(iy);
        }
    }
コード例 #53
0
ファイル: BlockPerms.cs プロジェクト: DireClanMC/MCGalaxy
 /// <summary> Find the permissions for the given block. </summary>
 public static BlockPerms Find(BlockID b)
 {
     return(List[b]);
 }
コード例 #54
0
 public void onLoginBaseappFailed(System.UInt16 failedcode)
 {
     err("loginBaseapp is failed(登陆网关失败), err=" + KBEngineApp.app.serverErr(failedcode));
 }
コード例 #55
0
 public void onKicked(System.UInt16 failedcode)
 {
     Debug.LogWarning("kick, disconnect!, reason=" + KBEngineApp.app.serverErr(failedcode));
 }
コード例 #56
0
 public void Deserialize(BitBuffer bitBuffer)
 {
     Tickrate = bitBuffer.ReadUShort();
 }
コード例 #57
0
        public void DrawBitmap(int16_t x, int16_t y, List <int> bitmap, int16_t w, int16_t h, uint16_t color)
        {
            int16_t i, j, byteWidth = (int16_t)((w + 7) / 8);

            for (j = 0; j < h; j++)
            {
                for (i = 0; i < w; i++)
                {
                    var bitmapValue = bitmap[j * byteWidth + i / 8];
                    var expected    = (128 >> (i & 7));
                    if ((bitmapValue & expected) == expected)
                    {
                        this.DrawPixel((int16_t)(x + i), (int16_t)(y + j), (uint16_t)color);
                    }
                }
            }
        }
コード例 #58
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="bitmapDefinedAsString">
 /// Accept bitmap defined as a list of byte defined like this "B11111111", "B10000001"
 /// </param>
 /// <param name="w"></param>
 /// <param name="h"></param>
 /// <param name="color"></param>
 public void DrawBitmap(int16_t x, int16_t y, List <string> bitmapDefinedAsString, int16_t w, int16_t h, uint16_t color)
 {
     DrawBitmap(0, 0, BitUtil.ParseBinary(bitmapDefinedAsString), 8, 8, 1);
 }
コード例 #59
0
ファイル: BlockPerms.cs プロジェクト: DireClanMC/MCGalaxy
 public BlockPerms(BlockID id, LevelPermission min, List <LevelPermission> allowed,
                   List <LevelPermission> disallowed) : base(min, allowed, disallowed)
 {
     ID = id;
 }
コード例 #60
0
ファイル: BlockPerms.cs プロジェクト: DireClanMC/MCGalaxy
        static LevelPermission DefaultPerm(BlockID block)
        {
            switch (block)
            {
            case Block.Bedrock:
            case Block.Air_Flood:
            case Block.Air_FloodDown:
            case Block.Air_FloodLayer:
            case Block.Air_FloodUp:

            case Block.TNT_Big:
            case Block.TNT_Nuke:
            case Block.RocketStart:
            case Block.RocketHead:

            case Block.Creeper:
            case Block.ZombieBody:
            case Block.ZombieHead:

            case Block.Bird_Red:
            case Block.Bird_Killer:
            case Block.Bird_Blue:

            case Block.Fish_Gold:
            case Block.Fish_Sponge:
            case Block.Fish_Shark:
            case Block.Fish_Salmon:
            case Block.Fish_Betta:
            case Block.Fish_LavaShark:

            case Block.Snake:
            case Block.SnakeTail:
            case Block.FlagBase:
                return(LevelPermission.Operator);

            case Block.FloatWood:
            case Block.LavaSponge:
            case Block.Door_Log_air:
            case Block.Door_Green_air:
            case Block.Door_TNT_air:

            case Block.Water:
            case Block.Lava:
            case Block.FastLava:
            case Block.WaterDown:
            case Block.LavaDown:
            case Block.WaterFaucet:
            case Block.LavaFaucet:
            case Block.FiniteWater:
            case Block.FiniteLava:
            case Block.FiniteFaucet:
            case Block.Magma:
            case Block.Geyser:
            case Block.Deadly_Lava:
            case Block.Deadly_Water:
            case Block.Deadly_Air:
            case Block.Deadly_ActiveWater:
            case Block.Deadly_ActiveLava:
            case Block.Deadly_FastLava:
            case Block.LavaFire:

            case Block.C4:
            case Block.C4Detonator:
            case Block.TNT_Small:
            case Block.TNT_Explosion:
            case Block.Fireworks:
            case Block.Checkpoint:
            case Block.Train:

            case Block.Bird_White:
            case Block.Bird_Black:
            case Block.Bird_Water:
            case Block.Bird_Lava:
                return(LevelPermission.AdvBuilder);
            }
            return(LevelPermission.Guest);
        }