Esempio n. 1
0
        private void StopLD()
        {
            if (!ldRunning)
            {
                return;
            }

            LD.SetWorkingScanners(-1);             // 'Set all scanners
            LD.SetWorkingTracks(-1);               // 'Set all tracks
            LD.DisplayFrame(0);                    // 'Basically, we make it so that anything that is being displayed now, on any scanner is blanked out
            LD.SetWorkingTracks(1);                // 'always exit with this set to 1 to avoid bugs
            LD.DisplayUpdate();
        }
Esempio n. 2
0
        public void Configurate(IPluginConfig Input)
        {
            if (!ldRunning)
            {
                PrintStatusMessage(STATUS_MSG_NOT_RUNNING);
                return;
            }

            if (Input == FScanRateIn)
            {
                double scanRate;
                FScanRateIn.GetValue(0, out scanRate);

                int desiredPPS = (int)scanRate;
                int actualPPS  = desiredPPS;
                LD.DisplayFreq3(desiredPPS, desiredPPS, desiredPPS, ref actualPPS, ref actualPPS, ref actualPPS);
            }
        }
Esempio n. 3
0
        private void RunLD()
        {
            try
            {
                if (ldRunning)
                {
                    return;
                }

                LD.InitialQMCheck(ref ldStatus);
                if (ldStatus != LD.LDSTATUS_OK)
                {
                    PrintStatusMessage("QMCheck failed.");
                    return;
                }

                LD.BeginSessionEx(ref ldVersion,
                                  ref ldMaxFrames,
                                  ref ldMaxPoints,
                                  ref ldMaxBuffer,
                                  ref ldUndoFrames,
                                  ref ldStatus);
                if (ldStatus != LD.LDSTATUS_OK)
                {
                    PrintStatusMessage("BeginSessionEx failed.");
                    return;
                }

                LD.SetWorkingScanners(-1);
                LD.SetWorkingTracks(1);
                LD.SetWorkingFrame(1);

                ldRunning = true;
            }
            catch (Exception)
            {
                ldRunning = false;
            }
        }
