internal VisionSensor( IDataRepository dataRepository, IErrorRepository errorRepository, ITcpCommand command) { this.Command = command; this.DataRepository = dataRepository; this.ErrorRepository = errorRepository; try { this.Sequencer = new CommandSequencer(dataRepository, command); this.AutoCommunicator = new AutoCommunicator(dataRepository, command); this.Sequencer.VerifyTargetJustAfterConnectionConfirmed(); } catch (ConnectionLostException ex) { this.Dispose(); throw; } this.AutoCommunicator.ImageAcquired += new ImageAcquiredEventHandler(this.MediateImageAcquiredEvent); this.AutoCommunicator.ResultUpdated += new ToolResultUpdatedEventHandler(this.MediateToolResultUpdatedEvent); errorRepository.ErrorStatusUpdated += new ErrorDetectedEventHandler(this.MediateErrorDetectedEvent); this.Sequencer.ProgramSettingsUpdated += new ProgramSettingsUpdatedEventHandler(this.MediateProgramSettingsUpdatedEvent); this.AutoCommunicator.ProgramSettingsUpdated += new ProgramSettingsUpdatedEventHandler(this.MediateProgramSettingsUpdatedEvent); }
internal void VerifyTargetJustAfterConnectionConfirmed() { int stateGetTimes = 0; do { ++stateGetTimes; this.CheckSensorStateAndMode(); CommandSequencer.DisconnectIfSensorStateIsHardToChange(stateGetTimes); }while (!this.IsSensorControllableStateAndMode()); this.AcquireTargetSensorVersion(); this.GetInitialSensorData(); }
private void CheckSensorStateAndMode() { this.AcquireSensorStateAndMode(); if (this.IsSensorUncorrectableMode()) { throw new ConnectionLostException("VisionSensor mode is not Application mode."); } if (this.IsSensorStateNeedsToBeWait()) { CommandSequencer.WaitASecond(); } if (!this.IsSensorStateCorrectable()) { return; } this.ChangeSensorToOperationState(); CommandSequencer.WaitASecond(); }
private void GetInitialSensorData() { ISensorCurrentSettingInformation currentSettingCounter = this.GetCurrentSettingCounter(); int settingGetTimes = 0; do { this._repository.Set(currentSettingCounter); ++settingGetTimes; CommandSequencer.DisconnectIfSensorSettingsAreHardlyStabilized(settingGetTimes); this.AcquireSystemSettings(); this.AcquireBankList(); this.AcquireActiveBankSettings(); currentSettingCounter = this.GetCurrentSettingCounter(); }while (this._repository.HasProgramChanged(currentSettingCounter)); if (!this.EnableEvent) { return; } this.ProgramSettingsUpdated((object)this, (ProgramSettingsUpdatedEventArgs) new ConcreteProgramSettingsUpdatedEventArgs()); }