Example #1
0
 public static void PutGap(this IoBuffer buffer, Gap obj)
 {
     buffer.PutEntityId(obj.ReaderId);
     buffer.PutEntityId(obj.WriterId);
     buffer.PutSequenceNumber(obj.GapStart);
     buffer.PutSequenceNumberSet(obj.GapList);
 }
Example #2
0
    // Update is called once per frame

    /*
     * データのサンプリングを行い、データ数が十分であれば座標系同士のズレを計算する
     */
    void Update()
    {
        if (ab != null)
        {
            pData.AddRange(ab.getTAPLDataFromAndroid());                                                                                                                          //Bluetooth通信でPULLDOGの時間・Location情報を取得
            if (pData.Count != 0)                                                                                                                                                 //返値がNullでなければ
            {
                if (pData.Count > CALCULATE_POSITION_NUMBER + 10)                                                                                                                 //サンプリングを行うときにデータをpDataのデータ数を10個余分に見ておくことで、一回のサンプリングで完了できるようにしている(10個は適当)
                {
                    List <List <JsonTimeAndPositionLog> > listForCalGap = samplingFromHoloLensLogList(tsl.getJsonTimeAndPositionLogByBaseTime(ab.getBluetoothBaseTime()), pData); //参照する数だけHoloLensの時間・Location情報を取得
                    if (listForCalGap != null)
                    {                                                                                                                                                             //返値がNullでなければ
                        cordinateGap = calculateGap(listForCalGap);                                                                                                               //Gapを計算
                        for (int i = 0; i < listForCalGap[1].Count || i < listForCalGap[0].Count; i++)                                                                            //データの表示
                        {
                            if (i < listForCalGap[1].Count)
                            {
                                ol.writeMessage_trajectory("HoloLens,Time," + listForCalGap[1][i].mTime.Minutes + ";" + listForCalGap[1][i].mTime.Seconds + ";" + listForCalGap[1][i].mTime.Milliseconds + ",x," + listForCalGap[1][i].location.x + ",y," + listForCalGap[1][i].location.y);
                            }
                            if (i < listForCalGap[0].Count)
                            {
                                ol.writeMessage_trajectory("PullDog,Time," + listForCalGap[0][i].mTime.Minutes + ";" + listForCalGap[0][i].mTime.Seconds + ";" + listForCalGap[0][i].mTime.Milliseconds + ",x," + listForCalGap[0][i].location.x + ",y," + listForCalGap[0][i].location.y);
                            }
                        }
                        ol.writeMessage_trajectory("Gap,x," + cordinateGap.gapX + ",y," + cordinateGap.gapY + ",Angle," + cordinateGap.gapAngle); //データの表示
                        //cordinateGap = new Gap();
                        pData = new List <JsonTimeAndPositionLog>();
                        tsl.clearjTAPLList();
                        //CALCULATE_POSITION_NUMBER += 10;
                    }
                }
            }
        }
    }
Example #3
0
        private void splitGapAt(int gapIndex, long matchId)
        {
            var gap = _heap[gapIndex];

            if (matchId < gap.From || matchId > gap.To)
            {
                throw new Exception();
            }
            _heap[gapIndex].To = matchId - 1;
            if (_heap[gapIndex].Length > 0)
            {
                heapifyDownFrom(gapIndex);
            }
            else
            {
                // Remove this gap altogether. Not super optimal as we could just add the other gap here, but that's more special cases and it's already more than fast enough
                _heapLength--;
                swapGaps(gapIndex, _heapLength);
                heapifyDownFrom(gapIndex);
            }
            gap = new Gap {
                From = matchId + 1, To = gap.To
            };
            if (gap.Length > 0)
            {
                addToHeap(gap);
            }
        }
Example #4
0
        public override void RenderElement(RenderContext context, Action <TagBuilder> onRender = null)
        {
            if (SkipRender(context))
            {
                return;
            }
            var flex = new TagBuilder("div", "flex", IsInGrid);

            onRender?.Invoke(flex);
            if (Orientation != Orientation.Vertical)
            {
                flex.AddCssClass("horz");
            }
            MergeAttributes(flex, context);
            if (Gap != null)
            {
                flex.MergeStyle("gap", Gap.ToString());
            }
            if (JustifyItems != JustifyItems.Default)
            {
                flex.AddCssClass("justify-" + JustifyItems.ToString().ToKebabCase());
            }

            flex.RenderStart(context);
            RenderChildren(context);
            flex.RenderEnd(context);
        }
