Пример #1
0
        // Recalculate (X+...) from (I, J)
        public static void CalculateXYEventFromIJ(PETSingleDigitalEvent In, ref PETSingleEvent Out)
        {
            Out.Position  = In.Position;
            Out.Timestamp = In.Timestamp;

            // не совсем точно с энергией. она должна быть взята из пакета, но пока её нет в протоколе
            GetXYFromIJ(In.I, In.J, 511, out Out.XPlus, out Out.XMinus, out Out.YPlus, out Out.YMinus);
            // Out.E = 511; или In.E
        }
Пример #2
0
        // Recalculate (I,J) from (X+, X-, Y+, Y-) and copy other parameters
        public static void CalculateDigitalEvent(PETSingleEvent In, ref PETSingleDigitalEvent OutE)
        {
            OutE.I = (byte)iForX(In.XPlus, In.XMinus);
            OutE.J = (byte)iForX(In.YPlus, In.YMinus);

            OutE.Position  = In.Position;
            OutE.Timestamp = In.Timestamp;

            // OutE.Flags = In.Flags;
        }
Пример #3
0
        public static PETSingleDigitalEvent[] ConvertXYToIJEvents(PETSingleEvent[] events)
        {
            var res = new PETSingleDigitalEvent[events.Length];

            for (int i = 0; i < res.Length; i++)
            {
                CalculateDigitalEvent(events[i], ref res[i]);
            }

            return(res);
        }
Пример #4
0
        public static PETSingleDigitalEvent FromBytes(byte[] b, int Ofs)
        {
            var res = new PETSingleDigitalEvent();

            res.Timestamp = BitConverter.ToUInt32(b, Ofs + 0);
            res.Position  = BitConverter.ToUInt16(b, Ofs + 4);

            res.I = b[Ofs + 6];
            res.J = b[Ofs + 7];

            return(res);
        }
Пример #5
0
        public static void CalculateEventForDigital(PETSingleDigitalEvent In, ref PETSingleEvent OutE)
        {
            OutE.XPlus  = XPlusForI(In.I);
            OutE.XMinus = XMinusForI(In.I);

            OutE.YPlus  = YPlusForJ(In.J);
            OutE.YMinus = YMinusForJ(In.J);

            OutE.Position  = In.Position;
            OutE.Timestamp = In.Timestamp;

            // OutE.Flags = In.Flags;
        }
Пример #6
0
        public static PETSingleDigitalEvent[] DecodeArray(byte[] b, int Ofs, int Len)
        {
            int ofs = Ofs;
            var res = new List <PETSingleDigitalEvent>();
            int num = Len / PETStructSizes.PETSingleDigitalEvent_Size;

            for (int i = 0; i < num; i++)
            {
                var evt = PETSingleDigitalEvent.FromBytes(b, ofs);
                res.Add(evt);

                ofs += PETStructSizes.PETSingleDigitalEvent_Size;
            }

            return(res.ToArray());
        }