Esempio n. 1
0
                /// <summary>
                /// Add a new turntable
                /// </summary>
                public ITurnTable AddTurnTable()
                {
                    var item = new TurnTable();

                    Add(item);
                    return(item);
                }
Esempio n. 2
0
        public override Sardauscan.Core.ScanData DoTask(Sardauscan.Core.ScanData source)
        {
            if (!HardwareAvailable)
            {
                throw new Exception(string.Format("HardWare missing : TURNTABLE:{0} LASER:{1} CAMERA:{2}", HardwarePresentTrace(TurnTable), HardwarePresentTrace(Laser), HardwarePresentTrace(Camera)));
            }

            double   RotationStep = (double)Math.Round(360.0 / (NumberOfGrab - 1), 2);
            ScanData ret          = new ScanData();

            UpdatePercent(0, ret);

            TurnTable.InitialiseRotation();
            Laser.TurnAll(false);
            int index = 0;

            for (double currentAngle = 0; currentAngle < 360f; currentAngle += RotationStep)
            {
                if (this.CancelPending)
                {
                    return(ret);
                }
                Bitmap imgoff = GetCapture();
                string path   = Path.Combine(Folder, string.Format("capture{0}.jpg", ++index, (int)currentAngle));
                imgoff.Save(path, System.Drawing.Imaging.ImageFormat.Jpeg);

                int percent = (int)((currentAngle / 360f) * 100f);
                UpdatePercent(percent, ret);
                TurnTable.Rotate(currentAngle, false);
                Thread.Sleep(1000);
            }

            return(null);
        }
Esempio n. 3
0
    private void Awake()
    {
        turnTable = GameObject.FindGameObjectWithTag("TurnTable").GetComponent <TurnTable>();

        if (turnTable.Toggle)
        {
            autoStatusText.text = "Auto On";
        }
        else
        {
            autoStatusText.text = "Auto Off";
        }
    }
Esempio n. 4
0
        protected int IAnimationMatrix = -1; // index of animation matrix

        /// <summary>
        /// Construct and initialize the class
        /// </summary>
        public TurntableShape(string path, IWorldPosition positionSource, ShapeFlags flags, TurnTable turntable, double startingY)
            : base(path, positionSource, flags)
        {
            Turntable = turntable;
            //Turntable.StartingY = (float)startingY;
            Turntable.TurntableFrameRate = SharedShape.Animations[0].FrameRate;
            animationKey = (Turntable.YAngle / (float)Math.PI * 1800.0f + 3600) % 3600.0f;
            for (var imatrix = 0; imatrix < SharedShape.Matrices.Length; ++imatrix)
            {
                if (SharedShape.MatrixNames[imatrix].Equals(turntable.Animations[0], StringComparison.OrdinalIgnoreCase))
                {
                    IAnimationMatrix = imatrix;
                    break;
                }
            }
            if (viewer.Simulator.Route.DefaultTurntableSMS != null)
            {
                string soundPath = viewer.Simulator.RouteFolder.SoundFile(viewer.Simulator.Route.DefaultTurntableSMS);
                if (File.Exists(soundPath))
                {
                    Sound = new SoundSource(viewer, WorldPosition.WorldLocation, SoundEventSource.Turntable, soundPath);
                    viewer.SoundProcess.AddSoundSources(this, new List <SoundSourceBase>()
                    {
                        Sound
                    });
                }
                else if (File.Exists(soundPath = viewer.Simulator.RouteFolder.ContentFolder.SoundFile(viewer.Simulator.Route.DefaultTurntableSMS)))
                {
                    Sound = new SoundSource(viewer, WorldPosition.WorldLocation, SoundEventSource.Turntable, soundPath);
                    viewer.SoundProcess.AddSoundSources(this, new List <SoundSourceBase>()
                    {
                        Sound
                    });
                }
                else
                {
                    Trace.WriteLine($"Turntable soundfile {soundPath} not found");
                }
            }
            for (var matrix = 0; matrix < SharedShape.Matrices.Length; ++matrix)
            {
                AnimateMatrix(matrix, animationKey);
            }

            MatrixExtension.Multiply(in XNAMatrices[IAnimationMatrix], in WorldPosition.XNAMatrix, out Matrix absAnimationMatrix);
            Turntable.ReInitTrainPositions(absAnimationMatrix);
        }
 private void Awake()
 {
     turnTable = GameObject.FindGameObjectWithTag("TurnTable").GetComponent <TurnTable>();
 }
