Ejemplo n.º 1
0
 private void ioConnection_IOTransition(object sender, IOConnectionEventArgs e)
 {
     if (ConnectionEventCallback != null)
     {
         ConnectionEventCallback.Invoke(Enum_ConnectionEvent.STATECHANGED_IO, e);
     }
 }
Ejemplo n.º 2
0
        public void ConnectMultipleReport()
        {
            IAvpCollection snapshotStepCol = jobStep.FindByType("Step.Snapshot.1");

            for (int i = 0; i < snapshotStepCol.Count; i++)
            {
                if (allMultipleReport == null)
                {
                    allMultipleReport = new ReportConnection[4];
                }
                if (allMultipleReport[i] == null)
                {
                    allMultipleReport[i]            = new ReportConnection();
                    allMultipleReport[i].NewReport += receivedReport_NewReport;
                }

                allMultipleReport[i].Connect(vsDevice, i + 1);
                allMultipleReport[i].DropWhenBusy = false;
                allMultipleReport[i].FreezeMode   = ReportConnection.FreezeModeOptions.SHOW_ALL;

                allMultipleReport[i].DataRecordAdd("Snapshot1.BufOut");

                if (ConnectionEventCallback != null)
                {
                    ConnectionEventCallback.Invoke(Enum_ConnectionEvent.CONNECTED_REPORT, allMultipleReport[i]);
                }
            }
        }
Ejemplo n.º 3
0
        private void DisconnectJob()
        {
            try
            {
                if (vsDevice != null)
                {
                    if (vsDevice.IsAnyInspectionRunning)
                    {
                        vsDevice.StopAll();
                    }
                }

                if (jobStep != null)
                {
                    while (jobStep.Count > 0)
                    {
                        jobStep.Remove(1);
                    }
                    jobStep = null;
                }
                if (ConnectionEventCallback != null)
                {
                    ConnectionEventCallback.Invoke(Enum_ConnectionEvent.DISCONNECTED_JOB, null);
                }
            }
            catch
            {
                throw new NotImplementedException();
            }
        }
Ejemplo n.º 4
0
        public void ConnectReport()
        {
            try
            {
                if (allReport == null)
                {
                    allReport            = new ReportConnection();
                    allReport.NewReport += receivedReport_NewReport;
                }
                allReport.Connect(vsDevice);

                allReport.DropWhenBusy = false;
                allReport.FreezeMode   = ReportConnection.FreezeModeOptions.SHOW_ALL;

                allReport.DataRecordAdd("Snapshot1.BufOut");

                if (ConnectionEventCallback != null)
                {
                    ConnectionEventCallback.Invoke(Enum_ConnectionEvent.CONNECTED_REPORT, allReport);
                }
            }
            catch (Exception ex)
            {
                throw new NotImplementedException(ex.Message);
            }
        }
Ejemplo n.º 5
0
        public IOWorker(
            IDictionary <string, Channel> channels,
            IDictionary <string, Listener> listeners,
            WaterFlowManager incomingFlowManager,
            Options options,
            IncomingMessageDispatchCallback incomingMessageDispatchCallback,
            ConnectionEventCallback connectionEventCallback,
            LogCallback logCallback, LogEventArgs.LogLevel logLevel)
        {
            this.channels                        = channels;
            this.listeners                       = listeners;
            this.incomingFlowManager             = incomingFlowManager;
            this.options                         = options;
            this.incomingMessageDispatchCallback =
                incomingMessageDispatchCallback;
            this.connectionEventCallback = connectionEventCallback;
            this.logCallback             = logCallback;
            this.logLevel = logLevel;

            listenersForSelection = new Dictionary <Socket, Listener>();
            channelsForSelection  = new Dictionary <Socket, Channel>();

            blockingChannelsReadyForReading = new List <Channel>();
            blockingChannelsReadyForWriting = new List <Channel>();

            stopRequest = false;
        }
