Exemplo n.º 1
0
        private const int MAX_SCANNER_CODE = 1073741824;         // 2^30

        #endregion field declaration

        #region constructor/destructor

        public LD2000Node()
        {
            //the nodes constructor
            workingFrame = new FrameEx();
            pointBuffer  = new Point[ldMaxPoints];

            // vector display pins
            FVDPins = new DisplayPin[7];
            int i = 0;

            FVDPins[i].Name      = "Line Beginning Blanked Points";
            FVDPins[i].ArgPos    = 4;
            FVDPins[i].Min       = 1;
            FVDPins[i].Max       = 8;
            FVDPins[i++].Default = 3;
            FVDPins[i].Name      = "Line Beginning Anchor Points";
            FVDPins[i].ArgPos    = 0;
            FVDPins[i].Min       = 1;
            FVDPins[i].Max       = 8;
            FVDPins[i++].Default = 2;
            FVDPins[i].Name      = "Line Corner Anchor Points";
            FVDPins[i].ArgPos    = 1;
            FVDPins[i].Min       = 2;
            FVDPins[i].Max       = 10;
            FVDPins[i++].Default = 3;
            FVDPins[i].Name      = "Line Ending Blanked Points";
            FVDPins[i].ArgPos    = 5;
            FVDPins[i].Min       = 1;
            FVDPins[i].Max       = 8;
            FVDPins[i++].Default = 3;
            FVDPins[i].Name      = "Line Ending Anchor Points";
            FVDPins[i].ArgPos    = 2;
            FVDPins[i].Min       = 1;
            FVDPins[i].Max       = 8;
            FVDPins[i++].Default = 2;
            FVDPins[i].Name      = "Point Spacing Blanked Lines";
            FVDPins[i].ArgPos    = 6;
            FVDPins[i].Min       = 100;
            FVDPins[i].Max       = 4000;
            FVDPins[i++].Default = 500;
            FVDPins[i].Name      = "Point Spacing Visible Lines";
            FVDPins[i].ArgPos    = 3;
            FVDPins[i].Min       = 100;
            FVDPins[i].Max       = 4000;
            FVDPins[i++].Default = 250;

            FSkewPins              = new DisplayPin[1];
            i                      = 0;
            FSkewPins[i].Name      = "Color/Blanking Shift";
            FSkewPins[i].ArgPos    = 0;
            FSkewPins[i].Min       = 0;
            FSkewPins[i].Max       = 20;
            FSkewPins[i++].Default = 0;
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
0
 public static extern void ReadFrameStructEx(int frameNumber, ref FrameEx LDfr);
Exemplo n.º 4
0
 public static extern void ReadFrameEx(ref FrameEx LDfr, ref Point LDpt);
Exemplo n.º 5
0
 public static extern void WriteFrameFastEx(ref FrameEx SUPPLY_LDFrameEx, ref Point SUPPLY_LDpt_Array);