Esempio n. 4
0
        //here we go, thats the method called by vvvv each frame
        //all data handling should be in here
        unsafe public void Evaluate(int SpreadMax)
        {
            if (!ldRunning)
            {
                return;
            }
            else
            {
                PrintStatusMessage("");
            }

            double    tmp;
            double *  px, py;
            int       v, countx, county;
            int       frameOffset = 0;
            int       pointCount  = 0;
            RGBAColor color;

            int[] frames = new int[FFrameIn.SliceCount];

            for (int i = 0; i < frames.Length; i++)
            {
                FFrameIn.GetValue(i, out tmp);
                frames[i] = VMath.Zmod((int)tmp, ldMaxFrames);
            }

            FDoWriteIn.GetValue(0, out tmp);
            if (tmp > 0)
            {
                pointCount = Math.Max(Math.Max(FXIn.SliceCount, FYIn.SliceCount), FColorIn.SliceCount);

                // Setup a mapping of point and its special flags.
                pointFlagMap.Clear();
                int pointId;
                for (int j = 0; j < FCornerIn.SliceCount; j++)
                {
                    FCornerIn.GetValue(j, out tmp);
                    pointId = VMath.Zmod((int)tmp, pointCount);
                    if (pointFlagMap.ContainsKey(pointId))
                    {
                        pointFlagMap[pointId] |= FLAG_CORNER;
                    }
                    else
                    {
                        pointFlagMap[pointId] = FLAG_CORNER;
                    }
                }
                for (int j = 0; j < FTravelBlankIn.SliceCount; j++)
                {
                    FTravelBlankIn.GetValue(j, out tmp);
                    pointId = VMath.Zmod((int)tmp, pointCount);
                    if (pointFlagMap.ContainsKey(pointId))
                    {
                        pointFlagMap[pointId] |= FLAG_TRAVELBLANK;
                    }
                    else
                    {
                        pointFlagMap[pointId] = FLAG_TRAVELBLANK;
                    }
                }

                for (int j = 0; j < frames.Length; j++)
                {
                    LD.SetWorkingFrame(frames[j]);

                    // Get the frame size for this frame
                    FFrameSizeIn.GetValue(j, out tmp);
                    int frameSize = (int)tmp;
                    if (frameSize < 0)
                    {
                        frameSize = pointCount / Math.Abs(frameSize);
                    }
                    if (frameSize > pointBuffer.Length)
                    {
                        PrintStatusMessage("Too many points. Maximum number of points for each frame is: " + pointBuffer.Length);
                        frameSize = pointBuffer.Length;
                    }

                    // Create binSize many points
                    workingFrame           = new FrameEx();
                    workingFrame.NumPoints = frameSize;

                    FXIn.GetValuePointer(out countx, out px);
                    FYIn.GetValuePointer(out county, out py);

                    int flag;
                    for (int i = 0; i < frameSize; i++)
                    {
                        pointId = i + frameOffset;

                        pointBuffer[i] = new Point();
                        v = (int)(*(px + (pointId % countx)) * 8000);
                        pointBuffer[i].X = v;

                        v = (int)(*(py + (pointId % county)) * 8000);
                        pointBuffer[i].Y = v;

                        FColorIn.GetColor(pointId, out color);
                        //swapping r'n'b
                        var r = color.R;
                        color.R = color.B;
                        color.B = r;
                        pointBuffer[i].Color = color.Color.ToArgb();

                        if (pointFlagMap.TryGetValue(pointId, out flag))
                        {
                            if ((flag & FLAG_CORNER) > 0)
                            {
                                pointBuffer[i].VOtype = LD.PT_CORNER;
                            }
                            if ((flag & FLAG_TRAVELBLANK) > 0)
                            {
                                pointBuffer[i].VOtype |= LD.PT_TRAVELBLANK;
                                pointBuffer[i].Color   = 0;
                            }
                        }
                    }

                    // Get projection zone for this frame
                    FZoneIn.GetValue(j, out tmp);
                    workingFrame.PreferredProjectionZone = VMath.Zmod((int)(tmp - 1), 30);

                    // Is this a vector orientated frame?
                    FIsVectorFrameIn.GetValue(j, out tmp);
                    workingFrame.VectorFlag = tmp > 0 ? 1 : 0;

                    // Scan rate for this frame
                    FFrameScanRateIn.GetValue(j, out tmp);
                    workingFrame.ScanRate = (int)tmp;

                    // Set animation count
                    FAnimationCountIn.GetValue(j, out tmp);
                    workingFrame.AnimationCount = (int)tmp;

                    LD.WriteFrameFastEx(ref workingFrame, ref pointBuffer[0]);

                    frameOffset += frameSize;
                }
            }
            else
            {
                List <int> corners = new List <int>();

                for (int j = 0; j < frames.Length; j++)
                {
                    LD.SetWorkingFrame(frames[j]);

                    int numPoints = 0;
                    LD.ReadNumPoints(ref numPoints);

                    pointCount += numPoints;
                }

                FXOut.SliceCount              = pointCount;
                FYOut.SliceCount              = pointCount;
                FColorOut.SliceCount          = pointCount;
                FFrameSizeOut.SliceCount      = frames.Length;
                FFrameScanRateOut.SliceCount  = frames.Length;
                FIsVectorFrameOut.SliceCount  = frames.Length;
                FZoneOut.SliceCount           = frames.Length;
                FAnimationCountOut.SliceCount = frames.Length;

                for (int j = 0; j < frames.Length; j++)
                {
                    LD.SetWorkingFrame(frames[j]);

                    int frameSize = 0;
                    LD.ReadNumPoints(ref frameSize);
                    LD.ReadFrameEx(ref workingFrame, ref pointBuffer[0]);

                    for (int i = 0; i < frameSize; i++)
                    {
                        int slice = i + frameOffset;
                        FXOut.SetValue(slice, ((double)pointBuffer[i].X) / 8000.0);
                        FYOut.SetValue(slice, ((double)pointBuffer[i].Y) / 8000.0);
                        RGBAColor c = new RGBAColor();
                        c.Color = System.Drawing.Color.FromArgb(pointBuffer[i].Color);
                        FColorOut.SetColor(slice, c);

                        // Handle vector orientated flags
                        if ((pointBuffer[i].VOtype & LD.PT_CORNER) > 0)
                        {
                            corners.Add(slice);
                        }
                    }

                    FCornerOut.SliceCount = corners.Count;
                    for (int i = 0; i < corners.Count; i++)
                    {
                        FCornerOut.SetValue(i, corners[i]);
                    }

                    FFrameSizeOut.SetValue(j, frameSize);
                    FFrameScanRateOut.SetValue(j, workingFrame.ScanRate);
                    FIsVectorFrameOut.SetValue(j, workingFrame.VectorFlag != 0 ? 1.0 : 0.0);
                    FZoneOut.SetValue(j, workingFrame.PreferredProjectionZone + 1);
                    FAnimationCountOut.SetValue(j, workingFrame.AnimationCount);

                    frameOffset += frameSize;
                }
            }

            bool vdChanged   = PinsChanged(FVDPins);
            bool skewChanged = PinsChanged(FSkewPins);

            /*
             * bool scannerChanged = FActiveScannerIn.PinIsChanged;
             * if (scannerChanged)
             * {
             *      // Blank out all scanners
             *      LD.SetWorkingScanners(-1);
             *      LD.DisplayFrame(0);
             * }
             * int scannerFrameCount = Math.Max(frames.Length, FActiveScannerIn.SliceCount);
             */
            int scannerFrameCount = Math.Max(frames.Length, FWorkingTrackIn.SliceCount);

            for (int i = 0; i < scannerFrameCount; i++)
            {
                /*
                 * FActiveScannerIn.GetValue(i, out tmp);
                 * int scannerCode = (int) tmp;
                 * scannerCode = VMath.Clamp(scannerCode, -1, MAX_SCANNER_CODE);
                 * if (scannerCode == 0) scannerCode = 1; // 0 is illegal
                 * LD.SetWorkingScanners(scannerCode);
                 */
                FWorkingTrackIn.GetValue(i, out tmp);
                int trackCode = (int)tmp;
                LD.SetWorkingTracks(trackCode);

                LD.DisplayFrame(frames[i % frames.Length]);
                if (vdChanged)
                {
                    int[] arg = PinsAsArgumentList(FVDPins, i);
                    LD.DisplayObjectSettings(arg[0], arg[1], arg[2], arg[3], arg[4], arg[5], arg[6]);
                }
                if (skewChanged)
                {
                    int[] arg = PinsAsArgumentList(FSkewPins, i);
                    LD.DisplaySkew(4, arg[0], 0);
                }
            }

            /*
             * LD.SetWorkingScanners(-1);
             */
            LD.DisplayUpdate();
        }