Пример #1
0
 public override void DrawContents(DataRecord rec)
 {
     if (rec != null)
     {
         if (rec.content[0] == 0x01)
         {
             xspp = (rec.content[1] - 128) / 10.0;
             yspp = (rec.content[2] - 128) / 10.0;
         }
     }
     xsp = 0.8 * xsp + 0.2 * xspp;
     ysp = 0.8 * ysp + 0.2 * yspp;
     RendererWrapper.DrawCoordinate(boundingbox, new RGBAColor(1, 1, 1, 0.3));
     RendererWrapper.DrawArrow(boundingbox, new Point2D(boundingbox.Width / 2, boundingbox.Height / 2),
                               new Point2D(boundingbox.Width / 2 + 7 * xsp, boundingbox.Height / 2 + 7 * ysp),
                               Globals.emgchannelcols[8], thickness: 2, headsize: 25);
 }
Пример #2
0
        public void Update()
        {
            DataRecord    rdr  = null;
            DataRecordRaw rdrr = null;

            do
            {
                rdr = Globals.datbuf.Pop(RawDataBuffer.ConsumerName.GUI);
                if (rdr != null)
                {
                    rdrr = new DataRecordRaw(rdr);
                }
                foreach (var p in panellistraw)
                {
                    p.Draw(rdrr);
                }
            } while (Globals.datbuf.bufgui.Count > 0);
        }
Пример #3
0
        //Called by GUI
        public void UpdatePanels()
        {
            DataRecord rdr = null;

            //while len>0?
            do
            {
                rdr = Globals.appdatbuf.Pop();
                foreach (var app in applist)
                {
                    foreach (var panel in app.Panels)
                    {
                        panel.Draw(rdr);
                    }
                    foreach (var cl in app.Clickables)
                    {
                        cl.UpdateGraphics();
                    }
                }
            } while (Globals.appdatbuf.buf.Count > 0);
        }
Пример #4
0
        public override void DrawContents(DataRecord rec)
        {
            if (rec != null)                    //new record
            {
                if (rec.content[0] == 0x09)     //check appuid
                {
                    if (rec.content[1] == 0x01) //mouse enabled
                    {
                        xspp = AppUtils.ValueMapToDouble(rec.content[2], -15, 15);
                        yspp = AppUtils.ValueMapToDouble(rec.content[3], -15, 15);
                    }
                    mxspp  = -AppUtils.ValueMapToDouble(rec.content[4], -15, 15);
                    myspp  = AppUtils.ValueMapToDouble(rec.content[5], -15, 15);
                    mxsoff = -AppUtils.ValueMapToDouble(rec.content[6], -15, 15);
                    mysoff = AppUtils.ValueMapToDouble(rec.content[7], -15, 15);
                }
            }
            xsp  = 0.8 * xsp + 0.2 * xspp;
            ysp  = 0.8 * ysp + 0.2 * yspp;
            mxsp = 0.8 * mxsp + 0.2 * mxspp;
            mysp = 0.8 * mysp + 0.2 * myspp;
            RendererWrapper.DrawCoordinate(boundingbox, new RGBAColor(1, 1, 1, 0.3));
            List <Point2D> mpts = new List <Point2D>();

            mpts.Add(new Point2D(boundingbox.Width / 2 + 7 * mxsoff, boundingbox.Height / 2));
            mpts.Add(new Point2D(boundingbox.Width / 2, boundingbox.Height / 2 + 7 * mysoff));
            RendererWrapper.DrawMarkers(boundingbox, mpts, Globals.emgchannelcols[7], 0, 10);
            RendererWrapper.DrawArrow(boundingbox, new Point2D(boundingbox.Width / 2, boundingbox.Height / 2),
                                      new Point2D(boundingbox.Width / 2 + 7 * mxsp - 7 * mxsoff, boundingbox.Height / 2),
                                      Globals.emgchannelcols[7], thickness: 2, headsize: 10);
            RendererWrapper.DrawArrow(boundingbox, new Point2D(boundingbox.Width / 2, boundingbox.Height / 2),
                                      new Point2D(boundingbox.Width / 2, boundingbox.Height / 2 + 7 * mysp - 7 * mysoff),
                                      Globals.emgchannelcols[7], thickness: 2, headsize: 10);
            RendererWrapper.DrawArrow(boundingbox, new Point2D(boundingbox.Width / 2, boundingbox.Height / 2),
                                      new Point2D(boundingbox.Width / 2 + 7 * xsp, boundingbox.Height / 2 + 7 * ysp),
                                      Globals.emgchannelcols[8], thickness: 2, headsize: 25);
        }
Пример #5
0
 public abstract void DrawContents(DataRecord rec);
Пример #6
0
 public void Draw(DataRecord rec)
 {
     boundingbox.origleft = boundingbox.origright - 1.0;
     DrawBorder();
     DrawContents(rec);
 }