Example #5
0
        public async Task <IActionResult> Edit(int id, [Bind("InitValue,Value,Period,Id")] Gap gap)
        {
            Gap currGap = new Gap();

            if (id != gap.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    currGap = await _context.Gap.FindAsync(gap.Id);

                    currGap.Period = gap.Period;
                    _context.Update(currGap);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GapExists(gap.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(currGap));
        }
Example #6
0
    // Start is called before the first frame update
    private void Start()
    {
        float topHeight    = Random.Range(1, 6) * 2;
        float gapHeight    = Random.Range(3, 4) * 2;
        float bottomHeight = 20.0f - topHeight - gapHeight;

        //Spawn Top
        GameObject topBlock = Instantiate(m_BlockPrefab, this.transform);

        topBlock.name = "TopBlock";
        topBlock.transform.Translate(0.0f, GameSetting.Instance.screenBounds.y - (topHeight / 2) + BLOCK_YOFFSET, 0.0f);
        m_TopBlock = topBlock.GetComponent <BlockController>();
        m_TopBlock.SetSize(topHeight);

        //Spawn Bottom
        GameObject bottomBlock = Instantiate(m_BlockPrefab, this.transform);

        bottomBlock.name = "BottomBlock";
        bottomBlock.transform.Translate(0.0f, -GameSetting.Instance.screenBounds.y + BLOCK_YOFFSET, 0.0f);
        m_BottomBlock = bottomBlock.GetComponent <BlockController>();
        m_BottomBlock.SetSize(bottomHeight);

        //Spawn Gap
        GameObject gap = Instantiate(m_GapPrefab, this.transform);

        gap.transform.Translate(0.0f, topBlock.transform.position.y - BLOCK_YOFFSET - (gapHeight / 4), 0.0f);
        m_Gap = gap.GetComponent <Gap>();
        m_Gap.SetSize(gapHeight);
    }
Example #7
0
 protected override void RemoveComponentSpecific()
 {
     list.Remove(this);
     hulls[0]?.Remove(); hulls[0] = null;
     hulls[1]?.Remove(); hulls[1] = null;
     gap?.Remove(); gap           = null;
 }
Example #8
0
 public static void GetGap(this IoBuffer buffer, ref Gap obj)
 {
     obj.readerId = buffer.GetEntityId();
     obj.writerId = buffer.GetEntityId();
     obj.gapStart = buffer.GetSequenceNumber();
     obj.gapList = buffer.GetSequenceNumberSet();
 }
Example #9
0
        internal override void RenderElement(RenderContext context, Action <TagBuilder> onRender = null)
        {
            if (SkipRender(context))
            {
                return;
            }
            var grid = new TagBuilder("div", "grid", IsInGrid);

            onRender?.Invoke(grid);
            MergeAttributes(grid, context);
            if (Height != null)
            {
                grid.MergeStyle("height", Height.Value);
            }
            if (_rows != null)
            {
                grid.MergeStyle("grid-template-rows", _rows.ToAttribute());
            }
            if (_columns != null)
            {
                grid.MergeStyle("grid-template-columns", _columns.ToAttribute());
            }
            if (Background != BackgroundStyle.Default)
            {
                grid.AddCssClass("background-" + Background.ToString().ToKebabCase());
            }
            if (DropShadow != ShadowStyle.None)
            {
                grid.AddCssClass("drop-shadow");
                grid.AddCssClass(DropShadow.ToString().ToLowerInvariant());
            }
            if (Gap != null)
            {
                grid.MergeStyle("grid-gap", Gap.ToString());
            }

            if (AutoFlow != AutoFlowMode.Default)
            {
                grid.MergeStyle("grid-auto-flow", AutoFlow.ToString().ToKebabCase(delim: " "));
            }

            if (AlignItems != AlignItem.Default)
            {
                String aiStyle = AlignItems.ToString().ToLowerInvariant();
                if (AlignItems == AlignItem.Top)
                {
                    aiStyle = "start";
                }
                if (AlignItems == AlignItem.Bottom)
                {
                    aiStyle = "end";
                }
                grid.MergeStyle("align-items", aiStyle);
            }

            grid.RenderStart(context);
            RenderChildren(context);
            grid.RenderEnd(context);
        }
Example #10
0
    // Use this for initialization

    /*
     * 変数の初期化
     */
    void Start()
    {
        hData        = new List <JsonTimeAndPositionLog> ();
        pData        = new List <JsonTimeAndPositionLog> ();
        ol           = GetComponent <OutputLog> ();
        ab           = GetComponent <ActionBluetooth> ();
        cordinateGap = new Gap();
    }
Example #11
0
        public GapViewModel(Gap gap)
        {
            Model = gap;
            Id    = gap.Id;

            Notice  = Notice.Instance;
            Setting = SettingService.Setting;
        }
        public void When_the_value_is_147_the_same_should_return_2()
        {
            int       value       = 147;
            const int ExpectedGap = 2;

            var result = new Gap().FindsTheBinaryGap(value);

            Assert.Equal(ExpectedGap, result);
        }
        public static bool IsInTargetGap(this Gap gap, int number)
        {
            if (gap == null)
            {
                return(false);
            }

            return(gap.StartInTargetFile <= number && number <= gap.EndInTargetFile);
        }
Example #14
0
 static void AddGapRidge(bool[,] shadow, Gap gap, Point[] line)
 {
     SkeletonRidge ridge = new SkeletonRidge();
     foreach (Point point in line)
         ridge.Points.Add(point);
     ridge.Start = gap.End1;
     ridge.End = gap.End2;
     foreach (Point point in line)
         point.Set(shadow, true);
 }
Example #15
0
    private float HeightCalculation()
    {
        Column column = FindObjectOfType <Column>();
        Gap    gap    = FindObjectOfType <Gap>();

        float columnHeight = column.GetComponent <SpriteRenderer>().bounds.size.y;
        float gapHeight    = gap.GetComponent <SpriteRenderer>().bounds.size.y;

        return(columnHeight / 2 + gapHeight / 2);
    }
Example #16
0
        public Filling(Gap gap, int length)
        {
            var occupation = new bool[length];

            for (int i = gap.Start; i < gap.End; i++)
            {
                occupation[i] = true;
            }
            Occupation = occupation;
        }
Example #17
0
 void AddRidge(SkeletonBuilder skeleton, BinaryMap shadow, Gap gap, Point[] line)
 {
     SkeletonBuilder.Ridge ridge = new SkeletonBuilder.Ridge();
     foreach (Point point in line)
         ridge.Points.Add(point);
     ridge.Start = gap.End1;
     ridge.End = gap.End2;
     foreach (Point point in line)
         shadow.SetBitOne(point);
 }
Example #18
0
            public static Gap Connect(Unit first, Unit second, Diagramm dgrm)
            {
                if (!dgrm.Units.Contains(first) || !dgrm.Units.Contains(second))
                {
                    throw new ArgumentException();
                }
                var edge = new Gap(first, second);

                first.edges.Add(edge);
                return(edge);
            }
Example #19
0
        protected override void RemoveComponentSpecific()
        {
            base.RemoveComponentSpecific();
            list.Remove(this);
            hulls[0]?.Remove(); hulls[0] = null;
            hulls[1]?.Remove(); hulls[1] = null;
            gap?.Remove(); gap           = null;

            overlaySprite?.Remove();
            overlaySprite = null;
        }
Example #20
0
        internal Gap AllocGap()
        {
            var gap = _gapPool;

            if (gap == null)
            {
                return(new Gap());
            }
            _gapPool = gap.Next;
            return(gap);
        }
Example #21
0
        public void ClientRead(ServerNetObject type, Lidgren.Network.NetBuffer msg, float sendingTime)
        {
            bool isDocked = msg.ReadBoolean();

            for (int i = 0; i < 2; i++)
            {
                if (hulls[i] == null)
                {
                    continue;
                }
                item.linkedTo.Remove(hulls[i]);
                hulls[i].Remove();
                hulls[i] = null;
            }

            if (gap != null)
            {
                item.linkedTo.Remove(gap);
                gap.Remove();
                gap = null;
            }

            if (isDocked)
            {
                ushort dockingTargetID = msg.ReadUInt16();

                bool isLocked = msg.ReadBoolean();

                Entity targetEntity = Entity.FindEntityByID(dockingTargetID);
                if (targetEntity == null || !(targetEntity is Item))
                {
                    DebugConsole.ThrowError("Invalid docking port network event (can't dock to " + targetEntity.ToString() + ")");
                    return;
                }

                dockingTarget = (targetEntity as Item).GetComponent <DockingPort>();
                if (dockingTarget == null)
                {
                    DebugConsole.ThrowError("Invalid docking port network event (" + targetEntity + " doesn't have a docking port component)");
                    return;
                }

                Dock(dockingTarget);

                if (isLocked)
                {
                    Lock(true);
                }
            }
            else
            {
                Undock();
            }
        }
Example #22
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Aperture.GetHashCode();
         hashCode = (hashCode * 397) ^ Gap.GetHashCode();
         hashCode = (hashCode * 397) ^ Annulus.GetHashCode();
         hashCode = (hashCode * 397) ^ (int)Type;
         return(hashCode);
     }
 }