Esempio n. 6
0
        public override ScanData DoTask(ScanData source)
        {
            if (!HardwareAvailable)
            {
                throw new Exception(string.Format("HardWare missing : TURNTABLE:{0} LASER:{1} CAMERA:{2}", HardwarePresentTrace(TurnTable), HardwarePresentTrace(Laser), HardwarePresentTrace(Camera)));
            }



            RotationStep = (double)Math.Round(TurnTable.MinimumRotation() + (15f - TurnTable.MinimumRotation()) * ((100 - Precision) / 100f), 2);


            Settings settings = Settings.Get <Settings>();

            CameraLoc.X = settings.Read(Settings.CAMERA, Settings.X, 0f);
            CameraLoc.Y = settings.Read(Settings.CAMERA, Settings.Y, 270f);
            CameraLoc.Z = settings.Read(Settings.CAMERA, Settings.Z, 70f);

            double thres = settings.Read(Settings.LASER_COMMON, Settings.MAGNITUDE_THRESHOLD, 10);
            int    min   = settings.Read(Settings.LASER_COMMON, Settings.MIN_WIDTH, 1);
            int    max   = settings.Read(Settings.LASER_COMMON, Settings.MAX_WIDTH, 60);


            ICameraProxy camera = Settings.Get <ICameraProxy>();

            ImageProcessor = new ImageProcessor(thres, min, max);

            SizeF tableSize = new SizeF(
                (float)settings.Read(Settings.TABLE, Settings.DIAMETER, 20f),
                (float)settings.Read(Settings.TABLE, Settings.HEIGHT, 15f)
                );

            Lasers = new List <LaserInfo>(LaserId.Length);
            for (int i = 0; i < LaserId.Length; i++)
            {
                Lasers.Add(new LaserInfo(LaserId[i], CameraLoc, tableSize));
            }

            ScanData ret = new ScanData();

            UpdatePercent(0, ret);
            int fadeTime = settings.Read(Settings.LASER_COMMON, Settings.FADE_DELAY, 100);

            TurnTable.InitialiseRotation();
            int laserCount = Lasers.Count;

            // Scan all laser location,
            for (double currentAngle = 0; currentAngle < 360f; currentAngle += RotationStep)
            {
                if (this.CancelPending)
                {
                    return(ret);
                }

                Laser.TurnAll(false);   // All laser off
                Thread.Sleep(fadeTime); // wait fade laser
                Bitmap imgoff = GetCapture();
                for (int laserIndex = 0; laserIndex < laserCount; laserIndex++)
                {
                    Laser.Turn(Lasers[laserIndex].Id, true);
                    Thread.Sleep(fadeTime); // wait fade laser
                    Bitmap imgon = GetCapture();
                    Laser.Turn(Lasers[laserIndex].Id, false);

                    List <PointF> laserloc = ImageProcessor.Process(imgoff, imgon, null);

                    Point3DList samplePoints = Lasers[laserIndex].MapPoints(laserloc, UseTexture ? imgoff : null, UseCorrectionMatrix);
                    PositionPostProcess(ref samplePoints, -Utils.DEGREES_TO_RADIANS(currentAngle));
                    ScanLine line = new ScanLine(laserIndex, samplePoints);
                    line.DisplayAsLine = true;
                    ret.Add(line);
                }
                int percent = (int)((currentAngle / 360f) * 100f);
                UpdatePercent(percent, ret);
                TurnTable.Rotate(currentAngle, false);
            }
            LineSort lineSort = new LineSort();

            ret = lineSort.Run(ret, CallerControl, this.Worker, this.WorkerArg);
            if (!string.IsNullOrEmpty(FileName))
            {
                string path = Path.Combine(Program.UserDataPath, FileName);
                ScanDataIO.Write(path, ret);
            }
            return(ret);
        }
Esempio n. 7
0
 public clsMIDIINPUT()
 {
     LeftTurnTable  = new TurnTable();
     RightTurnTable = new TurnTable();
     Xfader         = new XFader();
 }
 private void Awake()
 {
     turnTable = GameObject.FindGameObjectWithTag("TurnTable").GetComponent <TurnTable>();
     mesh      = GetComponent <MeshRenderer>();
 }
 /// <summary>
 /// Default ctor
 /// </summary>
 public TurnTableWithState(TurnTable junction, int position)
     : this()
 {
     Junction = junction;
     Position = position;
 }