Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
ScanMethod.h
Go to the documentation of this file.
1#pragma once
5#include <gii/gen/Variable.h>
10#include <math/Types.h>
11#include <misc/qt/ConfigStore.h>
12
13namespace sf
14{
15
16// Forward definitions.
17class ProjectData;
18class CalibrationSet;
19class ProjectAnalysisPropertyPage;
20class ParamMappingPropertyPage;
21class ScanMethodPositionPropertyPage;
22class ScanMethodCalibrationPropertyPage;
23class ScanMethodAcquisitionPropertyPage;
24class ScanDirectivePropertyPage;
25class ClusterList;
26
28{
29 public:
34 {
35 Parameters(ProjectData* prj_data, const QString& method, const QString& area)
36 : _projectData(prj_data)
37 , _methodName(method)
38 , _areaName(area)
39 {}
40
42 QString _methodName;
43 QString _areaName;
44 };
45
49 explicit ScanMethod(const Parameters&);
50
54 ~ScanMethod() override;
55
60 {
62 dpiINDEXCOUNT = 0,
64 dpiINDEXDENS = 1,
66 dpiSCANDENS = 2,
68 dpiSCANLEN = 3,
70 dpiDENSMODE = 4,
72 dpiANGLE_A = 5,
74 dpiANGLE_B = 6,
76 dpiSURFACEANGLE_A = 7,
78 dpiSURFACEANGLE_B = 8,
80 dpiGATEMODE = 10,
82 dpiDEPTH = 23,
84 dpiDEPTHFACTOR = 24,
86 dpiLAST = 0x100,
87 };
88
93 void SetAreaName(const QString& name);
94
98 QString GetAreaName() const;
99
107
108 // Function called before a scan method is deleted.
109 virtual void DestroyFrame();
110
111 // Returns a stream to print error or no error information to std::cout.
112 virtual std::ostream& Cout();
113
136
142 bool Execute(ECommand cmd);
143
149
155
161 void SetIndexFracRange(double start, double stop);
162
166 int GetIndexCount() const;
167
171 int GetIndexStart() const;
172
176 int GetIndexStop() const;
177
181 int GetScanListIndex() const;
182
189
195
201
206
212
217 bool IsActivated() const;
218
223 bool DoSustain(const timespec&);
224
230
239 bool DoConvertPosition(gmi::AxesCoord& dest, const gmi::AxesCoord& src, bool to_focus) const;
240
250 bool DoGetIndexPos(gmi::AxesCoord& pos, int index, double frac, bool rect) const;
251
260 bool DoGetFocusPos(gmi::AxesCoord& dest, int index, double frac) const;
261
268 bool DoGetIndexVel(gmi::AxesCoord& dest, int index) const;
269
279 bool DoGetMeasureOffset(Vector3D& vector, int index, double frac, bool rect) const;
280
287 bool DoSetAcqParams(int index, double frac);
288
296
303
310
317
324
331
337
342 const Vector3D& GetScanOffset() const;
343
348 Vector3D GetOffset() const;
349
354
359
367 bool GetRefractionAngle(double& dest, double src, bool to_medium = true);
368
372 TDataFilterLinks& GetFilterLinks();
373
379 bool ExecuteFilters(TDataFilterEntry::EAction action = TDataFilterEntry::feaSTART);
380
384 const std::vector<int>& GetUsedDevices() const;
385
391
397 void SetAcqState(InformationServer::EState sel_state, InformationServer::EState unsel_state = InformationServer::issOff);
398
403 {
405 smsCFGERR = -2,
407 smsERROR = -1,
409 smsNOINIT = 0,
421 smsLASTENTRY
422 };
423
428
436 virtual void HandleCursorEvent(bool btn_down, Qt::KeyboardModifiers shift, int index, double frac) {}
437
441 static const char* GetStateName(EState);
442
446 static const char* GetCommandName(ECommand);
447
452
456 QString GetMethodName() const;
457
461 QString GetDirectiveText() const;
462
467
473
477 QString GetElementName();
478
482 QString GetToolName();
483
488
492 QString GetSettingsName() const;
493
497 std::string GetNamePrefix() const;
498
503
507 QString GetCalibrationSetName() const;
508
512 InformationTypes::IdVector& GetCalibrationIds();
513
517 std::string GetFilterConfigs();
518 //
522 Variable::PtrVector& GetLocalVars();
523
527 QWidget* GetFrame();
528
529 protected:
536
540 const IdInfo* getInfo(const std::string& name) const override;
541
545 bool getSetValue(const IdInfo* info, Value* value, Value::vector_type* params, bool flag_set) override;
546
552 virtual bool CreateFrame();
553
561 virtual bool ConvertPosition(gmi::AxesCoord& dest, const gmi::AxesCoord& src, bool to_focus) const = 0;
562
569
576 virtual void StateChange(EState prev, EState cur) = 0;
577
583 virtual bool Initialize() = 0;
584
589 virtual void Read(IniProfile* inifile) = 0;
590
595 virtual void Write(IniProfile* inifile) = 0;
596
601 virtual bool GetGenericInfoList(StringList&) = 0;
602
608 virtual bool Sustain(const timespec& ts);
609
616 virtual bool HandleCommand(ECommand cmd) = 0;
617
627 virtual bool GetIndexPos(gmi::AxesCoord& pos, int index, double frac, bool rect) = 0;
628
637 virtual bool GetFocusPos(gmi::AxesCoord& dest, int index, double frac) = 0;
638
646 virtual bool GetIndexVel(gmi::AxesCoord& dest, int index) = 0;
647
654 virtual bool GetTriggerValue(gmi::AxisValue& value) = 0;
655
662
670 virtual bool SetAcqParams(int index, double frac) = 0;
671
679
690 virtual bool GetMeasureOffset(Vector3D& vector, int index, double frac, bool rect);
691
697 bool FilterHandler(TDataFilterLink*, EFilterNotifyCode fnc);
698
699 // Refills the positions result.
701
702 // Returns true if the state was successfully set.
703 bool SetState(EState state);
704 // This function is called by a derived class to set its frame pointer.
705 void SetFrame(QWidget* frame);
706 // Returns the allocated controller.
708 // Clips a trigger value to a value which is allowed by the controller.
709 // Is to be used by property pages to fill in the correct values.
710 bool ClipTriggerValue(gmi::AxisValue& trigger_value);
711 // A derived classes uses this function to set the index count for the scan method initialization.
712 void SetIndexCount(int idx_count);
713 // Returns Offset used to create the local ID's with for exporting.
715
716 private:
720 void localVarEvent(Variable::EEvent event, const Variable& caller, Variable& link, bool same_inst);
721
728 bool LoadVariableSettingsHandler(long vid, Value& value);
729 // Handles an apply of ID mapping changes.
730 void HandleParamMappingApply(QObject*);
731
737 void ReadWriteConfig(bool rd);
738
743 void SetStatePriv(EState state);
744
745 ConfigStore FSaveState;
746 gmi::AxesCoord FScanStart;
747 gmi::AxesCoord FScanStop;
748 Vector3D FScanOffset;
749 const EState FState;
750 ECommand FCommand;
751 ProjectData* FProjectData;
752 QWidget* FFrame;
753 QString FMethodName;
754 std::string FNamePrefix;
755 int FScanIndexCount;
756 bool FActive;
757 bool FSustainSentry;
758 QString FElement;
759 QString FTool;
760 QString FSettings;
761 QString FDirectiveText;
762 bool FDirectiveEnabled;
763 ESystemPosition FDirectivePosition;
764 TDataFilterLinks FFilterLinks;
765 std::string FFilterConfigs;
766 ClusterList* FClusterList;
767 ResultData RPositions;
768 LocalVariable VPart;
769 LocalVariable VToolName;
770 LocalVariable VToolSerial;
771 LocalVariable VElementName;
772 LocalVariable VElementSerial;
773 LocalVariable VMaterialName;
774 LocalVariable VMaterialVelocity;
775 LocalVariable VVelocityMode;
776 LocalVariable VSettings;
777 LocalVariable VArea;
778 LocalVariable VMethod;
779 LocalVariable VCalibType;
780 LocalVariable VCalibSet;
781 LocalVariable VState;
782 LocalVariable VIndexCount;
783 LocalVariable VFracStart;
784 LocalVariable VFracStop;
785 LocalVariable VScanIndex;
786 Variable::PtrVector FLocalVars;
787 InformationTypes::IdVector FCalibrationIds;
788 const CalibrationSet* FCalibSet;
789 TVector<int> FUsedDevices;
791
792 friend ScanMethodPositionPropertyPage;
793 friend ParamMappingPropertyPage;
794 friend ProjectAnalysisPropertyPage;
795 friend ScanMethodCalibrationPropertyPage;
796 friend ScanMethodAcquisitionPropertyPage;
797 friend ScanDirectivePropertyPage;
798
799 // Declarations of static functions and data members to be able to create registered implementations.
801};
802
803inline const Vector3D& ScanMethod::GetScanOffset() const
804{
805 return FScanOffset;
806}
807
809{
810 return FLocalVars;
811}
812
813inline TDataFilterLinks& ScanMethod::GetFilterLinks()
814{
815 return FFilterLinks;
816}
817
818inline const std::vector<int>& ScanMethod::GetUsedDevices() const
819{
820 return FUsedDevices;
821}
822
824{
825 return FCalibrationIds;
826}
827
829{
830 return FFilterConfigs;
831}
832
833inline bool ScanMethod::GetMeasureOffset(Vector3D& vector, int index, double frac, bool rect)
834{
835 return false;
836}
837
838}// namespace sf
#define SF_DECL_IFACE(InterfaceType, ParamType, FuncName)
Declares a public static function in the class where it is used. Where: InterfaceType: Global typenam...
Definition TClassRegistration.h:71
Holds a single calibration set of parameters.
Definition CalibrationSets.h:31
Class to store application configuration. Uses the global application settings or a given ini-file.
Definition ConfigStore.h:16
EState
Enumerate for state of the info server.
Definition InformationServer.h:42
unsigned long long id_type
Type used for the identifying integer (64-bits).
Definition InformationBase.h:30
Class for reading and writing ini-profiles.
Definition IniProfile.h:17
Create a local variable by calling the protected constructor.
Definition Variable.h:947
Definition ProjectData.h:23
Object for scripts to interact with the inspection project.
Definition ProjectScriptObject.h:14
Dialog containing multiple property pages.
Definition qt/PropertySheetDialog.h:14
Class for creating and referencing global created data called result data. This class allows linking ...
Definition ResultData.h:20
Definition ScanMethod.h:28
bool ExecuteFilters(TDataFilterEntry::EAction action=TDataFilterEntry::feaSTART)
Execute the referenced filters.
const gmi::AxesCoord & GetScanVelocity() const
Gets the velocity for the scan method to move. Actually calls the scan binder method sf::ScanBinder::...
EState GetState() const
Gets the state of the instance.
bool getSetValue(const IdInfo *info, Value *value, Value::vector_type *params, bool flag_set) override
Overridden from base class sf::ProjectScriptObject.
const Variable & GetMediumVelocity() const
Gets the medium sound velocity system variable.
virtual std::ostream & Cout()
void LoadSystemSettings()
Loads the system setting associated with the scan method.
QString GetSettingsName() const
Gets the settings name.
ECalibrationType GetCalibrationType()
Gets the calibration type name.
gmi::Controller * GetController()
virtual bool GetTriggerValue(gmi::AxisValue &value)=0
Gets the axis used for triggering measurements or when the axis location is #sf::EAxisLocation::alNA ...
int GetIndexStop() const
Gets the clipped stop value of the set range.
gmi::EAxisLocation DoGetScanAxis() const
Gets the scan and index axis for position calculations. Calls the overridden GetScanAxis() method.
QString GetDirectiveText() const
Gets the directive text.
bool DoSustain(const timespec &)
Called by the inspection project to enable the derived class to do some background processing.
QString GetMethodName() const
Gets this methods name.
ConfigStore & GetSaveState()
Gets the config store for saving and restoring the state of a frame. It is probably in the projects i...
virtual bool GetFocusPos(gmi::AxesCoord &dest, int index, double frac)=0
Gets the focus position of specified index and scan fraction. Must be overridden in a derived class.
virtual bool SetAcqParams(int index, double frac)=0
Sets the project acquisition parameters/variables based on the passed index. Must be overloaded by a ...
virtual bool ConvertPosition(gmi::AxesCoord &dest, const gmi::AxesCoord &src, bool to_focus) const =0
Converts a physical position to or from a focus position using the scan's configuration.
std::string GetFilterConfigs()
Gets the comma separated string of filter configuration names.
Definition ScanMethod.h:828
bool DoInitialize()
Initializes the class after the constructor is called. Final virtual functions are only valid after f...
TDataFilterLinks & GetFilterLinks()
Gets the analysis filter links.
Definition ScanMethod.h:813
virtual void StateChange(EState prev, EState cur)=0
Is called when the current state changes for a derived class to act up on. Must be overridden by a de...
const IdInfo * getInfo(const std::string &name) const override
Overridden from base class sf::ProjectScriptObject.
virtual void Read(IniProfile *inifile)=0
Reads the settings from the passed inifile.
bool IsActivated() const
Check if the scan method was activated.
~ScanMethod() override
Virtual destructor for derived classes.
QString GetMaterialName()
Gets the material name.
ECommand GetCommand()
Gets the last Issued command.
void DoAddPropertyPages(PropertySheetDialog *sheet)
Calls AddPropertyPages if the state allows it.
ECommand
Available commands.
Definition ScanMethod.h:118
@ smcOFFSETCHANGE
Definition ScanMethod.h:134
@ smcEVALUATE
Definition ScanMethod.h:130
@ smcINIT
Definition ScanMethod.h:120
@ smcDEACTIVATE
Definition ScanMethod.h:124
@ smcSCAN
Definition ScanMethod.h:128
@ smcCHECK
Definition ScanMethod.h:126
@ smcACTIVATE
Definition ScanMethod.h:122
@ smcSTOP
Definition ScanMethod.h:132
virtual bool GetIndexPos(gmi::AxesCoord &pos, int index, double frac, bool rect)=0
Gets the axes position of specified index and scan fraction. Must be overridden in a derived class.
bool SetState(EState state)
static const char * GetStateName(EState)
Gets the state name of the given state value.
virtual ScriptLink * GetScriptLink()
Gets the script link when one is associated. Can be overridden by a derived class.
EDefaultParamIndex
Default parameter ID indices for derived scan methods.
Definition ScanMethod.h:60
bool DoCreateFrame()
Creates a scan method UI frame if possible. Calls the overridden CreateFrame() method.
bool GetRefractionAngle(double &dest, double src, bool to_medium=true)
Gets the refracted angle.
static const char * GetCommandName(ECommand)
Gets the command name of the given command value.
void DoWrite(IniEnvelope ini)
Writes the settings of the scan method. Calls eventually the overridden Write() method.
QString GetCalibrationSetName() const
Gets the calibration set name.
int GetIndexCount() const
Gets the amount of indices in the scan method.
EState
States of operation.
Definition ScanMethod.h:403
@ smsACTIVE
Definition ScanMethod.h:413
@ smsCHECKING
Definition ScanMethod.h:415
@ smsSCANNING
Definition ScanMethod.h:417
@ smsREADY
Definition ScanMethod.h:411
@ smsEVALUATING
Definition ScanMethod.h:419
bool DoGetIndexVel(gmi::AxesCoord &dest, int index) const
Gets the velocity calculated by the derived scan mode.
ProjectData * GetProjectData()
Gets the project this instance is part of.
bool DoGetTriggerValue(gmi::AxisValue &value) const
Gets the axis used for triggering measurements or when the axis location is #sf::EAxisLocation::alNA ...
int GetScanListIndex() const
Returns the scan list index of this instance in the project.
void SetAcqState(InformationServer::EState sel_state, InformationServer::EState unsel_state=InformationServer::issOff)
Sets the state on all acquisition devices.
void SetAreaName(const QString &name)
Changes the area name so it is saved by the project under this new name.
virtual bool GetIndexVel(gmi::AxesCoord &dest, int index)=0
Gets the velocity calculated by the derived scan mode. Must be overridden in a derived class.
bool DoConvertPosition(gmi::AxesCoord &dest, const gmi::AxesCoord &src, bool to_focus) const
Converts a physical position to or from a focus position using the scan's configuration....
virtual bool GetGenericInfoList(StringList &)=0
Gets the list of linked variables or results. Must be overridden in a derived class.
void SetIndexCount(int idx_count)
const std::vector< int > & GetUsedDevices() const
Gets the acquisition devices used.
Definition ScanMethod.h:818
void SetIndexFracRange(double start, double stop)
Sets the new scan range for defined surface.
bool DoGetIndexPos(gmi::AxesCoord &pos, int index, double frac, bool rect) const
Gets the axes position calculated by the derived scan mode. Actually calls the overridden GetIndexPos...
QString GetToolName()
Gets the tool name.
const ScanBinder::InfoBase * GetScanInfo() const
Gets the binder information of this scan method instance. Actually calls sf::ScanBinder::GetScanInfo(...
const Variable & GetMaterialVelocity() const
Gets the material sound velocity system variable.
bool DoGetFocusPos(gmi::AxesCoord &dest, int index, double frac) const
Gets the focus position calculated by the derived scan mode. Actually calls the overridden GetFocusPo...
bool GetScanStart(gmi::AxesCoord &ac) const
Gets the position coordinate where the project passes control to the scan method.
virtual bool GetMeasureOffset(Vector3D &vector, int index, double frac, bool rect)
Gets the vector caused by changing measurement offsets. This means the offset caused by the A-scan de...
Definition ScanMethod.h:833
virtual void HandleCursorEvent(bool btn_down, Qt::KeyboardModifiers shift, int index, double frac)
Can be overridden to handle cursor events when the scan is selected in the project.
Definition ScanMethod.h:436
const gmi::AxesCoord & GetScanAcceleration() const
Gets the acceleration for the scan method to move. Actually calls the scan binder method sf::ScanBind...
bool Execute(ECommand cmd)
Calls HandleCommand() after several checks.
int GetIndexStart() const
Gets the clipped start value of the set range.
bool DoGetMeasureOffset(Vector3D &vector, int index, double frac, bool rect) const
Gets the vector caused by changing measurement offsets. This means the offset caused by the A-scan de...
QString GetElementName()
Gets the element name.
bool IsCalibReady()
Checks if the calibration is complete.
virtual bool HandleCommand(ECommand cmd)=0
Handles the command given by Execute(). Must be overridden in a derived class.
void DoRead(IniEnvelope ini)
Reads the settings of the scan method. Calls eventually the overridden Read() method.
bool UpdatePositionsData()
QWidget * GetFrame()
Called by a derived class to get its UI frame pointer.
virtual void Write(IniProfile *inifile)=0
Writes the settings to the passed inifile.
virtual void DestroyFrame()
Variable::PtrVector & GetLocalVars()
Gets the local variables in a pointer vector.
Definition ScanMethod.h:808
bool FilterHandler(TDataFilterLink *, EFilterNotifyCode fnc)
Event handler for filter events which are passed to the scan method script.
QString GetAreaName() const
Gets the area name of the scan entry.
virtual bool Initialize()=0
Initializes the scan method. Must be overridden by a derived class.
bool DoSetAcqParams(int index, double frac)
Calls the overridden SetAcqParams() method on the derived class.
InformationTypes::id_type GetIdOffset()
bool ClipTriggerValue(gmi::AxisValue &trigger_value)
void SetFrame(QWidget *frame)
virtual gmi::EAxisLocation GetScanAxis()=0
Gets the scan and index axis for position calculations. Must be overloaded by a derived class.
bool GetScanStop(gmi::AxesCoord &ac) const
Gets the position where the scan method passes control to the project.
virtual bool Sustain(const timespec &ts)
Can be overloaded to do background processing.
ScanMethod(const Parameters &)
Constructor for passing general structure for derived classes create by the class factory.
virtual bool CreateFrame()
Creates a scan method UI frame if possible. Can be overloaded by a derived class.
const Vector3D & GetScanOffset() const
Gets the offset of the part to its programmed position.
Definition ScanMethod.h:803
Vector3D GetOffset() const
Gets the total offsets added.
bool GetDirectiveEnabled() const
Gets the flag weather the directive is enabled.
InformationTypes::IdVector & GetCalibrationIds()
Gets the calibration ids.
Definition ScanMethod.h:823
std::string GetNamePrefix() const
Gets the name prefix.
ESystemPosition GetDirectivePosition()
??
bool SaveSystemSettings()
Saves the system setting associated with the scan method.
bool Reinitialize()
When the state is ready the scan method can be reinitialize. After changes are made to the settings f...
virtual void AddPropertyPages(PropertySheetDialog *sheet)
Adds scan method specific property pages to the passed sheet. Can be overloaded by a derived class.
String list with optional object association and sorting.
Definition TStringList.h:12
Template for linking pointers of member function to Variable instances.
Definition VariableHandler.h:38
Value container class able to performing arithmetic functions.
Definition Value.h:19
EEvent
Events send to the handler set with sf::Variable::setHandler.
Definition VariableTypes.h:130
Class for creating and referencing global or local created parameters or settings called variables....
Definition Variable.h:16
All axis values in one structure accompanied by some handy manipulation methods.
Definition AxesCoord.h:13
Single position, speed or acceleration value of a specific axis.
Definition GmiTypes.h:174
Pure virtual class for implementation of motion controllers.
Definition Controller.h:13
#define _IPJ_CLASS
Definition ipj/iface/global.h:35
EAxisLocation
Enumeration of axis locations.
Definition GmiTypes.h:81
Definition Application.h:10
ESystemPosition
Fixed system dependent axis positions.
Definition ipj/iface/Namespace.h:297
ECalibrationType
Type to identify a scan area type.
Definition ipj/iface/Namespace.h:247
Structure used a base class for derived binder classes to store scan dependant information.
Definition ScanBinder.h:36
Mandatory structure for initialization of derived class.
Definition ScanMethod.h:34
QString _areaName
Mode for scanning.
Definition ScanMethod.h:43
QString _methodName
Holds the project data structure.
Definition ScanMethod.h:42
ProjectData * _projectData
Definition ScanMethod.h:41
Parameters(ProjectData *prj_data, const QString &method, const QString &area)
Definition ScanMethod.h:35
Used to create static lookup lists.
Definition ScriptObject.h:62