Example #23
0
    private Vector2 SpawnGap()
    {
        float   yPos     = Random.Range(minSpawnYpos, maxSpawnYpos);
        Vector2 spawnPos = new Vector2(transform.position.x, yPos);
        Gap     newGap   = Instantiate(
            gapPrefab,
            spawnPos,
            Quaternion.identity) as Gap;

        return(spawnPos);
    }
Example #24
0
 private void addToHeap(Gap gap)
 {
     if (_heapLength == _heap.Length)
     {
         var tmp = _heap;
         _heap = new Gap[_heap.Length * 5 / 4]; // the size of this array settles over repeated invocations of rebuild, so no need to grow it very fast; prioritise reduced RAM waste
         Array.Copy(tmp, _heap, _heapLength);
     }
     _heap[_heapLength++] = gap;
     heapifyUpFrom(_heapLength - 1);
 }
Example #25
0
        public async Task <IActionResult> Create([Bind("InitValue,Value,Period,Id")] Gap gap)
        {
            if (ModelState.IsValid)
            {
                _context.Add(gap);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(gap));
        }
Example #26
0
        internal void Reset()
        {
            for (var i = 0; i < _tree.Length; i++)
            {
                _tree[i].Reset();
                _gaps[i] = null;
            }

            _gapPool  = null;
            Size      = 0;
            Alignment = 0;
        }
