Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
ProjectData.h
Go to the documentation of this file.
1#pragma once
6#include <ipj/iface/global.h>
9#include <misc/gen/Sustain.h>
10
11namespace sf
12{
13
14// Forward declarations.
15class DataFilterList;
16class CustomFields;
17class ScanEntry;
18
23{
24 public:
29
33 ~ProjectData() override;
34
38 void debug();
39
44
49
55 bool read(std::istream& is);
56
62 bool write(std::ostream& os);
63
68
73 void createFrame(QWidget* parent);
74
79
84 void setFrameSaveState(bool rd);
85
89 QString getStateName();
90
96
101 {
103 psNONE,
104
106 psABORTED,
108 psERROR,
110 psDISABLED,
111
113 psUNINITIALIZED,
115 psINITIALIZING,
117 psINITIALIZED,
119 psINITFAILED,
120
122 psREADY,
123
125 psPREPARING,
127 psPREPARED,
128
131 psTOOLCHANGED,
132
135 psAPPROACHED,
136
139 psCHECKED,
140
143 psSCANNED,
144
146 psDATASAVING,
148 psDATASAVED,
149
152 psEVALUATED,
153
155 psREPORTING,
157 psREPORTED,
158
161 psRETREATED,
162
165 psFINISHED,
166
168 psSUSPENDING,
170 psSUSPENDED,
171
174 psSTOPPED,
175
178 psMOVED,
179
181 psRESETTING,
183 psRESUMING,
184
186 psACCOMMODATING,
189
190 psLASTENTRY
191 };
192
197
203 bool start(unsigned index);
204
211 bool evaluate(unsigned index, int file_index = -1);
212
219
220 bool moveToQuery(int scan);
221
222 bool moveTo(int scan, int index, double frac = 0.0, bool rect = false);
230 bool activate(unsigned index);
231
236 bool suspend();
237
241 bool stop();
242
246 bool abort();
247
252 bool rotate(int scan_entry);
253
259
267 bool finalize(int lock = 0);
268
273 bool isFinalized() const;
274
280
285 bool canStart(int scan_entry);
286
291 bool canStop();
292
297 bool canAbort();
298
304
309 bool canRotate(int scan_entry);
310
315 bool canEvaluate(int scan_entry);
316
322 bool canFinalize(int lock = 0);
323
328 bool canMoveTo();
329
333 void clear();
334
340 IniEnvelope GetScanIni(QString scan_area);
341
347
353 bool isScanArea(const QString& name);
354
359 void removeScan(unsigned index);
360
366 void moveScan(unsigned src, unsigned dest);
367
373 void swapScan(unsigned idx1, unsigned idx2);
374
379 int indexOf(ScanEntry*) const;
380
386 int getScanListIndex(const ScanMethod* sm) const;
387
393 bool disableProject(bool disable);
394
400 bool storeFilterList(bool rd);
401
405 const TCalibrationSets& getCalibrationSets();
406
412
417 inline ScanEntry* getActiveScan();
418
423 int getActiveScanIndex();
424
430
435 ScanEntry* getSelectedScan();
436
442
447
452 void setScanBinderName(const QString& name);
453
458
464
470
474 std::string getNamePrefix();
475
479 QString getErrorText();
480
485
490 void setScanFrameParent(QWidget* parent);
491
495 DataFilterList* getFilterList();
496
500 QString getMediumName();
501
507
512
517
522 void setReportTemplate(const QString& templ);
523
529
536 void setPartProject(const PartProject* part_project);
537
542
546 void setPartInspection(const TPartInspection* part_inspection);
547
552
557 QWidget* getFrame();
558
564 ScanEntry* getScan(ssize_t index);
565
569 ssize_t getScanCount();
570
574 inline EState GetState();
575
579 QString GetStateName(int state);
580
584 QString getPart() const;
585
592 void setDirty(bool tf = true);
593
598 bool isDirty() const;
599
604
610 std::string getScanMethodName(ssize_t index);
611
615 TProjectFrame* GetProjectFrame();
616
621
622 protected:
627
633 bool sustain(const timespec& t);
634
640 bool process(const timespec& ts);
641
648 bool setError(const QString& error_text);
649
655 bool setState(EState state);
656
661 void attach(ScanEntry* entry);
662
667 void detach(ScanEntry* entry);
668
675 bool storeProfile(IniProfile& ini_profile, bool rd);
676
681 void storeConfig(bool rd);
682
688
692 const IdInfo* getInfo(const std::string& name) const override;
693
697 bool getSetValue(const IdInfo* info, Value* value, Value::vector_type* params, bool flag_set) override;
698
704
709 bool isDataSavingReady() const;
710
711 private:
715 enum : int
716 {
717 weDISABLED = 0,
718 weENABLED,
719 weEVENT
720 };
721
726 void setExports(bool var_export);
727
735 void SendCursorEvent(bool btn_dn, Qt::KeyboardModifiers shift, int index, double frac);
736
742 bool GetGenericInfoList(StringList& strings);
743
747 void UpdateScanStateChanges();
748
752 struct _IPJ_CLASS InformationVariables
753 {
754 LocalVariable vState;
755 LocalVariable vWaitForEvent;
756 LocalVariable vPartProject;
757 LocalVariable vPartInspection;
758 LocalVariable vMediumName;
759 CustomFields* Custom;
760
765 {
770 {
771 // Hook the handler for the mark related variables.
772 vPopIndex.setHandler(this);
773 vFraction.setHandler(this);
774 vIndex.setHandler(this);
775 vEvent.setHandler(this);
776 }
777
781 void variableEventHandler(EEvent, const Variable&, Variable&, bool) override;
782
783 ProjectData* ProjData{nullptr};
784 Value::int_type PopIndex{0};
785 Value::flt_type Fraction{0};
787 int Event{0};
788 bool Active{false};
793 } FCursor;
794 }* FVars;
795
796 QWidget* FFrame;
797 QWidget* FScanFrameParent;
798 TVector<ScanEntry*> FScanList;
799 PartProject* FPartProject;
800 bool FDirty;
801 int FActiveScanIndex;
802 int FPrevScanIndex;
803 int FQuitScanIndex;
804 int FDataFileIndex;
805 ScanMethod* ActiveScanMethod;
806 EState FState, FPrevState, FResumeState;
807 ElapseTimer FInitTimer;
808 QString FErrorText;
809 ElapseTimer FChangeTimer;
810 bool FShouldStop;
811 EState FEvalPreState;
812 ScanBinder* FScanBinder;
813 ConfigStore FSaveState;
814 std::string FNamePrefix;
815 std::string FNamePrefixCalibPre;
816 std::string FNamePrefixCalibPost;
817 Variable::PtrVector FLocalVars;
818 void VarEvent(Variable::EEvent, const Variable&, Variable&, bool);
819 TPartInspection* FPartInspection;
820 int FFinalized;
821 void HandleInspectionChange(const void*);
822 TCalibrationSets* FCalibSets;
823 void HandlePropertyPageApply(const void* sender);
824 ReportOptions FReportOptions;
825 QString FReportTemplate;
826 TVariableHandler<ProjectData> _variableHandler;//
827
828 friend class ScanEntry;
829 friend class ProjectDataPropertyPage;
831};
832
834{
835 return *FCalibSets;
836}
837
838inline QString ProjectData::getPart() const
839{
840 return FPartProject->getPart();
841}
842
843inline void ProjectData::setScanFrameParent(QWidget* parent)
844{
845 FScanFrameParent = parent;
846}
847
848inline ScanEntry* ProjectData::getScan(ssize_t index)
849{
850 return FScanList[index];
851}
852
854{
855 return GetStateName(GetState());
856}
857
859{
860 return FState;
861}
862
864{
865 if (FActiveScanIndex >= 0)
866 return getScan(FActiveScanIndex);
867 return nullptr;
868}
869
871{
872 return FActiveScanIndex;
873}
874
876{
877 int sel = getSelectedScanIndex();
878 if (sel >= 0)
879 return getScan(sel);
880 return nullptr;
881}
882
883}// namespace sf
Class to store application configuration. Uses the global application settings or a given ini-file.
Definition ConfigStore.h:16
Definition CustomFields.h:12
Timer for turning true when a certain amount of time has passed.
Definition ElapseTimer.h:12
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 PartProject.h:10
QString getPart() const
Gets the 'part' part.
Definition ProjectData.h:23
PartProject * getPartProject() const
Gets the part-project pointer of the current project.
void addPropertyPages(PropertySheetDialog *sheet)
Adds the project property pages to the given property sheet.
InformationTypes::id_type getScanMethodIdOffset()
Gets the scan method id-offset for derived scan methods. Scan methods use the id-offset to determine ...
bool canFinalize(int lock=0)
Checks if it is possible to 'finalize' at the current time. When lock is non-zero regardless force is...
void detach(ScanEntry *entry)
Called from ScanEntry instance to detach itself to this project.
ScanEntry * getSelectedScan()
Gets the selected scan entry pointer.
Definition ProjectData.h:875
void setPartInspection(const TPartInspection *part_inspection)
Sets the part-inspection of this project.
bool moveTo(int scan, int index, double frac=0.0, bool rect=false)
ConfigStore GetPartStateIni()
Gets an ini file descendant with screen position information.
bool setError(const QString &error_text)
Sets the error state and the SetState function to set the psERROR state. Called from process() to all...
TProjectFrame * GetProjectFrame()
Casts the FFrame pointer to a TProjectFrame.
bool isValidPart()
Check if the part this project data is referring to is valid.
void clear()
Clears the all scan entries of the current project.
bool initializeScans()
Initializes all scan methods.
IniEnvelope GetScanIni(QString scan_area)
Gets an ini file descendant with information about the scan area configuration.
QString getReportTemplate()
Gets the report template file.
void setScanBinderName(const QString &name)
Sets scan-binder name and so change the implementation.
bool canEvaluate(int scan_entry)
Checks if it is possible to 'Evaluate' at the current time.
int getActiveScanIndex()
Gets the active scan entry index.
Definition ProjectData.h:870
int getScanListIndex(const ScanMethod *sm) const
Gets scan method entry index in the scan list.
bool sustain(const timespec &t)
Handler set using the _sustainEntry.
EState GetState()
Gets the current state of the project data state machine.
Definition ProjectData.h:858
DataFilterList * getFilterList()
Gets the selected or used filter list. (same as global for now)
bool disableProject(bool disable)
Disables or enables project when other is running.
bool canAbort()
Checks if it is possible to 'Abort' at the current time.
void moveScan(unsigned src, unsigned dest)
Moves the scan area in the list from the given source to a destination index.
ssize_t getScanMethodCount()
Gets the amount of available scan methods.
double getScanProgress()
Gets the progress of the current active scan.
bool canRotate(int scan_entry)
Checks if it is possible to 'Rotate' at the current time.
TPartInspection * getPartInspection() const
Gets the part-inspection of this project.
int indexOf(ScanEntry *) const
Gets the index in the scan entry in the list.
bool isDataSavingReady() const
Checks is saving data is completed.
ProjectData()
Default constructor.
bool process(const timespec &ts)
Called from sustain.
void setDirty(bool tf=true)
Set or resets the dirty flag. Calls attached method of the onDirty closure. When dirty the project ca...
const ConfigStore & getConfigStore() const
Gets a fresh copy of the config store.
bool start(unsigned index)
Start scanning at specified index in the list of scans.
bool rotate(int scan_entry)
Starts rotating the scan axis if possible.
~ProjectData() override
Virtual overridden destructor.
bool moveToSysPos(ESystemPosition sp)
Makes the manipulator move to a predefined system position.
int getSelectedScanIndex()
Gets the selected scan entry index.
QString getErrorText()
Gets the last error text set.
void SetReportOptions(ReportOptions options)
Sets the report options of the project.
void swapScan(unsigned idx1, unsigned idx2)
Swaps to scan entries in the list between the 3 given indices.
const TCalibrationSets & getCalibrationSets()
Gets the calibration sets.
Definition ProjectData.h:833
bool storeFilterList(bool rd)
Read or writes the filter list file.
bool finalize(int lock=0)
Finalizes the project so it is locked for changes. When lock is non-zero regardless force is used....
bool abort()
Aborts the current active scan method immediately.
QWidget * getFrame()
Gets the projects frame.
QString getStateName()
Gets the name of the current state the project is in.
Definition ProjectData.h:853
bool shouldWaitForEvent()
Allows state machines to wait for a user event .
void debug()
Just for development and debugging.
bool stop()
Signals a stops to the current active scan method.
const IdInfo * getInfo(const std::string &name) const override
Overridden from base class ProjectScriptObject.
ssize_t getScanCount()
Gets the amount of scans in the current scan plan list.
QWidget * getScanFrameParent()
Gets the parent for each scan area frame.
bool isScanArea(const QString &name)
Gets if the given scan area name exists.
void addModulePropertyPages(PropertySheetDialog *sheet)
Add the module property pages from this project to the given property sheet.
void attach(ScanEntry *entry)
Called from ScanEntry instance to attach itself to this project.
void setPartProject(const PartProject *part_project)
Assigment clears the scan list and sets the part name. This must be done before this instance can be ...
bool read(std::istream &is)
Reads the project from the stream.
ScanEntry * getActiveScan()
Gets the active scan.
Definition ProjectData.h:863
QString GetStateName(int state)
Gets the state-machines's name of the given state.
bool isDirty() const
Get the dirty flag.
bool getSetValue(const IdInfo *info, Value *value, Value::vector_type *params, bool flag_set) override
Overridden from base class ProjectScriptObject.
bool activate(unsigned index)
Activates the scan method. This makes the mode exports its variables. Only one scan method is activat...
ReportOptions getReportOptions()
Gets the report options of the project.
bool storeProfile(IniProfile &ini_profile, bool rd)
Reads or writes all project data to or from the given ini-profile instance.
bool setState(EState state)
Sets the new state.
bool isFinalized() const
Checks if the project is finalized.
bool evaluate(unsigned index, int file_index=-1)
Starts evaluating.
bool write(std::ostream &os)
Writes the project information to the output stream.
QString getScanBinderName()
Gets current scan-binder name.
void createFrame(QWidget *parent)
Creates the frame and sets the parent. When the frame exists this function is ignored.
void setFrameSaveState(bool rd)
Stores the frames state.
bool canStop()
Checks if it is possible to 'Stop' at the current time.
InformationTypes::id_type getScanBinderIdOffset()
Gets the scan method ID offset for the derived scan binder. The scan binder uses the id-offset to det...
TSustain< ProjectData > _sustainEntry
Hooks the sustain function into the sustain interface.
Definition ProjectData.h:626
void removeScan(unsigned index)
Removes the scan at the given index.
bool canSuspend()
Checks if it is possible to 'Suspend' at the current time.
bool isRotating()
Checks iof the rotating axis is rotating currently.
EState
Project states in the machine.
Definition ProjectData.h:101
@ psSTOPPING
Definition ProjectData.h:173
@ psTOOLCHANGING
Definition ProjectData.h:130
@ psFINISHING
Definition ProjectData.h:164
@ psCHECKING
Definition ProjectData.h:138
@ psACCOMMODATED
Definition ProjectData.h:188
@ psSCANNING
Definition ProjectData.h:142
@ psEVALUATING
Definition ProjectData.h:151
@ psMOVING
Definition ProjectData.h:177
@ psAPPROACHING
Definition ProjectData.h:134
@ psRETREATING
Definition ProjectData.h:160
bool canStart(int scan_entry)
Checks if it is possible to 'Start' at the current time.
void setReportTemplate(const QString &templ)
Sets thew report template file.
bool canInitialize()
Checks if it is possible to 'Initialize' at the current time.
bool canMoveTo()
Checks if the MoveTo function can be executed successfully.
ScanBinder * GetScanBinder()
Gets the Scan binder derived instance pointer of the implementation.
bool initialize()
Initializes or reinitializes the project binder and all its scans.
bool moveToQuery(int scan)
ScanEntry * addScan()
Gets pointer to a new created scan entry instance.
bool suspend()
Tries to signal the current scan to hold.
std::string getScanMethodName(ssize_t index)
Gets the name of scan method at the given index.
void destroyFrame()
Destroys the frame.
std::string getNamePrefix()
Gets the name prefix of the exported parameters.
TClosure< void, void * > onDirty
Closure method to notify changes on the dirty flag. The attached handler is called when a scan of the...
Definition ProjectData.h:528
void setScanFrameParent(QWidget *parent)
Sets the parent for the scan methods frame.
Definition ProjectData.h:843
ScanEntry * getScan(ssize_t index)
Gets the scan entry pointer of the given index.
Definition ProjectData.h:848
bool startDataSaving()
Initiates the start of storing data.
void storeConfig(bool rd)
Reads or writes the module configuration information.
QString getMediumName()
Gets the medium name of the project like 'water'.
QString getPart() const
Gets the part name of the loaded project.
Definition ProjectData.h:838
Object for scripts to interact with the inspection project.
Definition ProjectScriptObject.h:14
Dialog containing multiple property pages.
Definition qt/PropertySheetDialog.h:14
Abstract base class for implementing scan binders.
Definition ScanBinder.h:30
Definition ScanEntry.h:13
Definition ScanMethod.h:28
Definition CalibrationSets.h:117
Encapsulates the std::function() template.
Definition TClosure.h:14
Definition PartInspection.h:11
String list with optional object association and sorting.
Definition TStringList.h:12
Template to make the sustain system call a class method regularly.
Definition Sustain.h:184
Template for linking pointers of member function to Variable instances.
Definition VariableHandler.h:38
Counted vector having additional methods and operators for ease of usage. This template class extends...
Definition TVector.h:20
Value container class able to performing arithmetic functions.
Definition Value.h:19
double flt_type
Type used internally for storing floating point value.
Definition Value.h:28
int64_t int_type
Type used internally for storing integers.
Definition Value.h:24
Base class used for giving a Variable instance access to a member functions of a derived class....
Definition VariableHandler.h:14
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
#define _IPJ_CLASS
Definition ipj/iface/global.h:35
Definition Application.h:10
ESystemPosition
Fixed system dependent axis positions.
Definition ipj/iface/Namespace.h:297
TStrings< std::string > strings
Vector of std::strings with additional functionality.
Definition TStrings.h:193
QFlags< EReportOption > ReportOptions
Reporting option flags.
Definition ipj/iface/Namespace.h:345
Holds the custom variable list.
Definition ProjectData.h:765
Variable vFraction
Variable for synchronising the data members with when they exist.
Definition ProjectData.h:791
Variable vEvent
Variable for synchronising the data members with when they exist.
Definition ProjectData.h:790
Variable vIndex
Variable for synchronising the data members with when they exist.
Definition ProjectData.h:792
void variableEventHandler(EEvent, const Variable &, Variable &, bool) override
Overridden method from base class sf::VariableHandler.
DataCursor()
Initializing constructor.
Definition ProjectData.h:769
Variable vPopIndex
Definition ProjectData.h:789
Used to create static lookup lists.
Definition ScriptObject.h:62