Пример #7
0
 public void DoWork()
 {
     Serial1 = new SerialPort(/*"COM13"*/ "COM20", 115200, Parity.None, 8, StopBits.One)
     {
         DtrEnable   = false,
         RtsEnable   = false,
         ReadTimeout = 500
     };
     while (running)
     {
         if (usefakedata)
         {
             DataRecord rec = new DataRecord(0x10, fakegen.MakeFakeData());
             Globals.datbuf.Push(rec);
             Thread.Sleep(50);
         }
         else
         {
             if (Serial1.IsOpen)
             {
                 byte tx = (byte)'s';
                 lock (Globals.serialcommand) {
                     if (Globals.serialcommand.Count > 0)
                     {
                         tx = Globals.serialcommand.Dequeue();
                     }
                 }
                 byte[] bytesnd = new byte[1] {
                     tx
                 };
                 byte[] msglenrecv = new byte[10];
                 byte[] byterecv = new byte[100];
                 byte[] datrecv = new byte[100];
                 int    msglen = 0;
                 bool   failed = false;
                 int    readnum = 0, offset = 0;
                 Serial1.DiscardInBuffer();
                 Serial1.Write(bytesnd, 0, 1);
                 try {
                     Serial1.Read(msglenrecv, 0, 1);
                 } catch (TimeoutException) {
                     failed = true;
                 }
                 msglen = msglenrecv[0] - 1;
                 if (msglen <= 0 || msglen >= 90)
                 {
                     failed = true;
                 }
                 if (!failed)
                 {
                     do      //it cannot be guaranteed that we would get all the data with one Serial.Read() because the serial port is not that fast and there may be remaining bytes to be transferred
                     {
                         try {
                             readnum = Serial1.Read(byterecv, offset, msglen - offset);
                             offset += readnum;
                         } catch (TimeoutException) {
                             failed = true;  //when serial read timed out
                         }
                     } while (offset < msglen && failed == false);
                     if (!failed)
                     {
                         Array.Copy(byterecv, 1, datrecv, 0, msglen - 1);
                         DataRecord rec = new DataRecord(0xAA, datrecv.ToList());
                         Globals.datbuf.Push(rec);
                     }
                 }
             }
             Thread.Sleep(50);
         }
     }
 }
Пример #8
0
 public abstract void Run(DataRecord rec);
Пример #9
0
        public override void DrawContents(DataRecord rec)
        {
            if (rec != null)
            {
                if (rec.content[0] == 0x01)
                {
                    xsp = (rec.content[1] - 128) / 50.0;
                    ysp = (rec.content[2] - 128) / 50.0;
                    if (rec.content[3] == 0x01)
                    {
                        particles.Add(new Particle(Particle.ParticleShapes.Cross, new RGBAColor(1.0, 0.5, 0.0, 1.0),
                                                   600, 7, 7, cursorpos.x + boundingbox.Width / 2, cursorpos.y + boundingbox.Height / 2,
                                                   lifefade_: 200
                                                   ));
                        particles.Add(new Particle(Particle.ParticleShapes.Diamond, new RGBAColor(1.0, 0.5, 0.0, 1.0),
                                                   30, 3, 3, cursorpos.x + boundingbox.Width / 2, cursorpos.y + boundingbox.Height / 2,
                                                   lifefade_: 30, xscalef_: 15, yscalef_: 15, bm_: RendererWrapper.BlendModes.Add, aseyecandy_: true
                                                   ));
                        //leftclicks.Add(new Point2D(cursorpos.x + boundingbox.Width / 2, cursorpos.y + boundingbox.Height / 2));
                    }
                    if (rec.content[4] == 0x01)
                    {
                        particles.Add(new Particle(Particle.ParticleShapes.Cross, new RGBAColor(0.0, 0.3, 1.0, 1.0),
                                                   600, 7, 7, cursorpos.x + boundingbox.Width / 2, cursorpos.y + boundingbox.Height / 2,
                                                   lifefade_: 200
                                                   ));
                        particles.Add(new Particle(Particle.ParticleShapes.Diamond, new RGBAColor(0.0, 0.3, 1.0, 1.0),
                                                   30, 3, 3, cursorpos.x + boundingbox.Width / 2, cursorpos.y + boundingbox.Height / 2,
                                                   lifefade_: 30, xscalef_: 15, yscalef_: 15, bm_: RendererWrapper.BlendModes.Add, aseyecandy_: true
                                                   ));
                        //rightclicks.Add(new Point2D(cursorpos.x + boundingbox.Width / 2, cursorpos.y + boundingbox.Height / 2));
                    }
                }
            }
            cursorpos.x += xsp;
            cursorpos.y += ysp;
            if (cursorpos.x > boundary)
            {
                cursorpos.x = boundary;
            }
            if (cursorpos.x < -boundary)
            {
                cursorpos.x = -boundary;
            }
            if (cursorpos.y > boundary)
            {
                cursorpos.y = boundary;
            }
            if (cursorpos.y < -boundary)
            {
                cursorpos.y = -boundary;
            }
            List <Point2D> curpos = new List <Point2D>();

            curpos.Add(new Point2D(cursorpos.x + boundingbox.Width / 2, cursorpos.y + boundingbox.Height / 2));
            RendererWrapper.DrawCoordinate(boundingbox, new RGBAColor(1, 1, 1, 0.3));
            //RendererWrapper.DrawMarkers(boundingbox, leftclicks, new RGBAColor(1.0, 0.5, 0.0, 1.0), 1, 8);
            //RendererWrapper.DrawMarkers(boundingbox, rightclicks, new RGBAColor(0.0, 0.3, 1.0, 1.0), 1, 8);
            RendererWrapper.DrawParticles(boundingbox, particles);
            RendererWrapper.DrawMarkers(boundingbox, curpos, new RGBAColor(Globals.emgchannelcols[8]), 0, 8);
        }