Example #27
0
        private static List <DailyCandle> AddGaps(List <DailyCandle> dailyCandles)
        {
            double previousClose = 500;

            foreach (var candle in dailyCandles)
            {
                var gap = new Gap(previousClose, candle.Open, candle.Date.Date);
                candle.Gap    = gap;
                previousClose = candle.Close;
            }

            return(dailyCandles);
        }
Example #28
0
 void AddRidge(SkeletonBuilder skeleton, BinaryMap shadow, Gap gap, Point[] line)
 {
     SkeletonBuilder.Ridge ridge = new SkeletonBuilder.Ridge();
     foreach (Point point in line)
     {
         ridge.Points.Add(point);
     }
     ridge.Start = gap.End1;
     ridge.End   = gap.End2;
     foreach (Point point in line)
     {
         shadow.SetBitOne(point);
     }
 }
        public Gap Find(string Periode, string Posisi)
        {
            Gap gap = new Gap();

            using (var ctx = new AhpEntities()) {
                gap.prosesGap = ctx.SpProseGap(Posisi, Periode).ToList();
                gap.kriterias = ctx.Kriterias.OrderBy(x => x.Kode).ToList();
            }

            var calonKaryawanGaps = (from a in (gap.prosesGap.GroupBy(x =>
                                                                      new {
                x.KodeKaryawan,
                x.Nama,
                x.KodeLowongan,
                x.Periode
            }).Select(g => g.FirstOrDefault()).ToList())
                                     select new CalonKaryawanGap {
                kodeKaryawan = a.KodeKaryawan,
                kodeLowongan = a.KodeLowongan,
                namaKaryawan = a.Nama,
                periode = a.Periode
            }).ToList();

            foreach (var c in calonKaryawanGaps)
            {
                var prosesGap = gap.prosesGap.Where(x => x.KodeKaryawan.Equals(c.kodeKaryawan) &&
                                                    x.KodeLowongan.Equals(c.kodeLowongan)).ToList();
                List <NilaiGapBobot> nilaiGapBobots = new List <NilaiGapBobot>();
                foreach (var item in prosesGap)
                {
                    NilaiGapBobot nilaiGapBobot = new NilaiGapBobot();
                    nilaiGapBobot.kodeKriteria    = item.KodeKriteria;
                    nilaiGapBobot.kriteria        = item.Kriteria;
                    nilaiGapBobot.nilaiBobot      = (decimal)item.NilaiBobot;
                    nilaiGapBobot.nilaiAlternatif = (decimal)item.NilaiAlternatif;
                    nilaiGapBobot.nilaiGap        = (decimal)item.NilaiGap;
                    nilaiGapBobot.ncf             = Math.Round((decimal)item.Ncf + 0.0000m, 4);
                    nilaiGapBobot.nsf             = Math.Round((decimal)item.Nsf + 0.0000m, 4);
                    nilaiGapBobot.nilaiTotal      = Math.Round((decimal)item.NilaiTotal + 0.0000m, 4);
                    nilaiGapBobot.nilaiTarget     = (decimal)gap.kriterias.SingleOrDefault(x => x.Kode.Equals(item.KodeKriteria)).NilaiTarget;
                    nilaiGapBobots.Add(nilaiGapBobot);
                }
                c.nilaiGapBobots = nilaiGapBobots;
            }

            gap.calonKaryawanGaps = calonKaryawanGaps;

            return(gap);
        }
