예제 #1
0
 private void ioConnection_IOTransition(object sender, IOConnectionEventArgs e)
 {
     if (ConnectionEventCallback != null)
     {
         ConnectionEventCallback.Invoke(Enum_ConnectionEvent.STATECHANGED_IO, e);
     }
 }
예제 #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]);
                }
            }
        }
예제 #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();
            }
        }
예제 #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);
            }
        }
예제 #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;
        }
예제 #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);
            }
        }
예제 #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;
        }
예제 #8
0
 public void DisconnectAll()
 {
     DisconnectJob();
     DisconnectDevice();
     if (ConnectionEventCallback != null)
     {
         ConnectionEventCallback.Invoke(Enum_ConnectionEvent.DISCONNECTED_ALL, null);
     }
 }
예제 #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;
        }
예제 #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();
 }
예제 #11
0
 private void DisconnectIO()
 {
     if (ioConnection != null)
     {
         ioConnection.Disconnect();
         ioConnection = null;
     }
     if (ConnectionEventCallback != null)
     {
         ConnectionEventCallback.Invoke(Enum_ConnectionEvent.DISCONNECTED_IO, null);
     }
 }
예제 #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);
            }
        }
예제 #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);
     }
 }
예제 #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;
        }
예제 #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);
                    }
                }
            }
        }
예제 #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);
            }
        }
예제 #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);
            }
        }
예제 #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;
                }
            }
        }
예제 #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);
     }
 }
예제 #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);
            }
        }
예제 #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;
        }
예제 #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();
        }
예제 #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
예제 #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