00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "stdafx.h"
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 #include "ippdme/Checker/ippCommandChecker.h"
00049 #include "ippdme/world.h"
00050
00051 #include "ippdme/Command/commands.h"
00052 #include "ippdme/ippErrorNameType.h"
00053 #include "ippdme/assert.h"
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078 #ifdef _DEBUG
00079 #define new DEBUG_NEW
00080 #undef THIS_FILE
00081 static char THIS_FILE[] = __FILE__;
00082 #endif
00083
00084 #define CHECKER_ENUMERATION \
00085 CHECKER_ENUM(CHECKER_OK ,GenericError ,"OK") \
00086 CHECKER_ENUM(AXIS_DIRECTION_VECTOR_HAS_ZERO_LENGTH ,VectorHasNoNorm ,"AXIS DIRECTION VECTOR HAS ZERO LENGTH")\
00087 CHECKER_ENUM(BAD_ERROR_NUMBER ,ArgumentOutOfRange ,"BAD ERROR NUMBER")\
00088 CHECKER_ENUM(CAN_NOT_CHANGE_TOOL_TO_UNDEFTOOL ,ToolNotDefined ,"CAN NOT CHANGE TOOL TO UNDEFTOOL")\
00089 CHECKER_ENUM(CAN_NOT_ENUMALLPROP_NOTOOL_PTMEASPAR ,IllegalCommand ,"CAN NOT ENUMALLPROP NOTOOL PTMEASPAR")\
00090 CHECKER_ENUM(CAN_NOT_ENUMALLPROP_UNDEFTOOL_GOTOPAR ,ToolNotDefined ,"CAN NOT ENUMALLPROP UNDEFTOOL GOTOPAR")\
00091 CHECKER_ENUM(CAN_NOT_ENUMALLPROP_UNDEFTOOL_PTMEASPAR ,ToolNotDefined ,"CAN NOT ENUMALLPROP UNDEFTOOL PTMEASPAR")\
00092 CHECKER_ENUM(CAN_NOT_ENUMPROP_NOTOOL_PTMEASPAR ,IllegalCommand ,"CAN NOT ENUMPROP NOTOOL PTMEASPAR")\
00093 CHECKER_ENUM(CAN_NOT_ENUMPROP_UNDEFTOOL_GOTOPAR ,ToolNotDefined ,"CAN NOT ENUMPROP UNDEFTOOL GOTOPAR")\
00094 CHECKER_ENUM(CAN_NOT_ENUMPROP_UNDEFTOOL_PTMEASPAR ,ToolNotDefined ,"CAN NOT ENUMPROP UNDEFTOOL PTMEASPAR")\
00095 CHECKER_ENUM(CAN_NOT_GETPROP_PTMEASPARS_OF_NOTOOL ,IllegalCommand ,"CAN NOT GETPROP PTMEASPARS OF NOTOOL")\
00096 CHECKER_ENUM(CAN_NOT_GETPROP_UNDEFTOOL ,ToolNotDefined ,"CAN NOT GETPROP UNDEFTOOL")\
00097 CHECKER_ENUM(CAN_NOT_GETPROPE_PTMEASPARS_OF_NOTOOL ,IllegalCommand ,"CAN NOT GETPROPE PTMEASPARS OF NOTOOL")\
00098 CHECKER_ENUM(CAN_NOT_GETPROPE_UNDEFTOOL ,ToolNotDefined ,"CAN NOT GETPROPE UNDEFTOOL")\
00099 CHECKER_ENUM(CAN_NOT_GOTO_USING_UNDEFTOOL ,IllegalCommand ,"CAN NOT GOTO USING UNDEFTOOL")\
00100 CHECKER_ENUM(CAN_NOT_PTMEAS_USING_NOTOOL ,IllegalCommand ,"CAN NOT PTMEAS USING NOTOOL")\
00101 CHECKER_ENUM(CAN_NOT_PTMEAS_USING_UNDEFTOOL ,ToolNotDefined ,"CAN NOT PTMEAS USING UNDEFTOOL")\
00102 CHECKER_ENUM(CAN_NOT_REQUALIFY_NOTOOL ,IllegalCommand ,"CAN_NOT_REQUALIFY_NOTOOL")\
00103 CHECKER_ENUM(CAN_NOT_REQUALIFY_UNDEFTOOL ,ToolNotDefined ,"CAN_NOT_REQUALIFY_UNDEFTOOL")\
00104 CHECKER_ENUM(CAN_NOT_SCAN_USING_NOTOOL ,IllegalCommand ,"CAN NOT SCAN USING NOTOOL")\
00105 CHECKER_ENUM(CAN_NOT_SCAN_USING_UNDEFTOOL ,ToolNotDefined ,"CAN NOT SCAN USING UNDEFTOOL")\
00106 CHECKER_ENUM(CAN_NOT_SET_TOOL_TO_UNDEFTOOL ,ToolNotDefined ,"CAN NOT SET TOOL TO UNDEFTOOL")\
00107 CHECKER_ENUM(CAN_NOT_SETPROP_PTMEASPARS_OF_NOTOOL ,IllegalCommand ,"CAN NOT SETPROP PTMEASPARS OF NOTOOL")\
00108 CHECKER_ENUM(CAN_NOT_SETPROP_UNDEFTOOL ,ToolNotDefined ,"CAN NOT SETPROP UNDEFTOOL")\
00109 CHECKER_ENUM(DAEMON_TO_STOP_DOES_NOT_EXIST ,DaemonDoesNotExist ,"DAEMON TO STOP DOES NOT EXIST")\
00110 CHECKER_ENUM(DIRECTION_VECTOR_HAS_ZERO_LENGTH ,VectorHasNoNorm ,"DIRECTION VECTOR HAS ZERO LENGTH")\
00111 CHECKER_ENUM(DIS_ARGUMENT_MUST_BE_POSITIVE ,BadProperty ,"DIS ARGUMENT MUST BE POSITIVE")\
00112 CHECKER_ENUM(FIRST_VECTOR_NOT_NORMALIZED ,IncorrectArguments ,"FIRST VECTOR NOT NORMALIZED")\
00113 CHECKER_ENUM(MUST_STOP_EXISTING_DAEMON_BEFORE_STARTING_ANOTHER,DaemonAlreadyExists, "MUST STOP EXISTING DAEMON BEFORE STARTING ANOTHER")\
00114 CHECKER_ENUM(NOT_HOMED_CAN_NOT_EXECUTE_COMMAND ,IllegalCommand ,"NOT HOMED CAN NOT EXECUTE COMMAND")\
00115 CHECKER_ENUM(RADIUS_MUST_BE_PERPENDICULAR_TO_NORMAL ,IllegalCommand ,"RADIUS MUST BE PERPENDICULAR TO NORMAL")\
00116 CHECKER_ENUM(RADIUS_MUST_HAVE_POSITIVE_LENGTH ,IncorrectArguments ,"RADIUS MUST HAVE POSITIVE LENGTH")\
00117 CHECKER_ENUM(READINESS_ABORTED_CAN_NOT_EXECUTE_COMMAND ,UseClearAllErrorsToCont ,"READINESS ABORTED CAN NOT EXECUTE COMMAND")\
00118 CHECKER_ENUM(READINESS_ERRED_CAN_NOT_EXECUTE_COMMAND ,UseClearAllErrorsToCont ,"READINESS ERRED CAN NOT EXECUTE COMMAND")\
00119 CHECKER_ENUM(SCAN_POINT_MUST_BE_IN_WORK_VOLUME ,ArgumentOutOfRange ,"SCAN POINT MUST BE IN WORK VOLUME")\
00120 CHECKER_ENUM(SECOND_VECTOR_NOT_NORMALIZED ,IncorrectArguments ,"SECOND VECTOR NOT NORMALIZED")\
00121 CHECKER_ENUM(START_POINT_MUST_DIFFER_FROM_DIRECTION_POINT,IncorrectArguments ,"START POINT MUST DIFFER FROM DIRECTION POINT")\
00122 CHECKER_ENUM(START_POINT_MUST_DIFFER_FROM_END_POINT ,IncorrectArguments ,"START POINT MUST DIFFER FROM END POINT")\
00123 CHECKER_ENUM(START_POINT_MUST_NOT_BE_ON_CYLINDER_AXIS ,IncorrectArguments ,"START POINT MUST NOT BE ON CYLINDER AXIS")\
00124 CHECKER_ENUM(TARGET_POINT_OUT_OF_WORK_VOLUME ,TargetPosOutOfMachVol ,"TARGET POINT OUT OF WORK VOLUME")\
00125 CHECKER_ENUM(THETA_MUST_NOT_BE_NEGATIVE_OR_MORE_THAN_180 ,ThetaOutOfRange ,"THETA MUST NOT BE NEGATIVE OR MORE THAN 180")\
00126 CHECKER_ENUM(TIME_ARGUMENT_MUST_NOT_BE_LESS_THAN_A_TENTH ,BadProperty ,"TIME ARGUMENT MUST NOT BE LESS THAN A TENTH")\
00127 CHECKER_ENUM(UNKNOWN_TOOL ,ToolNotFound ,"UNKNOWN TOOL")\
00128
00129
00130 ippErrorNameType ippCommandCheckerBase::getIppErr(ippCheckerErrorId code)
00131 {
00132 switch(code){
00133 #define CHECKER_ENUM(enumValue,IPPError,c) case enumValue: return IPPError;
00134 CHECKER_ENUMERATION
00135 #undef CHECKER_ENUM
00136 }
00137 return GenericError;
00138 }
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164 std::string ippCommandCheckerBase::getErrorMessageString() const
00165 {
00166 std::string error_string;
00167 if ((_commandName > -1) && (_commandName < ippCOMMANDNAMETYPE_MAXIMUM)) {
00168
00169 error_string.append(getCommandNameString(_commandName));
00170 error_string.append(" : ");
00171 }
00172
00173 switch(_errorCode){
00174 #define CHECKER_ENUM(x,b,c) case x: error_string.append(c); break;
00175 CHECKER_ENUMERATION
00176 #undef CHECKER_ENUM
00177 }
00178
00179 return error_string.c_str();
00180 }
00181
00182 ippCommandCheckerBase::ippCommandCheckerBase()
00183 {
00184 }
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199 void ippCommandChecker::checkAbortE(
00200 ippCommandConstPtr aCommand
00201 )
00202 {
00203
00204 }
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222 void ippCommandChecker::checkAlignPart( ippCommandConstPtr aCommand)
00223 {
00224 if (!(_world->getIsHomed())) {
00225 _errorCode = NOT_HOMED_CAN_NOT_EXECUTE_COMMAND;
00226 }
00227 }
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253 void ippCommandChecker::checkAlignTool( ippCommandConstPtr aCommand)
00254 {
00255 const ippAlignToolCommand* theAlign = static_cast<const ippAlignToolCommand*>(aCommand.get());
00256
00257 double i;
00258 double j;
00259 double k;
00260
00261
00262 i = theAlign->getVector1i();
00263 j = theAlign->getVector1j();
00264 k = theAlign->getVector1k();
00265 if (fabs(sqrt((i*i)+(j*j)+(k*k)) - 1.0) > IPP_NORMAL_ERROR)
00266 _errorCode = FIRST_VECTOR_NOT_NORMALIZED;
00267 if ((_errorCode == CHECKER_OK) && (theAlign->getHas2()))
00268 {
00269 i = theAlign->getVector2i();
00270 j = theAlign->getVector2j();
00271 k = theAlign->getVector2k();
00272 if (fabs(sqrt((i*i)+(j*j)+(k*k)) - 1.0) > IPP_NORMAL_ERROR)
00273 _errorCode = SECOND_VECTOR_NOT_NORMALIZED;
00274 }
00275 if ((_errorCode == CHECKER_OK) && (!(_world->getIsHomed())))
00276 _errorCode = NOT_HOMED_CAN_NOT_EXECUTE_COMMAND;
00277 }
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295 void ippCommandChecker::checkCenterPart( ippCommandConstPtr aCommand)
00296 {
00297 if (!_world->getIsHomed()) {
00298 _errorCode = NOT_HOMED_CAN_NOT_EXECUTE_COMMAND;
00299 }
00300 }
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327 void ippCommandChecker::checkChangeTool( ippCommandConstPtr aCommand)
00328 {
00329 const ippChangeToolCommand * theChange = static_cast<const ippChangeToolCommand *>(aCommand.get());
00330
00331 if (strcmp("UnDefTool", theChange->getToolName()) == 0) {
00332 _errorCode = CAN_NOT_CHANGE_TOOL_TO_UNDEFTOOL;
00333 } else if (_world->getTools()->findTool(theChange->getToolName()).get() == NULL) {
00334 _errorCode = UNKNOWN_TOOL;
00335 }
00336 }
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352 void ippCommandChecker::checkClearAllErrors( ippCommandConstPtr aCommand)
00353 {
00354
00355 }
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371 void ippCommandChecker::checkDisableUser( ippCommandConstPtr aCommand)
00372 {
00373
00374 }
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390 void ippCommandChecker::checkEnableUser( ippCommandConstPtr aCommand)
00391 {
00392
00393 }
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409 void ippCommandChecker::checkEndSession( ippCommandConstPtr aCommand)
00410 {
00411
00412 }
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442 typedef boost::intrusive_ptr<ippEnumAllPropCommand> ippEnumAllPropCommandPtr;
00443 typedef boost::intrusive_ptr<const ippEnumAllPropCommand> ippEnumAllPropCommandConstPtr;
00444
00445 void ippCommandChecker::checkEnumAllProp(ippCommandConstPtr aCommand)
00446 {
00447 const ippEnumAllPropCommand* theEnum =
00448 static_cast<const ippEnumAllPropCommand*>(aCommand.get());
00449
00450 ippKToolPtr theTool;
00451
00452 if (theEnum->getProp().getKey1() == Tool){
00453 theTool = _world->getTools()->getActiveTool();
00454
00455 } else if (theEnum->getProp().getKey1() == FoundTool) {
00456 theTool = _world->getTools()->getFoundTool();
00457 } else{
00458 theTool = NULL;
00459 }
00460 if (theTool && (theTool == _world->getTools()->getUnDefTool()))
00461 {
00462 if (theEnum->getProp().getNumberKeys() > 1)
00463 {
00464 if (theEnum->getProp().getKey2() == PtMeasPar)
00465 _errorCode = CAN_NOT_ENUMALLPROP_UNDEFTOOL_PTMEASPAR;
00466 else
00467 _errorCode = CAN_NOT_ENUMALLPROP_UNDEFTOOL_GOTOPAR;
00468 }
00469 }
00470 else if (theTool && (theTool == _world->getTools()->getNoTool()))
00471 {
00472 if ((theEnum->getProp().getNumberKeys() > 1) && (theEnum->getProp().getKey2() == PtMeasPar))
00473 _errorCode = CAN_NOT_ENUMALLPROP_NOTOOL_PTMEASPAR;
00474 }
00475 }
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506 void ippCommandChecker::checkEnumProp( ippCommandConstPtr aCommand)
00507 {
00508 const ippEnumPropCommand * theEnum= (const ippEnumPropCommand *)aCommand.get();
00509
00510 ippKToolConstPtr theTool;
00511
00512 const ippProp& prop = theEnum->getProp();
00513
00514 if (prop.getKey1() == Tool) {
00515 theTool = _world->getTools()->getActiveTool();
00516
00517 } else if (prop.getKey1() == FoundTool) {
00518 theTool = _world->getTools()->getFoundTool();
00519 } else {
00520 theTool = NULL;
00521
00522 }
00523
00524 if (theTool && (theTool == _world->getTools()->getUnDefTool()))
00525 {
00526 if (prop.getNumberKeys() > 1)
00527 {
00528 if (prop.getKey2() == PtMeasPar) {
00529 _errorCode = CAN_NOT_ENUMPROP_UNDEFTOOL_PTMEASPAR;
00530 } else {
00531 _errorCode = CAN_NOT_ENUMPROP_UNDEFTOOL_GOTOPAR;
00532 }
00533 }
00534 } else if (theTool && (theTool == _world->getTools()->getNoTool())) {
00535 if ((prop.getNumberKeys() > 1) && (prop.getKey2() == PtMeasPar)) {
00536 _errorCode = CAN_NOT_ENUMPROP_NOTOOL_PTMEASPAR;
00537 }
00538 }
00539 }
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555 void ippCommandChecker::checkEnumTools( ippCommandConstPtr aCommand)
00556 {
00557
00558 }
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579 void ippCommandChecker::checkFindTool( ippCommandConstPtr aCommand)
00580 {
00581
00582
00583
00584
00585
00586 }
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602 void ippCommandChecker::checkGet( ippCommandConstPtr aCommand)
00603 {
00604
00605 }
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625 void ippCommandChecker::checkGetChangeToolAction( ippCommandConstPtr aCommand)
00626 {
00627 const ippGetChangeToolActionCommand* theChangeAction =
00628 static_cast<const ippGetChangeToolActionCommand*>(aCommand.get());
00629
00630 if (strcmp("UnDefTool", theChangeAction->getToolName()) == 0){
00631
00632 _errorCode = CAN_NOT_CHANGE_TOOL_TO_UNDEFTOOL;
00633
00634 } else if (_world->getTools()->findTool(theChangeAction->getToolName()).get()== NULL){
00635
00636 _errorCode = UNKNOWN_TOOL;
00637
00638 }
00639 }
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655 void ippCommandChecker::checkGetCoordSystem( ippCommandConstPtr aCommand)
00656 {
00657
00658 }
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674 void ippCommandChecker::checkGetCsyTransformation( ippCommandConstPtr aCommand)
00675 {
00676
00677 }
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693 void ippCommandChecker::checkGetDMEVersion( ippCommandConstPtr aCommand)
00694 {
00695
00696 }
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721 void ippCommandChecker::checkGetErrorInfo(ippCommandConstPtr aCommand)
00722 {
00723 const ippGetErrorInfoCommand* theGetErrorInfo =
00724 static_cast<const ippGetErrorInfoCommand*>(aCommand.get());
00725
00726 int error_number = theGetErrorInfo->getErrorNumber().asInteger();
00727
00728 if (((error_number >= 0) && (error_number <= 8)) ||
00729 ((error_number >= 500) && (error_number <= 515)) ||
00730 ((error_number >= 1000) && (error_number <= 1010)) ||
00731 ((error_number >= 1500) && (error_number <= 1503)) ||
00732 ((error_number >= 2000) && (error_number <= 2002)) ||
00733 ((error_number >= 2500) && (error_number <= 2506)) ||
00734 ((error_number >= 8000) && (error_number <= 9999)));
00735 else
00736 _errorCode = BAD_ERROR_NUMBER;
00737 }
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753 void ippCommandChecker::checkGetErrStatusE( ippCommandConstPtr aCommand)
00754 {
00755
00756 }
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772 void ippCommandChecker::checkGetMachineClass( ippCommandConstPtr aCommand)
00773 {
00774
00775 }
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798 void ippCommandChecker::checkGetProp( ippCommandConstPtr aCommand)
00799 {
00800 const ippGetPropCommand* theGetProp =
00801 static_cast<const ippGetPropCommand*>(aCommand.get());
00802
00803
00804 ippKToolConstPtr theTool;
00805 int n;
00806
00807 for (n = 0; ((_errorCode == CHECKER_OK) && (n < theGetProp->getNumberProps())); n++)
00808 {
00809 const ippProp& prop = theGetProp->getProp(n);
00810
00811 if (theGetProp->getProp(n).getKey1() == Tool) {
00812 theTool = _world->getTools()->getActiveTool();
00813
00814 } else if (theGetProp->getProp(n).getKey1() == FoundTool) {
00815 theTool = _world->getTools()->getFoundTool();
00816
00817 } else {
00818 theTool = NULL;
00819 }
00820 if (theTool && (theTool == _world->getTools()->getUnDefTool())) {
00821 _errorCode = CAN_NOT_GETPROP_UNDEFTOOL;
00822
00823 } else if (theTool && (theGetProp->getProp(n).getKey2() == PtMeasPar) &&
00824 (theTool == _world->getTools()->getNoTool())) {
00825 _errorCode = CAN_NOT_GETPROP_PTMEASPARS_OF_NOTOOL;
00826 }
00827 }
00828 }
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851 void ippCommandChecker::checkGetPropE( ippCommandConstPtr aCommand)
00852 {
00853 const ippGetPropECommand * theGetPropE =
00854 static_cast<const ippGetPropECommand*>(aCommand.get());
00855
00856 ippKToolConstPtr theTool;
00857 int n;
00858
00859 for (n = 0;
00860 ((_errorCode == CHECKER_OK) && (n < theGetPropE->getNumberProps()));
00861 n++)
00862 {
00863 if (theGetPropE->getProp(n).getKey1() == Tool) {
00864 theTool = _world->getTools()->getActiveTool();
00865 } else if (theGetPropE->getProp(n).getKey1() == FoundTool){
00866 theTool = _world->getTools()->getFoundTool();
00867 } else{
00868 theTool = NULL;
00869 }
00870
00871 if (theTool && (theTool == _world->getTools()->getUnDefTool())){
00872 _errorCode = CAN_NOT_GETPROPE_UNDEFTOOL;
00873 } else if (theTool && (theGetPropE->getProp(n).getKey2() == PtMeasPar) &&
00874 (theTool == _world->getTools()->getNoTool())) {
00875 _errorCode = CAN_NOT_GETPROPE_PTMEASPARS_OF_NOTOOL;
00876 }
00877 }
00878 }
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894 void ippCommandChecker::checkGetXtdErrStatus( ippCommandConstPtr aCommand)
00895 {
00896
00897 }
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919 void ippCommandChecker::checkGoTo( ippCommandConstPtr aCommand)
00920 {
00921 const ippGoToCommand * theGoTo = static_cast<const ippGoToCommand*>(aCommand.get());
00922
00923 if (!(_world->getIsHomed())) {
00924 _errorCode = NOT_HOMED_CAN_NOT_EXECUTE_COMMAND;
00925
00926 } else if (_world->getTools()->getActiveTool() == _world->getTools()->getUnDefTool()){
00927 _errorCode = CAN_NOT_GOTO_USING_UNDEFTOOL;
00928 } else if (!(_world->inWorkVolume
00929 ((theGoTo->getHasX() ? theGoTo->getX() : _world->getCurrentX()),
00930 (theGoTo->getHasY() ? theGoTo->getY() : _world->getCurrentY()),
00931 (theGoTo->getHasZ() ? theGoTo->getZ() : _world->getCurrentZ())))) {
00932 _errorCode = TARGET_POINT_OUT_OF_WORK_VOLUME;
00933 }
00934 }
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950 void ippCommandChecker::checkHome( ippCommandConstPtr aCommand)
00951 {
00952
00953 }
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966
00967
00968
00969 void ippCommandChecker::checkIsHomed( ippCommandConstPtr aCommand)
00970 {
00971
00972 }
00973
00974
00975
00976
00977
00978
00979
00980
00981
00982
00983
00984
00985
00986
00987
00988 void ippCommandChecker::checkIsUserEnabled( ippCommandConstPtr aCommand)
00989 {
00990
00991 }
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007 void ippCommandChecker::checkLockAxis( ippCommandConstPtr aCommand)
01008 {
01009
01010 }
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035 void ippCommandChecker::checkOnMoveReportE( ippCommandConstPtr aCommand)
01036 {
01037 const ippOnMoveReportECommand* theOn =
01038 static_cast<const ippOnMoveReportECommand*>(aCommand.get());
01039
01040 if (theOn->getHasTime() && (theOn->getTheTime() < 0.1)) {
01041 _errorCode = TIME_ARGUMENT_MUST_NOT_BE_LESS_THAN_A_TENTH;
01042 } else if (theOn->getHasDis() && (theOn->getTheDis() <= 0)) {
01043 _errorCode = DIS_ARGUMENT_MUST_BE_POSITIVE;
01044 } else if (_world->daemonCount() != 0) {
01045 _errorCode = MUST_STOP_EXISTING_DAEMON_BEFORE_STARTING_ANOTHER;
01046 }
01047 }
01048
01049
01050
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060
01061
01062
01063 void ippCommandChecker::checkOnPtMeasReport( ippCommandConstPtr aCommand)
01064 {
01065
01066 }
01067
01068
01069
01070
01071
01072
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082 void ippCommandChecker::checkOnScanReport( ippCommandConstPtr aCommand)
01083 {
01084
01085 }
01086
01087
01088
01089
01090
01091
01092
01093
01094
01095 void ippCommandChecker::checkPtMeas( ippCommandConstPtr aCommand)
01096
01097
01098
01099
01100
01101
01102
01103
01104
01105
01106
01107
01108
01109
01110
01111
01112
01113
01114 {
01115 ippPtMeasCommandConstPtr thePtMeas = boost::static_pointer_cast<const ippPtMeasCommand>(aCommand);
01116
01117 if (!(_world->getIsHomed())) {
01118
01119 _errorCode = NOT_HOMED_CAN_NOT_EXECUTE_COMMAND;
01120
01121 } else if ((thePtMeas->getHasIJK()) && (thePtMeas->getI() == 0) && (thePtMeas->getJ() == 0) && (thePtMeas->getK() == 0)) {
01122
01123 _errorCode = DIRECTION_VECTOR_HAS_ZERO_LENGTH;
01124
01125 } else if (!(_world->inWorkVolume(
01126 (thePtMeas->getHasX() ? thePtMeas->getX() : _world->getCurrentX()),
01127 (thePtMeas->getHasY() ? thePtMeas->getY() : _world->getCurrentY()),
01128 (thePtMeas->getHasZ() ? thePtMeas->getZ() : _world->getCurrentZ()))))
01129 {
01130 _errorCode = TARGET_POINT_OUT_OF_WORK_VOLUME;
01131
01132
01133 } else if (_world->getTools()->getActiveTool() == _world->getTools()->getUnDefTool()) {
01134
01135 _errorCode = CAN_NOT_PTMEAS_USING_UNDEFTOOL;
01136
01137 } else if (_world->getTools()->getActiveTool() == _world->getTools()->getNoTool()) {
01138
01139 _errorCode = CAN_NOT_PTMEAS_USING_NOTOOL;
01140 }
01141 }
01142
01143
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153
01154
01155
01156
01157
01158
01159
01160
01161
01162
01163
01164
01165
01166
01167
01168
01169
01170
01171 void ippCommandChecker::checkReQualify( ippCommandConstPtr aCommand)
01172 {
01173 if (!(_world->getIsHomed()))
01174 _errorCode = NOT_HOMED_CAN_NOT_EXECUTE_COMMAND;
01175 else if (_world->getTools()->getActiveTool() ==
01176 _world->getTools()->getUnDefTool())
01177 _errorCode = CAN_NOT_REQUALIFY_UNDEFTOOL;
01178 else if (_world->getTools()->getActiveTool() ==
01179 _world->getTools()->getNoTool())
01180 _errorCode = CAN_NOT_REQUALIFY_NOTOOL;
01181 }
01182
01183
01184
01185
01186
01187
01188
01189
01190
01191
01192
01193
01194
01195
01196
01197
01198
01199
01200
01201
01202
01203
01204
01205
01206
01207
01208
01209
01210
01211
01212
01213
01214
01215
01216
01217
01218
01219
01220
01221
01222
01223
01224
01225 void ippCommandChecker::checkScanInCylEndIsPlane( ippCommandConstPtr aCommand)
01226 {
01227 const ippScanInCylEndIsPlaneCommand * theScan =
01228 static_cast<const ippScanInCylEndIsPlaneCommand*>(aCommand.get());
01229
01230 double ci = theScan->getCI();
01231 double cj = theScan->getCJ();
01232 double ck = theScan->getCK();
01233 double vi = (theScan->getSx() - theScan->getCx());
01234 double vj = (theScan->getSy() - theScan->getCy());
01235 double vk = (theScan->getSz() - theScan->getCz());
01236
01237 double lengthc = sqrt((ci * ci) + (cj * cj) + (ck * ck));
01238 double lengthv = sqrt((vi * vi) + (vj * vj) + (vk * vk));
01239
01240 if (!(_world->getIsHomed())) {
01241 _errorCode = NOT_HOMED_CAN_NOT_EXECUTE_COMMAND;
01242
01243 } else if (_world->getTools()->getActiveTool() == _world->getTools()->getUnDefTool()) {
01244 _errorCode = CAN_NOT_SCAN_USING_UNDEFTOOL;
01245
01246 } else if (_world->getTools()->getActiveTool() == _world->getTools()->getNoTool()) {
01247 _errorCode = CAN_NOT_SCAN_USING_NOTOOL;
01248
01249 } else if (lengthc == 0) {
01250 _errorCode = AXIS_DIRECTION_VECTOR_HAS_ZERO_LENGTH;
01251
01252 } else if ((theScan->getSI() == 0) && (theScan->getSJ() == 0) && (theScan->getSK() == 0)) {
01253 _errorCode = DIRECTION_VECTOR_HAS_ZERO_LENGTH;
01254
01255 } else if ((theScan->getPI() == 0) && (theScan->getPJ() == 0) && (theScan->getPK() == 0)){
01256 _errorCode = DIRECTION_VECTOR_HAS_ZERO_LENGTH;
01257
01258 } else if ((theScan->getEI() == 0) && (theScan->getEJ() == 0) && (theScan->getEK() == 0)) {
01259 _errorCode = DIRECTION_VECTOR_HAS_ZERO_LENGTH;
01260
01261 } else if (!(_world->inWorkVolume(theScan->getSx(), theScan->getSy(), theScan->getSz()))) {
01262 _errorCode = SCAN_POINT_MUST_BE_IN_WORK_VOLUME;
01263
01264 } else if (!(_world->inWorkVolume(theScan->getDx(), theScan->getDy(), theScan->getDz()))) {
01265 _errorCode = SCAN_POINT_MUST_BE_IN_WORK_VOLUME;
01266
01267 } else if ((theScan->getSx() == theScan->getDx()) && (theScan->getSy() == theScan->getDy()) && (theScan->getSz() == theScan->getDz())) {
01268 _errorCode = START_POINT_MUST_DIFFER_FROM_DIRECTION_POINT;
01269
01270 } else if ((lengthv == 0) || (fabs((((ci * vi) + (cj * vj) + (ck * vk)) / lengthc) / lengthv) > 0.9999)) {
01271 _errorCode = START_POINT_MUST_NOT_BE_ON_CYLINDER_AXIS;
01272 }
01273 }
01274
01275
01276
01277
01278
01279
01280
01281
01282
01283
01284
01285
01286
01287
01288
01289
01290
01291
01292
01293
01294
01295
01296
01297
01298
01299
01300
01301
01302
01303
01304
01305
01306
01307
01308
01309
01310
01311
01312
01313
01314
01315 void ippCommandChecker::checkScanInCylEndIsSphere( ippCommandConstPtr aCommand)
01316 {
01317 const ippScanInCylEndIsSphereCommand * theScan =
01318 static_cast<const ippScanInCylEndIsSphereCommand*>(aCommand.get());
01319
01320 double ci = theScan->getCI();
01321 double cj = theScan->getCJ();
01322 double ck = theScan->getCK();
01323 double vi = (theScan->getSx() - theScan->getCx());
01324 double vj = (theScan->getSy() - theScan->getCy());
01325 double vk = (theScan->getSz() - theScan->getCz());
01326 double lengthc = sqrt((ci * ci) + (cj * cj) + (ck * ck));
01327 double lengthv = sqrt((vi * vi) + (vj * vj) + (vk * vk));
01328
01329 if (!(_world->getIsHomed())) {
01330 _errorCode = NOT_HOMED_CAN_NOT_EXECUTE_COMMAND;
01331
01332 } else if (_world->getTools()->getActiveTool() == _world->getTools()->getUnDefTool()) {
01333 _errorCode = CAN_NOT_SCAN_USING_UNDEFTOOL;
01334
01335 } else if (_world->getTools()->getActiveTool() == _world->getTools()->getNoTool()) {
01336 _errorCode = CAN_NOT_SCAN_USING_NOTOOL;
01337
01338 } else if (lengthc == 0) {
01339 _errorCode = AXIS_DIRECTION_VECTOR_HAS_ZERO_LENGTH;
01340
01341 } else if ((theScan->getSI() == 0) && (theScan->getSJ() == 0) && (theScan->getSK() == 0)){
01342 _errorCode = DIRECTION_VECTOR_HAS_ZERO_LENGTH;
01343
01344 } else if ((theScan->getEI() == 0) &&(theScan->getEJ() == 0) && (theScan->getEK() == 0)) {
01345 _errorCode = DIRECTION_VECTOR_HAS_ZERO_LENGTH;
01346
01347 } else if (!(_world->inWorkVolume(theScan->getSx(), theScan->getSy(), theScan->getSz()))) {
01348 _errorCode = SCAN_POINT_MUST_BE_IN_WORK_VOLUME;
01349
01350 } else if (!(_world->inWorkVolume (theScan->getDx(), theScan->getDy(), theScan->getDz()))) {
01351 _errorCode = SCAN_POINT_MUST_BE_IN_WORK_VOLUME;
01352
01353 } else if ((theScan->getSx() == theScan->getDx()) &&(theScan->getSy() == theScan->getDy()) && (theScan->getSz() == theScan->getDz())){
01354 _errorCode = START_POINT_MUST_DIFFER_FROM_DIRECTION_POINT;
01355
01356 } else if ((lengthv == 0) ||(fabs((((ci * vi) + (cj * vj) + (ck * vk)) / lengthc) / lengthv)> 0.9999)) {
01357 _errorCode = START_POINT_MUST_NOT_BE_ON_CYLINDER_AXIS;
01358 }
01359 }
01360
01361
01362
01363
01364
01365
01366
01367
01368
01369
01370
01371
01372
01373
01374
01375
01376
01377
01378
01379
01380
01381
01382
01383
01384
01385
01386
01387
01388
01389
01390
01391
01392 void ippCommandChecker::checkScanInPlaneEndIsCyl( ippCommandConstPtr aCommand)
01393 {
01394 const ippScanInPlaneEndIsCylCommand * theScan =
01395 static_cast<const ippScanInPlaneEndIsCylCommand*>(aCommand.get());
01396
01397 if (!(_world->getIsHomed())) {
01398 _errorCode = NOT_HOMED_CAN_NOT_EXECUTE_COMMAND;
01399
01400 } else if (_world->getTools()->getActiveTool() == _world->getTools()->getUnDefTool()){
01401 _errorCode = CAN_NOT_SCAN_USING_UNDEFTOOL;
01402
01403 } else if (_world->getTools()->getActiveTool() == _world->getTools()->getNoTool()){
01404 _errorCode = CAN_NOT_SCAN_USING_NOTOOL;
01405
01406 } else if ((theScan->getCI() == 0) && (theScan->getCJ() == 0) && (theScan->getCK() == 0)){
01407 _errorCode = AXIS_DIRECTION_VECTOR_HAS_ZERO_LENGTH;
01408
01409 } else if ((theScan->getSI() == 0) && (theScan->getSJ() == 0) && (theScan->getSK() == 0)) {
01410 _errorCode = DIRECTION_VECTOR_HAS_ZERO_LENGTH;
01411
01412
01413 } else if ((theScan->getEI() == 0) && (theScan->getEJ() == 0) && (theScan->getEK() == 0)){
01414 _errorCode = DIRECTION_VECTOR_HAS_ZERO_LENGTH;
01415
01416 } else if (!(_world->inWorkVolume(theScan->getSx(), theScan->getSy(), theScan->getSz()))){
01417 _errorCode = SCAN_POINT_MUST_BE_IN_WORK_VOLUME;
01418
01419 } else if (!(_world->inWorkVolume(theScan->getDx(), theScan->getDy(), theScan->getDz()))){
01420 _errorCode = SCAN_POINT_MUST_BE_IN_WORK_VOLUME;
01421
01422 }else if ((theScan->getSx() == theScan->getDx()) &&(theScan->getSy() == theScan->getDy()) && (theScan->getSz() == theScan->getDz())){
01423 _errorCode = START_POINT_MUST_DIFFER_FROM_DIRECTION_POINT;
01424
01425 }
01426 }
01427
01428
01429
01430
01431
01432
01433
01434
01435
01436
01437
01438
01439
01440
01441
01442
01443
01444
01445
01446
01447
01448
01449
01450
01451
01452
01453
01454
01455
01456
01457
01458
01459 void ippCommandChecker::checkScanInPlaneEndIsPlane( ippCommandConstPtr aCommand)
01460 {
01461 const ippScanInPlaneEndIsPlaneCommand* theScan=
01462 static_cast<const ippScanInPlaneEndIsPlaneCommand*>(aCommand.get());
01463
01464
01465 if (!(_world->getIsHomed())) {
01466 _errorCode = NOT_HOMED_CAN_NOT_EXECUTE_COMMAND;
01467
01468 } else if (_world->getTools()->getActiveTool() == _world->getTools()->getUnDefTool()) {
01469 _errorCode = CAN_NOT_SCAN_USING_UNDEFTOOL;
01470
01471 } else if (_world->getTools()->getActiveTool() == _world->getTools()->getNoTool()){
01472 _errorCode = CAN_NOT_SCAN_USING_NOTOOL;
01473
01474 } else if ((theScan->getSI() == 0) &&(theScan->getSJ() == 0) && (theScan->getSK() == 0)){
01475 _errorCode = DIRECTION_VECTOR_HAS_ZERO_LENGTH;
01476
01477 }else if ((theScan->getPI() == 0) && (theScan->getPJ() == 0) &&(theScan->getPK() == 0)) {
01478 _errorCode = DIRECTION_VECTOR_HAS_ZERO_LENGTH;
01479
01480 } else if ((theScan->getEI() == 0) &&(theScan->getEJ() == 0) &&(theScan->getEK() == 0)) {
01481 _errorCode = DIRECTION_VECTOR_HAS_ZERO_LENGTH;
01482
01483 } else if (!(_world->inWorkVolume(theScan->getSx(), theScan->getSy(), theScan->getSz()))){
01484 _errorCode = SCAN_POINT_MUST_BE_IN_WORK_VOLUME;
01485
01486 } else if (!(_world->inWorkVolume(theScan->getDx(), theScan->getDy(), theScan->getDz()))){
01487 _errorCode = SCAN_POINT_MUST_BE_IN_WORK_VOLUME;
01488
01489 } else if ((theScan->getSx() == theScan->getDx()) &&(theScan->getSy() == theScan->getDy()) && (theScan->getSz() == theScan->getDz())) {
01490 _errorCode = START_POINT_MUST_DIFFER_FROM_DIRECTION_POINT;
01491
01492 }
01493 }
01494
01495
01496
01497
01498
01499
01500
01501
01502
01503
01504
01505
01506
01507
01508
01509
01510
01511
01512
01513
01514
01515
01516
01517
01518
01519
01520
01521
01522
01523
01524
01525
01526 void ippCommandChecker::checkScanInPlaneEndIsSphere( ippCommandConstPtr aCommand)
01527 {
01528 const ippScanInPlaneEndIsSphereCommand * theScan =
01529 static_cast<const ippScanInPlaneEndIsSphereCommand*>(aCommand.get());
01530
01531 if (!(_world->getIsHomed())) {
01532 _errorCode = NOT_HOMED_CAN_NOT_EXECUTE_COMMAND;
01533
01534 } else if (_world->getTools()->getActiveTool() == _world->getTools()->getUnDefTool()){
01535 _errorCode = CAN_NOT_SCAN_USING_UNDEFTOOL;
01536
01537 } else if (_world->getTools()->getActiveTool() == _world->getTools()->getNoTool()){
01538 _errorCode = CAN_NOT_SCAN_USING_NOTOOL;
01539
01540 } else if ((theScan->getSI() == 0) && (theScan->getSJ() == 0) && (theScan->getSK() == 0)) {
01541 _errorCode = DIRECTION_VECTOR_HAS_ZERO_LENGTH;
01542
01543 } else if ((theScan->getEI() == 0) && (theScan->getEJ() == 0) && (theScan->getEK() == 0)){
01544 _errorCode = DIRECTION_VECTOR_HAS_ZERO_LENGTH;
01545
01546 } else if (!(_world->inWorkVolume(theScan->getSx(), theScan->getSy(), theScan->getSz()))){
01547 _errorCode = SCAN_POINT_MUST_BE_IN_WORK_VOLUME;
01548
01549 } else if (!(_world->inWorkVolume(theScan->getDx(), theScan->getDy(), theScan->getDz()))){
01550 _errorCode = SCAN_POINT_MUST_BE_IN_WORK_VOLUME;
01551
01552 } else if (!(_world->inWorkVolume(theScan->getEx(), theScan->getEy(), theScan->getEz()))){
01553 _errorCode = SCAN_POINT_MUST_BE_IN_WORK_VOLUME;
01554
01555 } else if ((theScan->getSx() == theScan->getDx()) && (theScan->getSy() == theScan->getDy()) && (theScan->getSz() == theScan->getDz())){
01556 _errorCode = START_POINT_MUST_DIFFER_FROM_DIRECTION_POINT;
01557
01558 }
01559 }
01560
01561
01562
01563
01564
01565
01566
01567
01568
01569
01570
01571
01572
01573
01574
01575
01576
01577
01578
01579
01580
01581
01582
01583
01584
01585
01586
01587
01588
01589
01590
01591 void ippCommandChecker::checkScanOnCircle( ippCommandConstPtr aCommand)
01592 {
01593 const ippScanOnCircleCommand * theScan =
01594 static_cast<const ippScanOnCircleCommand *>(aCommand.get());
01595
01596 double i = theScan->getI();
01597 double j = theScan->getJ();
01598 double k = theScan->getK();
01599 double norml = sqrt((i * i) + (j * j) + (k * k));
01600 double radx = (theScan->getSx() - theScan->getCx());
01601 double rady = (theScan->getSy() - theScan->getCy());
01602 double radz = (theScan->getSz() - theScan->getCz());
01603 double radl = sqrt((radx * radx) + (rady * rady) + (radz * radz));
01604
01605 if (!(_world->getIsHomed())) {
01606 _errorCode = NOT_HOMED_CAN_NOT_EXECUTE_COMMAND;
01607
01608 } else if (_world->getTools()->getActiveTool() == _world->getTools()->getUnDefTool()){
01609 _errorCode = CAN_NOT_SCAN_USING_UNDEFTOOL;
01610
01611 } else if (_world->getTools()->getActiveTool() == _world->getTools()->getNoTool()) {
01612 _errorCode = CAN_NOT_SCAN_USING_NOTOOL;
01613
01614 } else if (norml == 0) {
01615 _errorCode = DIRECTION_VECTOR_HAS_ZERO_LENGTH;
01616
01617 } else if (radl == 0) {
01618 _errorCode = RADIUS_MUST_HAVE_POSITIVE_LENGTH;
01619
01620 } else if (fabs(((i * radx) + (j * rady) + (k * radz)) / (norml * radl)) > IPP_NORMAL_ERROR) {
01621 _errorCode = RADIUS_MUST_BE_PERPENDICULAR_TO_NORMAL;
01622
01623 } else if (!(_world->inWorkVolume(theScan->getSx(), theScan->getSy(), theScan->getSz()))) {
01624 _errorCode = SCAN_POINT_MUST_BE_IN_WORK_VOLUME;
01625
01626 }
01627 }
01628
01629
01630
01631
01632
01633
01634
01635
01636
01637
01638
01639
01640
01641
01642
01643 void ippCommandChecker::checkScanOnCircleHint( ippCommandConstPtr aCommand)
01644 {
01645
01646 }
01647
01648
01649
01650
01651
01652
01653
01654
01655
01656
01657
01658
01659
01660
01661
01662
01663
01664
01665
01666
01667
01668
01669
01670
01671
01672
01673 void ippCommandChecker::checkScanOnLine( ippCommandConstPtr aCommand)
01674 {
01675 const ippScanOnLineCommand* theScan =
01676 static_cast<const ippScanOnLineCommand *>(aCommand.get());
01677
01678 if (!(_world->getIsHomed())) {
01679 _errorCode = NOT_HOMED_CAN_NOT_EXECUTE_COMMAND;
01680
01681 } else if (_world->getTools()->getActiveTool() == _world->getTools()->getUnDefTool()){
01682 _errorCode = CAN_NOT_SCAN_USING_UNDEFTOOL;
01683
01684 } else if (_world->getTools()->getActiveTool() == _world->getTools()->getNoTool()){
01685 _errorCode = CAN_NOT_SCAN_USING_NOTOOL;
01686
01687 } else if ((theScan->getSx() == theScan->getEx()) && (theScan->getSy() == theScan->getEy()) &&(theScan->getSz() == theScan->getEz())){
01688 _errorCode = START_POINT_MUST_DIFFER_FROM_END_POINT;
01689
01690 } else if (!(_world->inWorkVolume(theScan->getSx(), theScan->getSy(), theScan->getSz()))){
01691 _errorCode = SCAN_POINT_MUST_BE_IN_WORK_VOLUME;
01692
01693 } else if (!(_world->inWorkVolume(theScan->getEx(), theScan->getEy(), theScan->getEz()))){
01694 _errorCode = SCAN_POINT_MUST_BE_IN_WORK_VOLUME;
01695
01696 }
01697 }
01698
01699
01700
01701
01702
01703
01704
01705
01706
01707
01708
01709
01710
01711
01712
01713 void ippCommandChecker::checkScanOnLineHint( ippCommandConstPtr aCommand)
01714 {
01715
01716 }
01717
01718
01719
01720
01721
01722
01723
01724
01725
01726
01727
01728
01729
01730
01731
01732 void ippCommandChecker::checkScanUnknownHint( ippCommandConstPtr aCommand)
01733 {
01734
01735 }
01736
01737
01738
01739
01740
01741
01742
01743
01744 void ippCommandChecker::checkScanUnknownDensity( ippCommandConstPtr aCommand)
01745 {
01746
01747 }
01748
01749
01750
01751
01752
01753
01754
01755
01756
01757
01758
01759
01760
01761
01762
01763 void ippCommandChecker::checkSetCoordSystem( ippCommandConstPtr aCommand)
01764 {
01765
01766 }
01767
01768
01769
01770
01771
01772
01773
01774
01775
01776
01777
01778
01779
01780
01781
01782
01783
01784
01785
01786
01787 void ippCommandChecker::checkSetCsyTransformation( ippCommandConstPtr aCommand)
01788 {
01789 const ippSetCsyTransformationCommand* theSetCsyTransformation =
01790 static_cast<const ippSetCsyTransformationCommand *>(aCommand.get());
01791
01792 if ((theSetCsyTransformation->getTheta() < 0) || (theSetCsyTransformation->getTheta() > 180)){
01793 _errorCode = THETA_MUST_NOT_BE_NEGATIVE_OR_MORE_THAN_180;
01794 }
01795
01796 }
01797
01798
01799
01800
01801
01802
01803
01804
01805
01806
01807
01808
01809
01810
01811
01812
01813
01814
01815
01816
01817
01818
01819
01820
01821
01822
01823
01824
01825 void ippCommandChecker::checkSetProp( ippCommandConstPtr aCommand)
01826 {
01827 const ippSetPropCommand * theSetProp =
01828 static_cast<const ippSetPropCommand*>(aCommand.get());
01829
01830 ippKToolConstPtr theTool;
01831 int n;
01832
01833 for (n = 0;
01834 ((_errorCode == CHECKER_OK) && (n < theSetProp->getNumberProps()));
01835 n++)
01836 {
01837 if (theSetProp->getProp(n).getKey1() == Tool)
01838 theTool = _world->getTools()->getActiveTool();
01839 else if (theSetProp->getProp(n).getKey1() == FoundTool)
01840 theTool = _world->getTools()->getFoundTool();
01841 else
01842 theTool = NULL;
01843 if (theTool && (theTool == _world->getTools()->getUnDefTool()))
01844 _errorCode = CAN_NOT_SETPROP_UNDEFTOOL;
01845 else if (theTool && (theSetProp->getProp(n).getKey2() == PtMeasPar) &&
01846 (theTool == _world->getTools()->getNoTool()))
01847 _errorCode = CAN_NOT_SETPROP_PTMEASPARS_OF_NOTOOL;
01848 }
01849 }
01850
01851
01852
01853
01854
01855
01856
01857
01858
01859
01860
01861
01862
01863
01864
01865
01866
01867
01868
01869
01870
01871
01872
01873 void ippCommandChecker::checkSetTool( ippCommandConstPtr aCommand)
01874 {
01875 const ippSetToolCommand * theSet =
01876 static_cast<const ippSetToolCommand*>(aCommand.get());
01877
01878 if (strcmp("UnDefTool", theSet->getToolName()) == 0) {
01879 _errorCode = CAN_NOT_SET_TOOL_TO_UNDEFTOOL;
01880 } else if (!_world->getTools()->findTool(theSet->getToolName())) {
01881 _errorCode = UNKNOWN_TOOL;
01882 }
01883 }
01884
01885
01886
01887
01888
01889
01890
01891
01892
01893
01894
01895
01896
01897
01898
01899
01900
01901 void ippCommandChecker::checkStartSession( ippCommandConstPtr aCommand)
01902 {
01903 }
01904
01905
01906
01907
01908
01909
01910
01911
01912
01913
01914
01915
01916
01917
01918
01919
01920
01921
01922 void ippCommandChecker::checkStopAllDaemons( ippCommandConstPtr aCommand)
01923 {
01924
01925 }
01926
01927
01928
01929
01930
01931
01932
01933
01934
01935
01936
01937
01938
01939
01940
01941
01942
01943 void ippCommandChecker::checkStopDaemon( ippCommandConstPtr aCommand)
01944 {
01945 const ippStopDaemonCommand * theStop =
01946 static_cast<const ippStopDaemonCommand* >(aCommand.get());
01947
01948 int tagNumber= theStop->getDaemonTag().getTagNumber();
01949 if (!(_world->daemonExists(tagNumber))) {
01950 _errorCode = DAEMON_TO_STOP_DOES_NOT_EXIST;
01951 }
01952 }
01953
01954
01955
01956
01957
01958
01959
01960
01961
01962
01963
01964
01965
01966
01967
01968
01969
01970
01971
01972
01973
01974
01975
01976
01977
01978 void ippCommandChecker::checkTiltCenterPart( ippCommandConstPtr aCommand)
01979 {
01980 const ippTiltCenterPartCommand * theTiltCenter =
01981 static_cast<const ippTiltCenterPartCommand *>(aCommand.get());
01982
01983 double vecX = (theTiltCenter->getPx1() - theTiltCenter->getPx2());
01984 double vecY = (theTiltCenter->getPy1() - theTiltCenter->getPy2());
01985 double vecZ = (theTiltCenter->getPz1() - theTiltCenter->getPz2());
01986 double length = sqrt((vecX * vecX) + (vecY * vecY) + (vecZ * vecZ));
01987
01988 if (length == 0) {
01989 _errorCode = AXIS_DIRECTION_VECTOR_HAS_ZERO_LENGTH;
01990 }
01991 }
01992
01993
01994
01995
01996
01997
01998
01999
02000
02001
02002
02003
02004
02005
02006
02007
02008
02009
02010
02011
02012
02013
02014
02015 void ippCommandChecker::checkTiltPart(ippCommandConstPtr aCommand)
02016 {
02017 const ippTiltPartCommand* theTilt =
02018 static_cast<const ippTiltPartCommand *>(aCommand.get());
02019
02020 double vecX = theTilt->getDx();
02021 double vecY = theTilt->getDy();
02022 double vecZ = theTilt->getDz();
02023 double length = sqrt((vecX * vecX) + (vecY * vecY) + (vecZ * vecZ));
02024 if (length == 0){
02025 _errorCode = AXIS_DIRECTION_VECTOR_HAS_ZERO_LENGTH;
02026 }
02027 }
02028
02029
02030 void ippCommandChecker::checkEnumToolCollection(ippCommandConstPtr aCommand)
02031 {
02032
02033 }
02034 void ippCommandChecker::checkEnumAllToolCollections(ippCommandConstPtr aCommand)
02035 {
02036
02037 }
02038 void ippCommandChecker::checkOpenToolCollection(ippCommandConstPtr aCommand)
02039 {
02040
02041 }
02042 void ippCommandChecker::checkSaveActiveCoordSystem(ippCommandConstPtr aCommand)
02043 {
02044
02045 }
02046 void ippCommandChecker::checkLoadCoordSystem(ippCommandConstPtr aCommand)
02047 {
02048
02049 }
02050 void ippCommandChecker::checkDeleteCoordSystem(ippCommandConstPtr aCommand)
02051 {
02052
02053 }
02054 void ippCommandChecker::checkEnumCoordSystems(ippCommandConstPtr aCommand)
02055 {
02056
02057 }
02058 void ippCommandChecker::checkGetNamedCsyTransformation(ippCommandConstPtr aCommand)
02059 {
02060
02061 }
02062 void ippCommandChecker::checkSaveNamedCsyTransformation(ippCommandConstPtr aCommand)
02063 {
02064
02065 }
02066 void ippCommandChecker::checkScanOnCurveDensity(ippCommandConstPtr aCommand)
02067 {
02068
02069 }
02070 void ippCommandChecker::checkScanOnCurve(ippCommandConstPtr aCommand)
02071 {
02072
02073 }
02074 void ippCommandChecker::checkScanOnCurveHint(ippCommandConstPtr aCommand)
02075 {
02076
02077 }
02078 void ippCommandChecker::checkScanOnHelix(ippCommandConstPtr aCommand)
02079 {
02080
02081 }
02082 void ippCommandChecker::checkPtMeasSelfCenter(ippCommandConstPtr aCommand)
02083 {
02084
02085 }
02086 void ippCommandChecker::checkPtMeasSelfCenterLocked(ippCommandConstPtr aCommand)
02087 {
02088
02089 }
02090
02091
02092
02093
02094
02095
02096
02097
02098
02099
02100
02101
02102
02103
02104
02105
02106
02107
02108
02109
02110
02111
02112
02113
02114
02115
02116
02117
02118
02119
02120
02121
02122
02123
02124
02125
02126
02127
02128
02129
02130
02131
02132
02133
02134
02135
02136
02137
02138
02139
02140
02141
02142
02143
02144
02145
02146
02147
02148
02149 ippCheckerErrorId ippCommandCheckerBase::checkCommand( ippCommandConstPtr aCommand)
02150 {
02151 _errorCode = CHECKER_OK;
02152 return _errorCode;
02153 }
02154
02155 ippCommandChecker::ippCommandChecker(world& inWorld)
02156 : _world(&inWorld)
02157 {
02158 }
02159
02160 ippCheckerErrorId ippCommandChecker::checkCommand( ippCommandConstPtr aCommand)
02161 {
02162
02163 _errorCode = CHECKER_OK;
02164
02165 _commandName = aCommand->getCommandName();
02166
02167 if (_errorCode == CHECKER_OK) {
02168
02169 if ((_world->getReadiness() == erred) &&
02170 (_commandName != GetErrStatusE) &&
02171 (_commandName != GetXtdErrStatus) &&
02172 (_commandName != ClearAllErrors)) {
02173
02174
02175
02176 _errorCode = READINESS_ERRED_CAN_NOT_EXECUTE_COMMAND;
02177
02178 } else if ((_world->getReadiness() == aborted) &&
02179 (_commandName != GetErrStatusE) &&
02180 (_commandName != GetXtdErrStatus) &&
02181 (_commandName != ClearAllErrors)) {
02182
02183 _errorCode = READINESS_ABORTED_CAN_NOT_EXECUTE_COMMAND;
02184 }
02185 }
02186 if (_errorCode == CHECKER_OK) {
02187
02188 switch(_commandName)
02189 {
02190
02191
02192
02193
02194 #define ENUM(value,function) case ipp::value: IPP_CONCAT(check,value)(aCommand); break;
02195 COMMAND_ENUMERATION
02196 #undef ENUM
02197 default:
02198 IPP_ASSERT_FAIL(" Unknown command");
02199
02200 }
02201 }
02202 return _errorCode;
02203
02204 }
02205
02206
02207
02208