Example #30
0
        public int maximumGap(List <int> A)
        {
            if (A.Count < 2)
            {
                return(0);
            }
            var min     = A.Min();
            var max     = A.Max();
            var gapSize = (int)Math.Ceiling((double)(max - min) / (A.Count - 1));

            if (gapSize == 0)
            {
                return(0);
            }
            var buckets = new Gap[A.Count];

            var maxGap = 0;
            int i      = 0;

            for (i = 0; i < A.Count; i++)
            {
                var n = (A[i] - min) / gapSize;
                if (buckets[n] == null)
                {
                    buckets[n] = new Gap(A[i], A[i]);
                }
                buckets[n].Min = Math.Min(A[i], buckets[n].Min);
                buckets[n].Max = Math.Max(A[i], buckets[n].Max);
            }

            var nonEmptyBuckets = new List <Gap>();

            foreach (var t in buckets)
            {
                if (t != null)
                {
                    nonEmptyBuckets.Add(t);
                }
            }

            for (int j = 0; j < nonEmptyBuckets.Count - 1; j++)
            {
                var b1 = nonEmptyBuckets[j];
                var b2 = nonEmptyBuckets[j + 1];
                maxGap = Math.Max(maxGap, b2.Min - b1.Max);
            }

            return(maxGap);
        }
Example #31
0
        internal ConstantPool()
        {
            var dataSize = 1;

            for (var i = 0; i < _tree.Length; i++)
            {
                _tree[i]   = new Tree(dataSize);
                _gaps[i]   = null;
                dataSize <<= 1;
            }

            _gapPool  = null;
            Size      = 0;
            Alignment = 0;
        }
        private static void AddGapRidge(bool[,] shadow, Gap gap, Point[] line)
        {
            var ridge = new SkeletonRidge();

            foreach (var point in line)
            {
                ridge.Points.Add(point);
            }
            ridge.Start = gap.End1;
            ridge.End   = gap.End2;
            foreach (var point in line)
            {
                point.Set(shadow, true);
            }
        }
Example #33
0
        static void AddGapRidge(BooleanMatrix shadow, Gap gap, IntPoint[] line)
        {
            var ridge = new SkeletonRidge();

            foreach (var point in line)
            {
                ridge.Points.Add(point);
            }
            ridge.Start = gap.End1;
            ridge.End   = gap.End2;
            foreach (var point in line)
            {
                shadow[point] = true;
            }
        }