Ejemplo n.º 6
0
        private void vsDevice_OnXferProgress(int nState, int nStatus, string msg)
        {
            /*
             *  Download Started to VisionHawk1580EB
             *  FTP Connection established
             *  Copying files to device...
             *  Copying _visionhawkcm_4002_752x480_CMOS.cam...
             *  Job streamed to memory
             *  RAM Drive Created
             *  Avp downloaded to Device
             *  Loading job on device...
             *  Job Loaded
             *  Download Complete to VisionHawk1580EB
             */

            _downloadProgress += 0.1;

            if (ConnectionEventCallback != null)
            {
                Event_Progress ep = new Event_Progress();
                ep.progress = _downloadProgress;
                ep.message  = msg;
                ConnectionEventCallback.Invoke(Enum_ConnectionEvent.DOWNLOADING_JOB, ep);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="connCb">Callback for connection-related events. When called, this callback must not leak any exceptions.</param>
        /// <param name="msgCb">Callback for the reception of a message. When called, this callback must not leak any exceptions.</param>
        public AppLogic(ConnectionEventCallback connCb, Action msgCb)
        {
            m_exeFolder = AppDomain.CurrentDomain.BaseDirectory.TrimEnd('\\');

            m_logger = new Logger(m_exeFolder);

            m_connectionUiCallback      = connCb;
            m_messageReceivedUiCallback = msgCb;
        }
Ejemplo n.º 8
0
 public void DisconnectAll()
 {
     DisconnectJob();
     DisconnectDevice();
     if (ConnectionEventCallback != null)
     {
         ConnectionEventCallback.Invoke(Enum_ConnectionEvent.DISCONNECTED_ALL, null);
     }
 }
Ejemplo n.º 9
0
        private int m_taskId = 4120; // This is incremented to fabricate changing IDs in messages

        /// <summary>
        /// Constructor.
        /// </summary>
        public FakeAmqpClient(ConnectionEventCallback connCb, MessageReceivedCallback msgCb)
            : base(connCb, msgCb)
        {
            // Create timer to send messages periodically
            m_timer           = new System.Timers.Timer();
            m_timer.Elapsed  += M_timer_Elapsed;
            m_timer.Interval  = 4000; // unit: ms
            m_timer.AutoReset = true;
        }
Ejemplo n.º 10
0
 private void receivedReport_NewReport(object sender, ReportConnectionEventArgs e)
 {
     if (ConnectionEventCallback != null)
     {
         if (e.Report.Images.Count > 0)
         {
             ConnectionEventCallback.Invoke(Enum_ConnectionEvent.RECEIVED_IMAGE, e.Report);
         }
         ConnectionEventCallback.Invoke(Enum_ConnectionEvent.RECEIVED_REPORT, e.Report);
     }
     GC.Collect();
 }
Ejemplo n.º 11
0
 private void DisconnectIO()
 {
     if (ioConnection != null)
     {
         ioConnection.Disconnect();
         ioConnection = null;
     }
     if (ConnectionEventCallback != null)
     {
         ConnectionEventCallback.Invoke(Enum_ConnectionEvent.DISCONNECTED_IO, null);
     }
 }
Ejemplo n.º 12
0
        public void ConnectIO()
        {
            if (ioConnection == null)
            {
                ioConnection = new IOConnection();
                ioConnection.IOTransition += ioConnection_IOTransition;
            }
            ioConnection.Connect(vsDevice);

            // STATECHANGED_IO
            if (ConnectionEventCallback != null)
            {
                ConnectionEventCallback.Invoke(Enum_ConnectionEvent.CONNECTED_IO, ioConnection);
            }
        }
Ejemplo n.º 13
0
 private void vsCoordinator_OnDeviceDiscovered(VsDevice newDevice)
 {
     // When new camera detected
     if (newDevice.Name == _cameraName && vsDevice != newDevice)
     {
         vsDevice = newDevice;
         if (ConnectionEventCallback != null)
         {
             ConnectionEventCallback.Invoke(Enum_ConnectionEvent.DISCOVERED_CAMERA, newDevice);
         }
     }
     if (ConnectionEventCallback != null)
     {
         ConnectionEventCallback.Invoke(Enum_ConnectionEvent.DISCOVERED_NEW_CAMERA, newDevice);
     }
 }
Ejemplo n.º 14
0
        private void vsDevice_OnDownloadComplete(int nStatus)
        {
            if (!vsDevice.IsInspectionRunning())
            {
                vsDevice.StartAll();
            }
            if (ConnectionEventCallback != null)
            {
                Event_Progress ep = new Event_Progress();
                ep.progress = 1;
                ep.message  = "Download Completed";
                ConnectionEventCallback.Invoke(Enum_ConnectionEvent.DOWNLOADED_JOB, ep);
            }

            vsDevice.OnXferProgress     -= vsDevice_OnXferProgress;
            vsDevice.OnDownloadComplete -= vsDevice_OnDownloadComplete;
        }
Ejemplo n.º 15
0
        public void DownloadJob()
        {
            if (vsDevice == null || jobStep == null)
            {
                return;
            }

            if (vsDevice.IsAnyInspectionRunning)
            {
                vsDevice.StopAll();
            }

            if (vsDevice.DeviceClass == tagDEVCLASS.DEVCLASS_GIGE_VISION_SYSTEM || vsDevice.DeviceClass == tagDEVCLASS.DEVCLASS_SOFTWARE_EMULATED)
            {
                if (ConnectionEventCallback != null)
                {
                    vsDevice.Download(jobStep, true);

                    Event_Progress ep = new Event_Progress();
                    ep.progress = 1;
                    ep.message  = "Download Completed";
                    vsDevice.StartAll();
                    ConnectionEventCallback.Invoke(Enum_ConnectionEvent.DOWNLOADED_JOB, ep);
                }
            }
            else
            {
                try
                {
                    _downloadProgress            = 0;
                    vsDevice.OnXferProgress     += vsDevice_OnXferProgress;
                    vsDevice.OnDownloadComplete += vsDevice_OnDownloadComplete;

                    vsDevice.Download(jobStep, false);
                }
                catch (Exception e)
                {
                    if (ConnectionEventCallback != null)
                    {
                        ConnectionEventCallback.Invoke(Enum_ConnectionEvent.ERROR, e.Message);
                    }
                }
            }
        }
Ejemplo n.º 16
0
        public void Trigger(int virtualIO)
        {
            if (ioConnection == null)
            {
                ioConnection = new IOConnection();
            }
            if (!ioConnection.IsConnected())
            {
                ioConnection.Connect(vsDevice);
            }

            ioConnection.PointWrite(virtualIO, true);
            ioConnection.PointWrite(virtualIO, false);

            if (ConnectionEventCallback != null)
            {
                ConnectionEventCallback.Invoke(Enum_ConnectionEvent.TRIGGERED_IO, virtualIO);
            }
        }
Ejemplo n.º 17
0
        public void ConnectJob(string jobPath)
        {
            _jobPath = jobPath;


            DisconnectJob();

            if (jobStep == null)
            {
                jobStep = new JobStep();
            }

            jobStep.Load(_jobPath);

            if (ConnectionEventCallback != null)
            {
                ConnectionEventCallback.Invoke(Enum_ConnectionEvent.CONNECTED_JOB, jobStep);
            }
        }
Ejemplo n.º 18
0
        public void ConnectCamera(string cameraName)
        {
            if (_cameraName == cameraName || cameraName == "None")
            {
                return;
            }
            _cameraName = cameraName;

            // If camera already found
            foreach (VsDevice dev in vsCoordinator.Devices)
            {
                if (dev.Name == cameraName && vsDevice != dev)
                {
                    vsDevice = dev;
                    if (ConnectionEventCallback != null)
                    {
                        ConnectionEventCallback.Invoke(Enum_ConnectionEvent.DISCOVERED_CAMERA, dev);
                    }
                    return;
                }
            }
        }
Ejemplo n.º 19
0
 private void DisconnectReport()
 {
     if (allReport != null)
     {
         allReport.Disconnect();
         allReport.NewReport -= receivedReport_NewReport;
         allReport            = null;
     }
     if (allMultipleReport != null)
     {
         foreach (ReportConnection report in allMultipleReport)
         {
             report.Disconnect();
             report.NewReport -= receivedReport_NewReport;
         }
         allMultipleReport = null;
     }
     if (ConnectionEventCallback != null)
     {
         ConnectionEventCallback.Invoke(Enum_ConnectionEvent.CONNECTED_REPORT, null);
     }
 }
Ejemplo n.º 20
0
        private void DisconnectDevice()
        {
            if (vsDevice != null)
            {
                if (vsDevice.IsAnyInspectionRunning)
                {
                    vsDevice.StopAll();
                }
                if (vsDevice.IsConnected)
                {
                    vsDevice.Disconnect();
                }
            }

            vsDevice    = null;
            _cameraName = null;

            if (ConnectionEventCallback != null)
            {
                ConnectionEventCallback.Invoke(Enum_ConnectionEvent.DISCONNECTED_DEVICE, null);
            }
        }
Ejemplo n.º 21
0
        public IOWorker(
            IDictionary<string, Channel> channels, 
            IDictionary<string, Listener> listeners, 
            WaterFlowManager incomingFlowManager, 
            Options options, 
            IncomingMessageDispatchCallback incomingMessageDispatchCallback,
            ConnectionEventCallback connectionEventCallback, 
            LogCallback logCallback, LogEventArgs.LogLevel logLevel)
        {
            this.channels = channels;
            this.listeners = listeners;
            this.incomingFlowManager = incomingFlowManager;
            this.options = options;
            this.incomingMessageDispatchCallback =
                incomingMessageDispatchCallback;
            this.connectionEventCallback = connectionEventCallback;
            this.logCallback = logCallback;
            this.logLevel = logLevel;

            listenersForSelection = new Dictionary<Socket, Listener>();
            channelsForSelection = new Dictionary<Socket, Channel>();

            stopRequest = false;
        }
Ejemplo n.º 22
0
        public void ConnectSetup(Step rootStep)
        {
            if (vsDevice == null || jobStep == null)
            {
                if (ConnectionEventCallback != null)
                {
                    ConnectionEventCallback.Invoke(Enum_ConnectionEvent.ERROR, "ERROR: Device or Job not found!");
                }
                return;
            }
            if (setupManager == null)
            {
                setupManager = new SetupManager();
            }

            if (vsDevice.IsAnyInspectionRunning)
            {
                vsDevice.StopAll();
            }

            if (rootStep == null)
            {
                IAvpCollection inspStepCol = jobStep.FindByType("Step.Inspection.1");
                setupManager.RootStep = inspStepCol[1] as Step;
            }
            else
            {
                setupManager.RootStep = rootStep;
            }

            setupManager.OptionLayoutSet(SetupManagerLayoutOptions.ShowEverything, true);
            setupManager.OptionLayoutSet(SetupManagerLayoutOptions.ShowDatumGrid, false);
            setupManager.OptionLayoutSet(SetupManagerLayoutOptions.ShowStepTree, false);
            setupManager.ZoomAuto();
            setupManager.Acquire();
        }
Ejemplo n.º 23
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="connCb">Callback for connection-related events excluding connection failure.</param>
 /// <param name="msgCb">Callback for the reception of messages.</param>
 public AmqpClient(ConnectionEventCallback connCb, MessageReceivedCallback msgCb)
     : base(connCb, msgCb)
 {
     m_connectionHandler = new Thread(ConnectionHandlerProgram);
     m_connectionHandler.Start();
 } // AmqpClient
Ejemplo n.º 24
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="connCb">Callback for connection-related events excluding errors.</param>
 /// <param name="msgCb">Callback for the reception of messages.</param>
 protected AmqpClientBase(ConnectionEventCallback connCb, MessageReceivedCallback msgCb)
 {
     b_connectionEventCallback = connCb;
     b_messageReceivedCallback = msgCb;
 } // AmqpClientBase