This repository has been archived by the owner on May 15, 2024. It is now read-only.
generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCaDOF.cpp
857 lines (751 loc) · 22.9 KB
/
CaDOF.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
// SPDX-FileCopyrightText: 2023 SAP SE
//
// SPDX-License-Identifier: Apache-2.0
//
// This file is part of FEDEM - https://openfedem.org
////////////////////////////////////////////////////////////////////////////////
#include "CaDOF.h"
#include "CaFunction.h"
#include "CaApplication.h"
#include "CaMacros.h"
#include "vpmDB/FmJointBase.H"
#include "vpmDB/FmDB.H"
//////////////////////////////////////////////////////////////////////
// Constructors and set-up
IMPLEMENT_DYNCREATE(CaDOF, CCmdTarget)
BEGIN_MESSAGE_MAP(CaDOF, CCmdTarget)
END_MESSAGE_MAP()
BEGIN_DISPATCH_MAP(CaDOF, CCmdTarget)
DISP_PROPERTY_EX_ID(CaDOF, "DOFConstraintType", dispidDOFConstraintType, get_DOFConstraintType, SetNotSupported, VT_I4)
DISP_PROPERTY_EX_ID(CaDOF, "InitialVelocity", dispidInitialVelocity, get_InitialVelocity, SetNotSupported, VT_R8)
DISP_PROPERTY_EX_ID(CaDOF, "AddBC", dispidAddBC, get_AddBC, put_AddBC, VT_BOOL)
DISP_PROPERTY_EX_ID(CaDOF, "LoadMagnitude", dispidLoadMagnitude, get_LoadMagnitude, SetNotSupported, VT_VARIANT)
DISP_PROPERTY_EX_ID(CaDOF, "PrescribedMotionType", dispidPrescribedMotionType, get_PrescribedMotionType, SetNotSupported, VT_VARIANT)
DISP_PROPERTY_EX_ID(CaDOF, "PrescribedMotionMagnitude", dispidPrescribedMotionMagnitude, get_PrescribedMotionMagnitude, SetNotSupported, VT_VARIANT)
DISP_PROPERTY_EX_ID(CaDOF, "SDStressfreeLength", dispidSDStressfreeLength, get_SDStressfreeLength, SetNotSupported, VT_VARIANT)
DISP_PROPERTY_EX_ID(CaDOF, "SDStiffness", dispidSDStiffness, get_SDStiffness, SetNotSupported, VT_VARIANT)
DISP_PROPERTY_EX_ID(CaDOF, "SDStiffnessScale", dispidSDStiffnessScale, get_SDStiffnessScale, SetNotSupported, VT_VARIANT)
DISP_PROPERTY_EX_ID(CaDOF, "SDDamper", dispidSDDamper, get_SDDamper, SetNotSupported, VT_VARIANT)
DISP_PROPERTY_EX_ID(CaDOF, "SDDamperScale", dispidSDDamperScale, get_SDDamperScale, SetNotSupported, VT_VARIANT)
DISP_FUNCTION_ID(CaDOF, "SetFree", dispidSetFree, SetFree, VT_EMPTY, VTS_VARIANT VTS_VARIANT)
DISP_FUNCTION_ID(CaDOF, "SetFixed", dispidSetFixed, SetFixed, VT_EMPTY, VTS_NONE)
DISP_FUNCTION_ID(CaDOF, "SetPrescribed", dispidSetPrescribed, SetPrescribed, VT_EMPTY, VTS_I4 VTS_VARIANT VTS_VARIANT)
DISP_FUNCTION_ID(CaDOF, "SetSpringDamper", dispidSetSpringDamper, SetSpringDamper, VT_EMPTY, VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT)
END_DISPATCH_MAP()
BEGIN_INTERFACE_MAP(CaDOF, CCmdTarget)
INTERFACE_PART(CaDOF, IID_IDOF, LocalClass)
END_INTERFACE_MAP()
// {FE8E38C7-69F4-4b38-B887-4C0028301792}
IMPLEMENT_OLECREATE(CaDOF, "FEDEM.DOF",
0xfe8e38c7, 0x69f4, 0x4b38, 0xb8, 0x87, 0x4c, 0x0, 0x28, 0x30, 0x17, 0x92);
CaDOF::CaDOF(void) : m_ptr(m_pDOF)
{
EnableAutomation();
::AfxOleLockApp();
m_pDOF = NULL;
m_nDOFIndex = -1;
signalConnector.Connect(this);
}
CaDOF::~CaDOF(void)
{
::AfxOleUnlockApp();
m_pDOF = NULL;
m_nDOFIndex = -1;
}
//////////////////////////////////////////////////////////////////////
// Methods
void CaDOF::checkMe()
{
CA_CHECK(m_pDOF);
if (m_nDOFIndex == -1)
AfxThrowOleException(CO_E_OBJNOTCONNECTED);
else if (m_nDOFIndex < 1 || m_nDOFIndex > 6)
AfxThrowOleException(ERROR_INVALID_INDEX);
}
DOFConstraintType CaDOF::get_DOFConstraintType()
{
this->checkMe();
switch (m_pDOF->getStatusOfDOF(m_nDOFIndex-1)) {
case FmHasDOFsBase::FIXED:
return DOFConstraintType::Fixed;
case FmHasDOFsBase::FREE_DYNAMICS:
return DOFConstraintType::Free;
case FmHasDOFsBase::FREE:
return DOFConstraintType::Free;
case FmHasDOFsBase::PRESCRIBED:
return DOFConstraintType::Prescribed;
case FmHasDOFsBase::SPRING_CONSTRAINED:
return DOFConstraintType::SpringDamper;
case FmHasDOFsBase::SPRING_DYNAMICS:
return DOFConstraintType::SpringDamper;
}
return DOFConstraintType::Free;
}
void CaDOF::put_DOFConstraintType(DOFConstraintType Val)
{
this->checkMe();
switch (Val) {
case DOFConstraintType::Free:
m_pDOF->setStatusForDOF(m_nDOFIndex-1, FmHasDOFsBase::FREE);
break;
case DOFConstraintType::Fixed:
m_pDOF->setStatusForDOF(m_nDOFIndex-1, FmHasDOFsBase::FIXED);
break;
case DOFConstraintType::Prescribed:
m_pDOF->setStatusForDOF(m_nDOFIndex-1, FmHasDOFsBase::PRESCRIBED);
break;
case DOFConstraintType::SpringDamper:
m_pDOF->setStatusForDOF(m_nDOFIndex-1, FmHasDOFsBase::SPRING_CONSTRAINED);
break;
}
}
double CaDOF::get_InitialVelocity()
{
this->checkMe();
return m_pDOF->getInitVel(m_nDOFIndex-1);
}
BOOL CaDOF::get_AddBC()
{
this->checkMe();
return m_pDOF->getStatusCode(m_nDOFIndex-1) == 2;
}
void CaDOF::put_AddBC(BOOL Val)
{
this->checkMe();
int dof = m_nDOFIndex - 1;
FmHasDOFsBase::DOFStatus stat = m_pDOF->getStatusOfDOF(dof);
if (Val) {
if (stat == FmHasDOFsBase::DOFStatus::FREE)
m_pDOF->setStatusForDOF(dof, FmHasDOFsBase::DOFStatus::FREE_DYNAMICS);
else if (stat == FmHasDOFsBase::DOFStatus::SPRING_CONSTRAINED)
m_pDOF->setStatusForDOF(dof, FmHasDOFsBase::DOFStatus::SPRING_DYNAMICS);
else
return;
}
else
{
if (stat == FmHasDOFsBase::DOFStatus::FREE_DYNAMICS)
m_pDOF->setStatusForDOF(dof, FmHasDOFsBase::DOFStatus::FREE);
else if (stat == FmHasDOFsBase::DOFStatus::SPRING_CONSTRAINED)
m_pDOF->setStatusForDOF(dof, FmHasDOFsBase::DOFStatus::SPRING_DYNAMICS);
else
return;
}
m_pDOF->onChanged();
}
VARIANT CaDOF::get_LoadMagnitude()
{
this->checkMe();
VARIANT vRet;
vRet.vt = VT_EMPTY;
FmDofLoad* pLoad = m_pDOF->getLoadAtDOF(m_nDOFIndex-1);
if (pLoad == NULL)
return vRet;
if (pLoad->getEngine()) {
// IFunction
CaFunction* pCaFunction = (CaFunction*)CaFunction::CreateObject();
if (pCaFunction == NULL)
return vRet;
pCaFunction->m_ptr = pLoad->getEngine();
IFunction* pIFunction = NULL;
LPDISPATCH pDisp = pCaFunction->GetIDispatch(false);
pDisp->QueryInterface(IID_IFunction, (void**)&pIFunction);
pCaFunction->InternalRelease();
vRet.punkVal = pIFunction;
vRet.vt = VT_UNKNOWN;
}
else {
// double
vRet.dblVal = pLoad->getInitLoad();
vRet.vt = VT_R8;
}
return vRet;
}
DOFPrescribedMotionType CaDOF::get_PrescribedMotionType()
{
this->checkMe();
FmDofMotion* pMotion = m_pDOF->getMotionAtDOF(m_nDOFIndex-1);
if (pMotion != NULL)
switch (pMotion->getMotionType()) {
case FmDofMotion::DEFLECTION:
return DOFPrescribedMotionType::Deflection;
case FmDofMotion::VELOCITY:
return DOFPrescribedMotionType::Velocity;
case FmDofMotion::ACCELERATION:
return DOFPrescribedMotionType::Acceleration;
}
return (DOFPrescribedMotionType)0;
}
VARIANT CaDOF::get_PrescribedMotionMagnitude()
{
this->checkMe();
VARIANT vRet;
vRet.vt = VT_EMPTY;
FmDofMotion* pMotion = m_pDOF->getMotionAtDOF(m_nDOFIndex-1);
if (pMotion == NULL)
return vRet;
if (pMotion->getEngine()) {
// IFunction
CaFunction* pCaFunction = (CaFunction*)CaFunction::CreateObject();
if (pCaFunction == NULL)
return vRet;
pCaFunction->m_ptr = pMotion->getEngine();
IFunction* pIFunction = NULL;
LPDISPATCH pDisp = pCaFunction->GetIDispatch(false);
pDisp->QueryInterface(IID_IFunction, (void**)&pIFunction);
pCaFunction->InternalRelease();
vRet.punkVal = pIFunction;
vRet.vt = VT_UNKNOWN;
}
else {
// double
vRet.dblVal = pMotion->getInitMotion();
vRet.vt = VT_R8;
}
return vRet;
}
VARIANT CaDOF::get_SDStressfreeLength()
{
// Note: Are SDStressfreeLength and PrescribedMotionMagnitude the same?
// KMO say: Yes, they are, so this method is not necessary.
return this->get_PrescribedMotionMagnitude();
}
VARIANT CaDOF::get_SDStiffness()
{
this->checkMe();
VARIANT vRet;
vRet.vt = VT_EMPTY;
FmJointBase* pJoint = dynamic_cast<FmJointBase*>(m_pDOF);
if (pJoint == NULL)
return vRet;
FmJointSpring* pSpring = pJoint->getSpringAtDOF(m_nDOFIndex-1);
if (pSpring == NULL)
return vRet;
if (pSpring->getSpringCharOrStiffFunction()) {
// IFunction
CaFunction* pCaFunction = (CaFunction*)CaFunction::CreateObject();
if (pCaFunction == NULL)
return vRet;
pCaFunction->m_ptr = pSpring->getSpringCharOrStiffFunction();
IFunction* pIFunction = NULL;
LPDISPATCH pDisp = pCaFunction->GetIDispatch(false);
pDisp->QueryInterface(IID_IFunction, (void**)&pIFunction);
pCaFunction->InternalRelease();
vRet.punkVal = pIFunction;
vRet.vt = VT_UNKNOWN;
}
else {
// double
vRet.dblVal = pSpring->getInitStiff();
vRet.vt = VT_R8;
}
return vRet;
}
VARIANT CaDOF::get_SDStiffnessScale()
{
this->checkMe();
VARIANT vRet;
vRet.vt = VT_EMPTY;
FmJointBase* pJoint = dynamic_cast<FmJointBase*>(m_pDOF);
if (pJoint == NULL)
return vRet;
FmJointSpring* pSpring = pJoint->getSpringAtDOF(m_nDOFIndex-1);
if (pSpring == NULL)
return vRet;
FmEngine* pScaleEng = pSpring->getScaleEngine();
if (pScaleEng == NULL)
return vRet;
// IFunction
CaFunction* pCaFunction = (CaFunction*)CaFunction::CreateObject();
if (pCaFunction == NULL)
return vRet;
pCaFunction->m_ptr = pScaleEng;
IFunction* pIFunction = NULL;
LPDISPATCH pDisp = pCaFunction->GetIDispatch(false);
pDisp->QueryInterface(IID_IFunction, (void**)&pIFunction);
pCaFunction->InternalRelease();
vRet.punkVal = pIFunction;
vRet.vt = VT_UNKNOWN;
return vRet;
}
VARIANT CaDOF::get_SDDamper()
{
this->checkMe();
VARIANT vRet;
vRet.vt = VT_EMPTY;
FmJointBase* pJoint = dynamic_cast<FmJointBase*>(m_pDOF);
if (pJoint == NULL)
return vRet;
FmJointDamper* pDamper = pJoint->getDamperAtDOF(m_nDOFIndex-1);
if (pDamper == NULL)
return vRet;
if (pDamper->getFunction()) {
// IFunction
CaFunction* pCaFunction = (CaFunction*)CaFunction::CreateObject();
if (pCaFunction == NULL)
return vRet;
pCaFunction->m_ptr = pDamper->getFunction();
IFunction* pIFunction = NULL;
LPDISPATCH pDisp = pCaFunction->GetIDispatch(false);
pDisp->QueryInterface(IID_IFunction, (void**)&pIFunction);
pCaFunction->InternalRelease();
vRet.punkVal = pIFunction;
vRet.vt = VT_UNKNOWN;
}
else {
// double
vRet.dblVal = pDamper->getInitDamp();
vRet.vt = VT_R8;
}
return vRet;
}
VARIANT CaDOF::get_SDDamperScale()
{
this->checkMe();
VARIANT vRet;
vRet.vt = VT_EMPTY;
FmJointBase* pJoint = dynamic_cast<FmJointBase*>(m_pDOF);
if (pJoint == NULL)
return vRet;
FmJointDamper* pDamper = pJoint->getDamperAtDOF(m_nDOFIndex-1);
if (pDamper == NULL)
return vRet;
FmEngine* pScaleEng = pDamper->getDampEngine();
if (pScaleEng == NULL)
return vRet;
// IFunction
CaFunction* pCaFunction = (CaFunction*)CaFunction::CreateObject();
if (pCaFunction == NULL)
return vRet;
pCaFunction->m_ptr = pScaleEng;
IFunction* pIFunction = NULL;
LPDISPATCH pDisp = pCaFunction->GetIDispatch(false);
pDisp->QueryInterface(IID_IFunction, (void**)&pIFunction);
pCaFunction->InternalRelease();
vRet.punkVal = pIFunction;
vRet.vt = VT_UNKNOWN;
return vRet;
}
void CaDOF::SetFree(const VARIANT FAR& LoadMagnitude, const VARIANT FAR& InitialVelocity)
{
this->checkMe();
// Get load magnitude parameter.
// Note: LoadMagnitude can be a double, a function name or an IFunction.
double fLoadMagnitude = 0.0;
FmModelMemberBase* pLoadMagnitudeFunction = NULL;
CaApplication::GetFunctionParameter(LoadMagnitude, &fLoadMagnitude, &pLoadMagnitudeFunction);
// Convert to double
VARIANT varR8;
VariantInit(&varR8);
VariantChangeType(&varR8, &InitialVelocity, 0, VT_R8);
double fInitialVelocity = varR8.vt == VT_R8 ? varR8.dblVal : 0.0;
int dof = m_nDOFIndex - 1;
// Set status
m_pDOF->setStatusForDOF(dof, FmHasDOFsBase::DOFStatus::FREE);
// Set initial velocity
m_pDOF->setInitVel(dof, fInitialVelocity);
// Set load magnitude
FmDofLoad* pLoad = m_pDOF->getLoadAtDOF(dof,true);
pLoad->setInitLoad(fLoadMagnitude);
pLoad->setEngine(dynamic_cast<FmEngine*>(pLoadMagnitudeFunction));
m_pDOF->onChanged();
}
void CaDOF::SetFixed()
{
this->checkMe();
if (m_pDOF->setStatusForDOF(m_nDOFIndex-1,FmHasDOFsBase::DOFStatus::FIXED))
m_pDOF->onChanged();
}
void CaDOF::SetPrescribed(DOFPrescribedMotionType MotionType,
const VARIANT FAR& MotionMagnitude, const VARIANT FAR& InitialVelocity)
{
this->checkMe();
// Get motion magnitude parameter.
// Note: MotionMagnitude can be a double, a function name or an IFunction.
double fMotionMagnitude = 0.0;
FmModelMemberBase* pMotionMagnitudeFunction = NULL;
CaApplication::GetFunctionParameter(MotionMagnitude, &fMotionMagnitude, &pMotionMagnitudeFunction);
// Convert to double
VARIANT varR8;
VariantInit(&varR8);
VariantChangeType(&varR8, &InitialVelocity, 0, VT_R8);
double fInitialVelocity = varR8.vt == VT_R8 ? varR8.dblVal : 0.0;
int dof = m_nDOFIndex - 1;
// Set status
m_pDOF->setStatusForDOF(dof, FmHasDOFsBase::DOFStatus::PRESCRIBED);
// Set initial velocity
m_pDOF->setInitVel(dof, fInitialVelocity);
// Set motion type and magnitude
FmDofMotion* pMotion = m_pDOF->getMotionAtDOF(dof,true);
pMotion->setMotionType((FmDofMotion::MotionType)(int)MotionType);
pMotion->setInitMotion(fMotionMagnitude);
pMotion->setEngine(dynamic_cast<FmEngine*>(pMotionMagnitudeFunction));
m_pDOF->onChanged();
}
void CaDOF::SetSpringDamper(const VARIANT FAR& LoadMagnitude,
const VARIANT FAR& StressfreeLength, const VARIANT FAR& Stiffness,
const VARIANT FAR& StiffnessScale, const VARIANT FAR& Damper,
const VARIANT FAR& DamperScale, const VARIANT FAR& InitialVelocity)
{
this->checkMe();
// Get function parameters.
// Note: Function parameters can be a double, a function name or an IFunction.
// Load magnitude
double fLoadMagnitude = 0.0;
FmModelMemberBase* pLoadMagnitudeFunction = NULL;
CaApplication::GetFunctionParameter(LoadMagnitude, &fLoadMagnitude, &pLoadMagnitudeFunction);
// Stressfree length
double fStressfreeLength = 0.0;
FmModelMemberBase* pStressfreeLengthFunction = NULL;
CaApplication::GetFunctionParameter(StressfreeLength, &fStressfreeLength, &pStressfreeLengthFunction);
// Stiffness
double fStiffness = 0.0;
FmModelMemberBase* pStiffnessFunction = NULL;
CaApplication::GetFunctionParameter(Stiffness, &fStiffness, &pStiffnessFunction);
// StiffnessScale
double fStiffnessScale = 0.0;
FmModelMemberBase* pStiffnessScaleFunction = NULL;
CaApplication::GetFunctionParameter(StiffnessScale, &fStiffnessScale, &pStiffnessScaleFunction);
// Damper
double fDamper = 0.0;
FmModelMemberBase* pDamperFunction = NULL;
CaApplication::GetFunctionParameter(Damper, &fDamper, &pDamperFunction);
// DamperScale
double fDamperScale = 0.0;
FmModelMemberBase* pDamperScaleFunction = NULL;
CaApplication::GetFunctionParameter(DamperScale, &fDamperScale, &pDamperScaleFunction);
// Convert to double
VARIANT varR8;
VariantInit(&varR8);
VariantChangeType(&varR8, &InitialVelocity, 0, VT_R8);
double fInitialVelocity = varR8.vt == VT_R8 ? varR8.dblVal : 0.0;
// Note: I have not added checking/searching for sd-only functions.
int dof = m_nDOFIndex - 1;
// Set status
m_pDOF->setStatusForDOF(dof, FmHasDOFsBase::DOFStatus::SPRING_CONSTRAINED);
// Set initial velocity
m_pDOF->setInitVel(dof, fInitialVelocity);
// Set load magnitude
FmDofLoad* pLoad = m_pDOF->getLoadAtDOF(dof,true);
pLoad->setInitLoad(fLoadMagnitude);
pLoad->setEngine(dynamic_cast<FmEngine*>(pLoadMagnitudeFunction));
FmJointBase* pJoint = dynamic_cast<FmJointBase*>(m_pDOF);
if (pJoint != NULL)
{
// Set stiffness & stressfree length
FmJointSpring* pSpring = pJoint->getSpringAtDOF(dof,true);
pSpring->setInitStiff(fStiffness);
pSpring->setSpringCharOrStiffFunction(pStiffnessFunction);
pSpring->setInitLengthOrDefl(fStressfreeLength);
pSpring->setLengthEngine(dynamic_cast<FmEngine*>(pStressfreeLengthFunction));
pSpring->setScaleEngine(dynamic_cast<FmEngine*>(pStiffnessScaleFunction));
// Set damper
FmJointDamper* pDamper = pJoint->getDamperAtDOF(dof,true);
pDamper->setInitDamp(fDamper);
pDamper->setFunction(dynamic_cast<FmMathFuncBase*>(pDamperFunction));
pDamper->setDampEngine(dynamic_cast<FmEngine*>(pDamperScaleFunction));
}
m_pDOF->onChanged();
}
//////////////////////////////////////////////////////////////////////
// Implementation
STDMETHODIMP_(ULONG) CaDOF::XLocalClass::AddRef()
{
METHOD_PROLOGUE(CaDOF, LocalClass)
return pThis->ExternalAddRef();
}
STDMETHODIMP_(ULONG) CaDOF::XLocalClass::Release()
{
METHOD_PROLOGUE(CaDOF, LocalClass)
return pThis->ExternalRelease();
}
STDMETHODIMP CaDOF::XLocalClass::QueryInterface(
REFIID iid, LPVOID* ppvObj)
{
METHOD_PROLOGUE(CaDOF, LocalClass)
return pThis->ExternalQueryInterface(&iid, ppvObj);
}
STDMETHODIMP CaDOF::XLocalClass::GetTypeInfoCount(
UINT FAR* pctinfo)
{
METHOD_PROLOGUE(CaDOF, LocalClass)
LPDISPATCH lpDispatch = pThis->GetIDispatch(FALSE);
ASSERT(lpDispatch != NULL);
return lpDispatch->GetTypeInfoCount(pctinfo);
}
STDMETHODIMP CaDOF::XLocalClass::GetTypeInfo(
UINT itinfo, LCID lcid, ITypeInfo FAR* FAR* pptinfo)
{
METHOD_PROLOGUE(CaDOF, LocalClass)
LPDISPATCH lpDispatch = pThis->GetIDispatch(FALSE);
ASSERT(lpDispatch != NULL);
return lpDispatch->GetTypeInfo(itinfo, lcid, pptinfo);
}
STDMETHODIMP CaDOF::XLocalClass::GetIDsOfNames(
REFIID riid, OLECHAR FAR* FAR* rgszNames, UINT cNames,
LCID lcid, DISPID FAR* rgdispid)
{
METHOD_PROLOGUE(CaDOF, LocalClass)
LPDISPATCH lpDispatch = pThis->GetIDispatch(FALSE);
ASSERT(lpDispatch != NULL);
return lpDispatch->GetIDsOfNames(riid, rgszNames, cNames,
lcid, rgdispid);
}
STDMETHODIMP CaDOF::XLocalClass::Invoke(
DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags,
DISPPARAMS FAR* pdispparams, VARIANT FAR* pvarResult,
EXCEPINFO FAR* pexcepinfo, UINT FAR* puArgErr)
{
METHOD_PROLOGUE(CaDOF, LocalClass)
LPDISPATCH lpDispatch = pThis->GetIDispatch(FALSE);
ASSERT(lpDispatch != NULL);
return lpDispatch->Invoke(dispidMember, riid, lcid,
wFlags, pdispparams, pvarResult,
pexcepinfo, puArgErr);
}
// Note: The following wrapper code will only be called by TLB
// interface calls, and not by IDispatch calls. So, you should
// only forward this call to the code in the methods part here
// (see further up in this file).
STDMETHODIMP CaDOF::XLocalClass::get_DOFConstraintType(DOFConstraintType* pVal)
{
METHOD_PROLOGUE(CaDOF, LocalClass);
TRY
{
*pVal = pThis->get_DOFConstraintType();
}
CATCH_ALL(e)
{
return ResultFromScode(COleException::Process(e));
}
END_CATCH_ALL
return S_OK;
}
STDMETHODIMP CaDOF::XLocalClass::put_DOFConstraintType(DOFConstraintType Val)
{
METHOD_PROLOGUE(CaDOF, LocalClass);
TRY
{
pThis->put_DOFConstraintType(Val);
}
CATCH_ALL(e)
{
return ResultFromScode(COleException::Process(e));
}
END_CATCH_ALL
return S_OK;
}
STDMETHODIMP CaDOF::XLocalClass::get_InitialVelocity(double* pVal)
{
METHOD_PROLOGUE(CaDOF, LocalClass);
TRY
{
*pVal = pThis->get_InitialVelocity();
}
CATCH_ALL(e)
{
return ResultFromScode(COleException::Process(e));
}
END_CATCH_ALL
return S_OK;
}
STDMETHODIMP CaDOF::XLocalClass::get_AddBC(VARIANT_BOOL* pVal)
{
METHOD_PROLOGUE(CaDOF, LocalClass);
TRY
{
*pVal = pThis->get_AddBC();
}
CATCH_ALL(e)
{
return ResultFromScode(COleException::Process(e));
}
END_CATCH_ALL
return S_OK;
}
STDMETHODIMP CaDOF::XLocalClass::put_AddBC(VARIANT_BOOL Val)
{
METHOD_PROLOGUE(CaDOF, LocalClass);
TRY
{
pThis->put_AddBC(Val);
}
CATCH_ALL(e)
{
return ResultFromScode(COleException::Process(e));
}
END_CATCH_ALL
return S_OK;
}
STDMETHODIMP CaDOF::XLocalClass::get_LoadMagnitude(VARIANT* pVal)
{
METHOD_PROLOGUE(CaDOF, LocalClass);
TRY
{
*pVal = pThis->get_LoadMagnitude();
}
CATCH_ALL(e)
{
return ResultFromScode(COleException::Process(e));
}
END_CATCH_ALL
return S_OK;
}
STDMETHODIMP CaDOF::XLocalClass::get_PrescribedMotionType(DOFPrescribedMotionType* pVal)
{
METHOD_PROLOGUE(CaDOF, LocalClass);
TRY
{
*pVal = pThis->get_PrescribedMotionType();
}
CATCH_ALL(e)
{
return ResultFromScode(COleException::Process(e));
}
END_CATCH_ALL
return S_OK;
}
STDMETHODIMP CaDOF::XLocalClass::get_PrescribedMotionMagnitude(VARIANT* pVal)
{
METHOD_PROLOGUE(CaDOF, LocalClass);
TRY
{
*pVal = pThis->get_PrescribedMotionMagnitude();
}
CATCH_ALL(e)
{
return ResultFromScode(COleException::Process(e));
}
END_CATCH_ALL
return S_OK;
}
STDMETHODIMP CaDOF::XLocalClass::get_SDStressfreeLength(VARIANT* pVal)
{
METHOD_PROLOGUE(CaDOF, LocalClass);
TRY
{
*pVal = pThis->get_SDStressfreeLength();
}
CATCH_ALL(e)
{
return ResultFromScode(COleException::Process(e));
}
END_CATCH_ALL
return S_OK;
}
STDMETHODIMP CaDOF::XLocalClass::get_SDStiffness(VARIANT* pVal)
{
METHOD_PROLOGUE(CaDOF, LocalClass);
TRY
{
*pVal = pThis->get_SDStiffness();
}
CATCH_ALL(e)
{
return ResultFromScode(COleException::Process(e));
}
END_CATCH_ALL
return S_OK;
}
STDMETHODIMP CaDOF::XLocalClass::get_SDStiffnessScale(VARIANT* pVal)
{
METHOD_PROLOGUE(CaDOF, LocalClass);
TRY
{
*pVal = pThis->get_SDStiffnessScale();
}
CATCH_ALL(e)
{
return ResultFromScode(COleException::Process(e));
}
END_CATCH_ALL
return S_OK;
}
STDMETHODIMP CaDOF::XLocalClass::get_SDDamper(VARIANT* pVal)
{
METHOD_PROLOGUE(CaDOF, LocalClass);
TRY
{
*pVal = pThis->get_SDDamper();
}
CATCH_ALL(e)
{
return ResultFromScode(COleException::Process(e));
}
END_CATCH_ALL
return S_OK;
}
STDMETHODIMP CaDOF::XLocalClass::get_SDDamperScale(VARIANT* pVal)
{
METHOD_PROLOGUE(CaDOF, LocalClass);
TRY
{
*pVal = pThis->get_SDDamperScale();
}
CATCH_ALL(e)
{
return ResultFromScode(COleException::Process(e));
}
END_CATCH_ALL
return S_OK;
}
STDMETHODIMP CaDOF::XLocalClass::SetFree(VARIANT LoadMagnitude, VARIANT InitialVelocity)
{
METHOD_PROLOGUE(CaDOF, LocalClass);
TRY
{
pThis->SetFree(LoadMagnitude, InitialVelocity);
}
CATCH_ALL(e)
{
return ResultFromScode(COleException::Process(e));
}
END_CATCH_ALL
return S_OK;
}
STDMETHODIMP CaDOF::XLocalClass::SetFixed()
{
METHOD_PROLOGUE(CaDOF, LocalClass);
TRY
{
pThis->SetFixed();
}
CATCH_ALL(e)
{
return ResultFromScode(COleException::Process(e));
}
END_CATCH_ALL
return S_OK;
}
STDMETHODIMP CaDOF::XLocalClass::SetPrescribed(DOFPrescribedMotionType MotionType,
VARIANT MotionMagnitude, VARIANT InitialVelocity)
{
METHOD_PROLOGUE(CaDOF, LocalClass);
TRY
{
pThis->SetPrescribed(MotionType, MotionMagnitude, InitialVelocity);
}
CATCH_ALL(e)
{
return ResultFromScode(COleException::Process(e));
}
END_CATCH_ALL
return S_OK;
}
STDMETHODIMP CaDOF::XLocalClass::SetSpringDamper(VARIANT LoadMagnitude,
VARIANT StressfreeLength, VARIANT Stiffness, VARIANT StiffnessScale,
VARIANT Damper, VARIANT DamperScale, VARIANT InitialVelocity)
{
METHOD_PROLOGUE(CaDOF, LocalClass);
TRY
{
pThis->SetSpringDamper(LoadMagnitude, StressfreeLength, Stiffness, StiffnessScale,
Damper, DamperScale, InitialVelocity);
}
CATCH_ALL(e)
{
return ResultFromScode(COleException::Process(e));
}
END_CATCH_ALL
return S_OK;
}