Exemplo n.º 1
0
        /// <summary>
        /// Sets the position of the galvo.
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        public virtual void SetPosition(double x, double y, bool async = false)
        {
            ConfigureTask(1);

            IsWriting = true;
            if (WriterTask.IsDone)
            {
                WriterTask.Start();
            }
            MCWriter.WriteSingleSample(false, new double[] { x, y });
            System.Threading.Thread.Sleep(10);
            IsWriting = false;
        }
Exemplo n.º 2
0
        public virtual void WriteScan(double[,] positions, bool async = true,
                                      string triggerSource            = null, DigitalEdgeStartTriggerEdge edge = DigitalEdgeStartTriggerEdge.Rising)
        {
            // Go to initial position. (before the scan starts);
            SetPosition(positions[0, 0], positions[0, 1]);

            // Confugyre the task and force recration of the task.
            ConfigureTask(positions.GetLength(1) * positions.GetLength(0), true);

            // If there is a trigger source then we are currently waiting to writer trigger.
            if (triggerSource != null)
            {
                WriterTask.Triggers.StartTrigger.ConfigureDigitalEdgeTrigger(triggerSource, edge);
                IsWaitingForWriteStartEvent = false;
                IsWriting = true;
            }
            else
            {
                IsWaitingForWriteStartEvent = true;
                IsWriting = false;
            }

            // define the start action.
            TotalScanTicks = positions.GetLength(1);

            MCWriter.WriteMultiSample(false, positions);
            //MCWriter.BeginWriteMultiSample(false, positions, (IAsyncResult rslt) =>
            //{
            //    //CallWriteScanEnd();
            //}, null);

            if (WriterTask.IsDone)
            {
                WriterTask.Start();
            }

            CallStartScanEvent();

            if (triggerSource != null)
            {
                CallStartScanEvent();
            }

            if (!async)
            {
                while (IsWriting || IsWaitingForWriteStartEvent)
                {
                    System.Threading.Thread.Sleep(10);
                }
            }
        }