Example #34
0
        private void button_LoadTraingData_Click(object sender, EventArgs e)
        {
            Form1_Load(sender, null);
            listBox_TrainData.Items.Clear();
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    LoadData(openFileDialog1.FileName);
                    label_TrainFileName.Text = ("Training file is " + openFileDialog1.FileName);
                    label_TrainDataNum.Text  = (label_TrainDataNum.Text + (Index.Count() / 10).ToString() + " * 10");
                    //label_TrainDataNum.Text = (label_TrainDataNum.Text + (Gap.Count() / 10).ToString() + " * 10");
                }
                catch { }
            }
            InputData  = new double[Index.Count()][];
            DataOutput = new double[Index.Count()];
            //InputData = new double[Gap.Count()][];
            //DataOutput = new double[Gap.Count()];


            Gap    = Function.Normalization(Gap);
            Feed   = Function.Normalization(Feed);
            Hipwr  = Function.Normalization(Hipwr);
            WaterR = Function.Normalization(WaterR);

            for (int i = 0; i < Gap.Count(); i++)
            {
                try
                {
                    listBox_TrainData.Items.Add(Index[i] + "\t" + Gap[i].ToString("f3") + "\t" + Feed[i].ToString("f3") + "\t" + Hipwr[i].ToString("f3") + "\t" + WaterR[i].ToString("f3") + "\t" + Label5[i]);
                    //listBox_TrainData.Items.Add(Gap[i] + "\t" + Feed[i] + "\t\t" + Hipwr[i] + "\t" + WaterR[i] + "\t" + Label5[i]);
                    InputData[i]         = new double[4];
                    InputData[i][0]      = Gap[i];
                    InputData[i][1]      = Feed[i];
                    InputData[i][2]      = Hipwr[i];
                    InputData[i][3]      = WaterR[i];
                    DataOutput[i]        = Label5[i];
                    label_InputNum.Text  = ("InputNum : " + InputData.Length.ToString() + " * " + InputData[0].Length.ToString());
                    button_Train.Enabled = true;
                }
                catch
                {
                    MessageBox.Show("Choose error file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;
                }
            }
        }
Example #35
0
 public static Gap GetGap(this IoBuffer buffer)
 {
     Gap obj = new Gap();
     buffer.GetGap(ref obj);
     return obj;
 }
Example #36
0
        private Gap.Network.Message SendRequest(Gap.Network.Message requestMessage)
        {
            Gap.Network.Message.Send(_transmitterSocket, requestMessage);

            return Gap.Network.Message.Receive(_transmitterSocket);
        }
Example #37
0
        public static void GetSubMessage(this IoBuffer buffer, ref SubMessage obj)
        {
            buffer.Align(4);
            int smhPosition = buffer.Position;

            SubMessageHeader header = buffer.GetSubMessageHeader();
            int smStart = buffer.Position;

            switch (header.SubMessageKind)
            { // @see 9.4.5.1.1
                case SubMessageKind.PAD:
                    Pad smPad = new Pad();
                    smPad.Header = header;
                    buffer.GetPad(ref smPad);
                    obj = smPad;
                    break;
                case SubMessageKind.ACKNACK:
                    AckNack smAckNack = new AckNack();
                    smAckNack.Header = header;
                    buffer.GetAckNack(ref smAckNack);
                    obj = smAckNack;
                    break;
                case SubMessageKind.HEARTBEAT:
                    Heartbeat smHeartbeat = new Heartbeat();
                    smHeartbeat.Header = header;
                    buffer.GetHeartbeat(ref smHeartbeat);
                    obj = smHeartbeat;
                    break;
                case SubMessageKind.GAP:
                    Gap smgap = new Gap();
                    smgap.Header = header;
                    buffer.GetGap(ref smgap);
                    obj = smgap;
                    break;
                case SubMessageKind.INFO_TS:
                    InfoTimestamp sminfots = new InfoTimestamp();
                    sminfots.Header = header;
                    buffer.GetInfoTimestamp(ref sminfots);
                    obj = sminfots;
                    break;
                case SubMessageKind.INFO_SRC:
                    InfoSource smInfoSource = new InfoSource();
                    smInfoSource.Header = header;
                    buffer.GetInfoSource(ref smInfoSource);
                    obj = smInfoSource;
                    break;
                case SubMessageKind.INFO_REPLY_IP4:
                    InfoReplyIp4 smInfoReplyIp4 = new InfoReplyIp4();
                    smInfoReplyIp4.Header = header;
                    buffer.GetInfoReplyIp4(ref smInfoReplyIp4);
                    obj = smInfoReplyIp4;
                    break;
                case SubMessageKind.INFO_DST:
                    InfoDestination smInfoDestination = new InfoDestination();
                    smInfoDestination.Header = header;
                    buffer.GetInfoDestination(ref smInfoDestination);
                    obj = smInfoDestination;
                    break;
                case SubMessageKind.INFO_REPLY:
                    InfoReply smInfoReply = new InfoReply();
                    smInfoReply.Header = header;
                    buffer.GetInfoReply(ref smInfoReply);
                    obj = smInfoReply;
                    break;
                case SubMessageKind.NACK_FRAG:
                    NackFrag smNackFrag = new NackFrag();
                    smNackFrag.Header = header;
                    buffer.GetNackFrag(ref smNackFrag);
                    obj = smNackFrag;
                    break;
                case SubMessageKind.HEARTBEAT_FRAG:
                    HeartbeatFrag smHeartbeatFrag = new HeartbeatFrag();
                    smHeartbeatFrag.Header = header;
                    buffer.GetHeartbeatFrag(ref smHeartbeatFrag);
                    obj = smHeartbeatFrag;
                    break;
                case SubMessageKind.DATA:
                    Data smdata = new Data();
                    smdata.Header = header;
                    buffer.GetDataSubMessage(ref smdata);
                    obj = smdata;
                    break;
                case SubMessageKind.DATA_FRAG:
                    DataFrag smdDataFrag = new DataFrag();
                    smdDataFrag.Header = header;
                    buffer.GetDataFrag(ref smdDataFrag);
                    obj = smdDataFrag;
                    break;

                default:
                    throw new NotSupportedException();
                    break;
            }

            int smEnd = buffer.Position;
            int smLength = smEnd - smStart;
            if (smLength != header.SubMessageLength && header.SubMessageLength != 0)
            {
                log.WarnFormat("SubMessage length differs for {0} != {1} for {2}", smLength, header.SubMessageLength, obj);
                if (smLength < header.SubMessageLength)
                {
                    byte[] unknownBytes = new byte[header.SubMessageLength - smLength];
                    log.DebugFormat("Trying to skip {0} bytes", unknownBytes.Length);

                    buffer.Get(unknownBytes, 0, unknownBytes.Length);
                }
            }

            log.DebugFormat("SubMsg in:  {0}", obj);
        }
Example #38
0
 // This is a quick(ish) way to scan all the programmes in pips_programmes
 // and find all gaps in the schedule.
 // Note that this process will find all actual gaps where
 // the channel is not transmitting
 private void ScanGaps_Click(object sender, RoutedEventArgs e)
 {
     List<Gap> gaps = new List<Gap>();
     Task.Factory.StartNew(() =>
         {
             StringBuilder sql = new StringBuilder();
             sql.AppendLine("insert into gaps (programme_id, service_id, gapstart,gapend)");// VALUES(1234,1,"2007-06-28 03:00","2007-06-28 06:00")
             using (var data = new ReduxItems())
             {
                 var programmes = (from prog in data.pips_programmes
                                   //orderby prog.ServiceId, prog.StartTime
                                   select prog).ToList();
                 programmes = (from prog in programmes
                              orderby prog.service_id, prog.start_gmt
                              select prog).ToList();
                 PipsProgramme prev = null;
                 using (var newdata = new ReduxItems())
                 {
                     foreach (var prog in programmes)
                     {
                         if (prev != null && prev.service_id == prog.service_id && prev.end_gmt < prog.start_gmt)
                         {
                             Gap gap = new Gap
                             {
                                 pips_id = prog.id,
                                 service_id = prog.service_id,
                                 gapstart = prev.end_gmt,
                                 gapend = prog.start_gmt
                             };
                             newdata.gaps.Add(gap);
                             Dispatcher.Invoke((MyDelegate)delegate { gapLabel.Content = string.Format("{0}", gap.gapstart); });
                         }
                         if (prev == null || prog.service_id != prev.service_id || prog.end_gmt > prev.end_gmt)
                         {
                             prev = prog;
                         }
                     }
                     newdata.SaveChanges();
                 }
                 Dispatcher.Invoke((MyDelegate)delegate { gapGrid.ItemsSource = data.gaps; });
             }
         });
 }