-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCurveView.cpp
More file actions
5529 lines (5331 loc) · 175 KB
/
CurveView.cpp
File metadata and controls
5529 lines (5331 loc) · 175 KB
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
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// CurveView.cpp : implementation file
//
#include "stdafx.h"
#include "SID_2FY.h"
#include "CurveView.h"
#include "MainFrm.h"
#include <queue>
#include "CurvePrintSet.h"
#include <math.h>
#include "dMessageBox.h"
#include "WareEventData.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define PI 3.1415926 //π
extern CMySID_2FYApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CCurveView
//判断浮点数是是否为0
long DoubleCmp(double d)
{
//1e-8=10的负8次方
if(fabs(d)<Precision) return 0;
return (d>0)?1:-1;
}
Point::Point(double _x,double _y)
{
x=_x;
y=_y;
}
//重载<用于二分搜索
bool Point::operator <(Point p)
{
if(DoubleCmp(x-p.x)<0) return true;
return false;
}
//重载 == 用于二分搜索
bool Point::operator ==(Point p)
{
if(DoubleCmp(x-p.x)==0) return true;
return false;
}
//重载-用于二分搜索
Point Point::operator -(const Point p)
{
Point re;
re.x=this->x-p.x;
return re;
}
Point & Point::operator =(const Point & pt)
{
if(this == &pt)
{
return *this;
}
extendValue = pt.extendValue;
x=pt.x;
y=pt.y;
return *this;
}
BOOL CCurveView::m_isFirstShow = FALSE;
IMPLEMENT_DYNCREATE(CCurveView, CScrollView)
/***********************************************
完成变量的初始化
***********************************************/
CCurveView::CCurveView():m_nHeightOfRCScale(20),m_nHeightOfScale(5),m_nMinWidthOfDisScale(5),
m_nMinWidthOfLogScale(1),m_nMinGirdWidth(50),m_nMinGirdHeight(10),m_pCurve(NULL),m_bPrint(FALSE),
m_bMultiColorDis(TRUE),m_dWindowSizeOfX(1000),m_dInitDisPosOfx(-300)
{
memset(m_arrPageHeadInfo,0,sizeof(m_arrPageHeadInfo));
m_dValueOfClick = 0;
m_nHeightOfDigitalCoor = DIGITAL_HEIGHTH_COONDIATE;
m_nHeightOfAnalogCoor = ANALOG_HEIGHTH_COONDIATE;
m_nMaxOfX=0;
m_dMulti=1;
m_dNewMulti = 1;
m_nCellOfX=1;
m_bkColor=RGB(255,255,255);
m_crossLineColor=RGB(0,0,255);
m_coordinateColor=RGB(0,0,255);
m_colorGirdLine =RGB(210,210,210);
m_pCurve=NULL;
m_nCurveCount=0;
m_strValueType=_T("");
m_colorArray[0]=RGB(0,0,0); //黑色,脉振电源
m_colorArray[1]=RGB(0,255,255); //主控插件相角差和系统侧角转差
m_colorArray[2]=RGB(255,0,255); //主控插件US
m_colorArray[3]=RGB(128,0,0); //主控插件Ug
m_colorArray[4]=RGB(128,128,0); //合闸出口
m_colorArray[5]=RGB(0,128,0); //升压
m_colorArray[6]=RGB(128,128,255); //降压
m_colorArray[7]=RGB(0,128,128); //加速
m_colorArray[8]=RGB(128,0,128); //主控插件US频率
m_colorArray[9]=RGB(0,255,128); //主控插件Ug频率
m_colorArray[10]=RGB(0,128,255); //
m_colorArray[11]=RGB(0,0,255); //
m_colorStartLine = RGB(255,0,0); //红色,启动录波线的颜色
m_clientRc = CRect(0,0,0,0);
m_dMinFreq = 30;
m_dMaxFreq = 70;
m_isUnitedFile=false;
m_diffMilli=0;
intersect=0;
m_dota = 0;
m_isLabel=false;
m_bFirstShow=false;
m_flagShow = ALL_VALUE_SHOW;
m_TimeCloseOut = 0;
memset(m_average,0,sizeof(m_average));
m_fMZstartDota = 0;
m_fMZreturnDota = 0;
//
lpStaPhaseAngle = NULL;
lpRetPhaseAngle = NULL;
}
CCurveView::~CCurveView()
{
CCurveView::Release(m_pCurve,m_nCurveCount);
OnReleaseAngle();
}
/*********************************************
消息命令的监听设置
*********************************************/
BEGIN_MESSAGE_MAP(CCurveView, CMyView)
//{{AFX_MSG_MAP(CCurveView)
ON_WM_RBUTTONDOWN()
ON_COMMAND(ID_FILE_PRINT, OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview)
ON_WM_KEYDOWN()
ON_WM_PAINT()
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONDOWN()
ON_COMMAND(IDM_ACHROMATIC,OnAchromatic)
ON_COMMAND(IDM_DYEING,OnDyeing)
ON_COMMAND(IDM_SHOW_VALID,OnShowValid)
ON_COMMAND(IDM_SHOW_SAMPLE,OnShowSample)
ON_COMMAND(IDM_SHOW_ALL,OnShowAll)
ON_COMMAND(IDM_CURVE_DIS_SET,OnCurveDisSet)
ON_COMMAND(ID_FILE_PRINT_SETUP, OnFilePrintSetup)
ON_COMMAND(IDM_EXPORT_WARE_TEXT, OnExportWareFile) //2016-5-5 add 导出波形文件Text
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCurveView drawing
/***********************************
状态栏的设置
***********************************/
void CCurveView::OnInitialUpdate()
{
//这里是设置状态栏的
CScrollView::OnInitialUpdate();
((CMainFrame *)GetParentFrame())->m_wndStatusBar.SetPaneInfo(1,IDS_SUB_TIME,SBPS_NORMAL, 230);
((CMainFrame *)GetParentFrame())->m_wndStatusBar.SetPaneInfo(2,IDS_INDICATOR_TIME,SBPS_NORMAL,190);
GetClientRect(&m_curRect);
CSize sizeTotal;
// TODO: calculate the total size of this view
sizeTotal.cx = sizeTotal.cy = 300;
SetScrollSizes(MM_TEXT, sizeTotal);
}
void CCurveView::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// TODO: add draw code here
}
#ifdef _DEBUG
void CCurveView::AssertValid() const
{
CScrollView::AssertValid();
}
void CCurveView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CCurveView message handlers
/***********************
当键盘的按键除alt F10按下的时候
************************/
void CCurveView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
CRect rc;
switch(nChar)
{
case VK_LEFT://按下键盘左方向键,跟随鼠标移动的x=m_mousePoint.x竖线向左一个像素一个像素地平移
if(m_mousePoint.x >CHANNEL_INFO_WIDTH)
{
m_mousePoint.x--;
}
else if(m_mousePoint.x<=CHANNEL_INFO_WIDTH)
{
m_mousePoint.x=CHANNEL_INFO_WIDTH;
}
break;
case VK_RIGHT://按下键盘右方向键,跟随鼠标移动的x=m_mousePoint.x竖线向右一个像素一个像素地平移
GetClientRect(&rc);
if(m_mousePoint.x<CHANNEL_INFO_WIDTH)
{
m_mousePoint.x=CHANNEL_INFO_WIDTH;
}
else if(m_mousePoint.x <=rc.right)
{
m_mousePoint.x++;
}
break;
case VK_RETURN://按下键盘enter键,测量时间的基线移动到m_mousePoint.x处
{
//曲线绘制区域的大小为m_rectCurve(230,20,1116,1120);
//这是一个结构体
Point pLogic;
POINT origital;
origital.x = m_rectCurve.left;
origital.y = m_nHeightOfAnalogCoor/2;
m_mousePoint.x += m_curRect.left;
if(m_mousePoint.x<CHANNEL_INFO_WIDTH)
{
m_mousePoint.x=CHANNEL_INFO_WIDTH;
}
//获取鼠标点的横坐标
MapPointToLogic(m_mousePoint,pLogic,0,origital,m_nHeightOfAnalogCoor/CELL_COUNT);
m_dValueOfClick = pLogic.x;
m_mousePoint.x -= m_curRect.left;
break;
}
default:
break;
}
::RedrawWindow(m_hWnd,NULL,NULL,RDW_INVALIDATE|RDW_UPDATENOW|RDW_ALLCHILDREN);
CScrollView::OnKeyDown(nChar, nRepCnt, nFlags);
}
/***********************************************************************************
函数名:MapPointToLogic
描述:将显示区域的显示坐标转化为逻辑坐标(显示坐标以像素为单位)
参数:p1[in]: p2[out]: cellOfY[in]: nWidthOfcell[in]:
返回值
***********************************************************************************/
Point CCurveView::MapPointToLogic(POINT p1, Point &p2,double cellOfY,POINT origitalPoint,int nWidthOfCell)
{
int xWidthOfCell;
if(m_bPrint)
{
//3 60 20CELL_COUNT 1倍格刻度线的宽度
xWidthOfCell = abs(m_nHeightOfAnalogCoor/CELL_COUNT);
}
else
{
//60
xWidthOfCell=ANALOG_HEIGHTH_COONDIATE/CELL_COUNT;
}
//m_dMulti倍数;m_nCellOfX=X轴上一个刻度的逻辑值
//p2.x当前的逻辑值,求出刻度的个数然后乘以刻度的逻辑值
p2.x=(double)(p1.x-origitalPoint.x)/(xWidthOfCell*m_dMulti)*m_nCellOfX;
//标么值
p2.y=(double)(origitalPoint.y-p1.y)/nWidthOfCell/cellOfY;
return p2;
}
/********************************
第一次显示录波文件或者录波文件切换 主要是进行数据的拷贝
********************************/
void CCurveView::ChangeCurve(Curve *pCurve,long count,bool isUnitedFile,int diffMilli,char ps)
{
//判断是否是1次值或者2次值
ASSERT(ps=='p'||ps=='s'||ps=='P'||ps=='S');
if(ps=='p'||ps=='P') m_strValueType=_T("一次值");
else m_strValueType=_T("二次值");
//是否为合并波形
m_isUnitedFile=isUnitedFile;
//不懂什么用
m_diffMilli=diffMilli;
//定义的频率,振幅和角度
double freq,swing,angle;
int angleIndex = -1;
//600个结构体数组里面存储的是瞬时值,标幺值、逻辑值
Point AngleAnalyse[2][300]; //3S的有效值空间
//为什么是32
int halfPointCnt = 32;
//清空函数
CCurveView::Release(m_pCurve,m_nCurveCount);
OnReleaseAngle();
//获取框架的索引
CMainFrame * pMainFrm = (CMainFrame *)GetParentFrame();
int i,j,temp_n;
CString str;
//定义两个容器
queue<int> qVolIndex,qCurrentIndex;
//定义一堆的double型数据
double dMaxOfX=0,dMaxVolY=0,dMaxCurrentY=0,dMaxVal,dVolMinRange,dCurrentMinRange;
//字符型数据
wchar_t cUint;
double dValueOfCellY;
BOOL isRecord = FALSE,isShowCurveMZ=false;
i = 0;
//如果结构体的第一个成员的单位不为空
//是否显示脉振电压/角差
if (pCurve[0].unit != _T(""))
{
//第一个成员的单位的最后一位是不是"V"
cUint = pCurve[0].unit[pCurve[0].unit.GetLength()-1];
if(cUint == TEXT('v') || cUint == TEXT('V'))
{
//结构体的第一个成员和第二个成员的单位数据是否一致
if (pCurve[0].unit == pCurve[1].unit)
{
i = 1;
count += 1;
//
isShowCurveMZ = TRUE;
}
}
//第2个成员的单位时候等于第三个成员的单位
else if (pCurve[1].unit == pCurve[2].unit)
{
//如果第二个成员的单位不为空
if (pCurve[1].unit != _T(""))
{
//获取单位的数据中的最后一位
cUint = pCurve[1].unit[pCurve[1].unit.GetLength()-1];
//如果最后一位为"V"
if(cUint == TEXT('v') || cUint == TEXT('V'))
{
i = 1;
count += 1;
isShowCurveMZ = TRUE; //显示脉振电压
}
}
}
}
//通过计算记录了43条曲线
m_nCurveCount = count;
//相当于开辟一个结构体指针数据,里面存储的都是结构体
m_pCurve = new Curve[m_nCurveCount];
//用于补偿最后点数不够的问题,即50个点只能连49条线,此处需要51个点才能连出50线,后面同理
for(int curveIndex = 0;i < m_nCurveCount;i++ , curveIndex++)
{
//你会观察到是比cuiveIndex大1
//开始采样点数组51
m_pCurve[i].lpStaPoint=new Point[pCurve[curveIndex].StaCount+1];
//返回采样点数组5951
m_pCurve[i].lpRetPoint=new Point[pCurve[curveIndex].RetCount+1];
//起始断点数组0,1600,800
m_pCurve[i].lpStartSecPoint=new Point[pCurve[curveIndex].startCount];
//返回段点数组0,4800,240
m_pCurve[i].lpReturnSecPoint=new Point[pCurve[curveIndex].returnCount];
//如果开辟空间失败,就清除该空间
if(m_pCurve[i].lpStaPoint == NULL)
{
CCurveView::Release(m_pCurve,m_nCurveCount);
m_pCurve = NULL;
return;
}
//全程启动段点数50
m_pCurve[i].StaCount=pCurve[curveIndex].StaCount;
//全程返回段点数5950
m_pCurve[i].RetCount=pCurve[curveIndex].RetCount;
//子项序号5,0,1
m_pCurve[i].nSubItemIndex = pCurve[curveIndex].nSubItemIndex;
//通道序号5,0,1
m_pCurve[i].nChannelIndex = pCurve[curveIndex].nChannelIndex;
//第一个采样点时间
m_pCurve[i].firstSampleTime=pCurve[curveIndex].firstSampleTime;
//第一个采样点的ms数
m_pCurve[i].milliSecondOfFirst=pCurve[curveIndex].milliSecondOfFirst;
//启动录波时间
m_pCurve[i].startTime=pCurve[curveIndex].startTime;
//采样启动段点数
m_pCurve[i].startCount = pCurve[curveIndex].startCount;
//曲线返回段点数
m_pCurve[i].returnCount = pCurve[curveIndex].returnCount;
//曲线颜色
m_pCurve[i].color=m_colorArray[i%COLOR_NUM];
//最小的逻辑坐标值
m_pCurve[i].minRange=pCurve[curveIndex].minRange;
//是否有开入开出量
m_pCurve[i].bIsDigital = pCurve[curveIndex].bIsDigital;
//是否有起始段,返回段
m_pCurve[i].bIsOverlap = pCurve[curveIndex].bIsOverlap;
//计算频率和相位角0,64,64,32
m_pCurve[i].nPointInCircle = pCurve[curveIndex].nPointInCircle;
//通道名称
m_pCurve[i].name = pCurve[curveIndex].name;
//单位
m_pCurve[i].unit = pCurve[curveIndex].unit;
//不设与设为0都是默认系统设置
m_pCurve[i].valueOfCellY = pCurve[curveIndex].valueOfCellY;
//上面感觉就是开辟空间和赋值
dMaxVal = 0;
int sampleRetBegin=0;
//下面是计算返回段开始显示的时间
if(m_diffMilli>0)
{
//相交
intersect=1000;
m_dota=m_diffMilli;
str.Format(_T("△t =%dms"),m_dota);
m_strDota=str;
m_isLabel=true;
//58500 pCurve[1].nPointInCircle=64
sampleRetBegin = 60000 - pCurve[1].returnCount*1.0/pCurve[1].nPointInCircle*20;
}
else if (pCurve[2].nPointInCircle != 0 )
{//返回段开始显示的时间
sampleRetBegin = pMainFrm->m_wareFileData.m_nCycleCount*20- pCurve[2].returnCount*1.0/pCurve[2].nPointInCircle*20;
}
else if ( pCurve[1].nPointInCircle != 0 )
{//2015-1-30 add 如果不显示角差,待并侧电压ug就在pCruve[1]
sampleRetBegin = pMainFrm->m_wareFileData.m_nCycleCount*20- pCurve[1].returnCount*1.0/pCurve[1].nPointInCircle*20;
}
else
{
sampleRetBegin = 0;
}
if (!m_isFirstShow)
{
sampleRetBegin = 0;
intersect = 0;
}
//这里将所有连续的电压量(或电流)使用同样的Y坐标刻度变比,是为了让用户从界面上就能看出各条曲线的
//电压(或电流)量的大小,这里只有开入开出量才会设置Y轴上单位刻度所代表的逻辑值(valueOfCellY),
//模拟量的valueOfCellY为0,也就是未设置,一个坐标系中,Y轴的正负轴各有十个单位刻度,每个单位刻度
//可以表示一个浮点数的逻辑值,所以很小的数据,也可以在界面得到放大显示,minRange,用于设置坐标系
//的显示逻辑值范围的最小值
//是否有开入开出量
//是开入开出量
if(m_pCurve[i].bIsDigital)
{
//曲线全程启动段点数
for(j=0;j<pCurve[curveIndex].StaCount;j++)
{
//把原本的结构体0的全程启动段采样点数组,赋值到新结构体1里面
m_pCurve[i].lpStaPoint[j]=pCurve[curveIndex].lpStaPoint[j];
//不被进入
if(m_pCurve[i].lpStaPoint[j].x>dMaxOfX)
{
dMaxOfX=m_pCurve[i].lpStaPoint[j].x;
}
}
//lpStaPoint里面的最后一个值和前面的值一样,且最后会在它的X值上+10
m_pCurve[i].lpStaPoint[j]=m_pCurve[i].lpStaPoint[j-1];
m_pCurve[i].lpStaPoint[j].x+=10;
//曲线全程返回段点数
for(j=0;j<pCurve[i].RetCount;j++)
{
//新的结构体的retpoint等于原来的数据,且在它的X的基础上加上相交的坐标点的个数
m_pCurve[i].lpRetPoint[j]=pCurve[curveIndex].lpRetPoint[j];
m_pCurve[i].lpRetPoint[j].x+=intersect;
//不被进入
if(m_pCurve[i].lpRetPoint[j].x>dMaxOfX)
{
dMaxOfX=m_pCurve[i].lpRetPoint[j].x;
}
}
//RetCount里面的最后一个值和前面的值一样,且最后会在它的X值上+10
m_pCurve[i].lpRetPoint[j]=m_pCurve[i].lpRetPoint[j-1];
m_pCurve[i].lpRetPoint[j].x+=10;
//曲线采样启动段点数
for (j=0;j<pCurve[curveIndex].startCount;j++)
{
m_pCurve[i].lpStartSecPoint[j]=pCurve[curveIndex].lpStartSecPoint[j];
//不被进入
if(m_pCurve[i].lpStartSecPoint[j].x>dMaxOfX)
{
dMaxOfX=m_pCurve[i].lpStartSecPoint[j].x;
}
}
//曲线采样返回段点数
for (j=0;j<pCurve[curveIndex].returnCount;j++)
{
//lpReturnSecPoint在原来的基础上加上相交的点数和时间
m_pCurve[i].lpReturnSecPoint[j]=pCurve[curveIndex].lpReturnSecPoint[j];
//59500=58500+1000(intersect)
m_pCurve[i].lpReturnSecPoint[j].x+=(intersect+sampleRetBegin);
//不被进入
if(m_pCurve[i].lpReturnSecPoint[j].x>dMaxOfX)
{
dMaxOfX=m_pCurve[i].lpReturnSecPoint[j].x;
}
//如果有合闸出口这个通道的话
if (pCurve[curveIndex].lpReturnSecPoint[j].y && (m_pCurve[i].name.Find(_T("合闸出口")) >= 0 || m_pCurve[i].name.Find(_T("Close Outlet")) >= 0 ) && !isRecord)
{
isRecord = TRUE;
//0
m_TimeCloseOut = pCurve[curveIndex].lpReturnSecPoint[j].x+sampleRetBegin;
}
}
}
//如果不是开入开出量
else
{
//获取单位的数据中的最后一位
cUint = m_pCurve[i].unit[m_pCurve[i].unit.GetLength()-1];
//如果单位为安培的话
if(cUint == TEXT('a') || cUint == TEXT('A'))
{
//逻辑值的值的范围最小不能小于minRange
dCurrentMinRange = m_pCurve[i].minRange;
qCurrentIndex.push(i);
//50曲线全程启动段点数
for(j=0;j<pCurve[curveIndex].StaCount;j++)
{
m_pCurve[i].lpStaPoint[j]=pCurve[curveIndex].lpStaPoint[j];
//比较大小
if(DoubleCmp(m_pCurve[i].lpStaPoint[j].x-dMaxOfX)>0)
{
dMaxOfX=m_pCurve[i].lpStaPoint[j].x;
}
if(DoubleCmp(fabs(m_pCurve[i].lpStaPoint[j].y)-dMaxVolY)>0)
{
dMaxVolY = fabs(m_pCurve[i].lpStaPoint[j].y);
}
}
m_pCurve[i].lpStaPoint[j]=m_pCurve[i].lpStaPoint[j-1];
m_pCurve[i].lpStaPoint[j].x+=10;
//5950
//曲线全程返回段点数
for(j=0;j<pCurve[curveIndex].RetCount;j++)
{
//它的x需要加上相交数
m_pCurve[i].lpRetPoint[j]=pCurve[curveIndex].lpRetPoint[j];
m_pCurve[i].lpRetPoint[j].x+=intersect;
if(DoubleCmp(m_pCurve[i].lpRetPoint[j].x-dMaxOfX)>0)
{
dMaxOfX=m_pCurve[i].lpRetPoint[j].x;
}
if(DoubleCmp(fabs(m_pCurve[i].lpRetPoint[j].y)-dMaxCurrentY)>0)
{
dMaxCurrentY = fabs(m_pCurve[i].lpRetPoint[j].y);
}
}
m_pCurve[i].lpRetPoint[j]=m_pCurve[i].lpRetPoint[j-1];
m_pCurve[i].lpRetPoint[j].x+=10;
//曲线采样启动段点数
for (j = 0; j< m_pCurve[i].startCount ; j++)
{
m_pCurve[i].lpStartSecPoint[j]=pCurve[curveIndex].lpStartSecPoint[j];
if(DoubleCmp(m_pCurve[i].lpStartSecPoint[j].x-dMaxOfX)>0)
{
dMaxOfX=m_pCurve[i].lpStartSecPoint[j].x;
}
if(DoubleCmp(fabs(m_pCurve[i].lpStartSecPoint[j].y)-dMaxCurrentY)>0)
{
dMaxCurrentY = fabs(m_pCurve[i].lpStartSecPoint[j].y);
}
}
//曲线采样返回段点数
for (j = 0; j< m_pCurve[i].returnCount ; j++)
{
m_pCurve[i].lpReturnSecPoint[j]=pCurve[curveIndex].lpReturnSecPoint[j];
m_pCurve[i].lpReturnSecPoint[j].x+=(intersect+sampleRetBegin);
if(DoubleCmp(m_pCurve[i].lpReturnSecPoint[j].x-dMaxOfX)>0)
{
dMaxOfX=m_pCurve[i].lpReturnSecPoint[j].x;
}
if(DoubleCmp(fabs(m_pCurve[i].lpReturnSecPoint[j].y)-dMaxCurrentY)>0)
{
dMaxCurrentY = fabs(m_pCurve[i].lpReturnSecPoint[j].y);
}
}
}
//只有通道2,通道3会传入进去 当这条通道信息的单位为伏特的时候
else if(cUint == TEXT('v') || cUint == TEXT('V'))
{
//获取通道的索引
angleIndex = m_pCurve[i].nChannelIndex;//刚好采样模块量有两个通道,第一us,第二个ug,
//最小逻辑值
dVolMinRange = m_pCurve[i].minRange;
//是第几条通道
qVolIndex.push(i);
//简单的赋值运算 传入的时候好像并没有角差这类东西
for(j=0;j<pCurve[curveIndex].StaCount;j++)
{
m_pCurve[i].lpStaPoint[j]=pCurve[curveIndex].lpStaPoint[j];
if(DoubleCmp(m_pCurve[i].lpStaPoint[j].x-dMaxOfX)>0)
{
dMaxOfX=m_pCurve[i].lpStaPoint[j].x;
}
if(DoubleCmp(fabs(m_pCurve[i].lpStaPoint[j].y)-dMaxVolY)>0)
{
dMaxVolY = fabs(m_pCurve[i].lpStaPoint[j].y);
}
}
m_pCurve[i].lpStaPoint[j]=m_pCurve[i].lpStaPoint[j-1];
m_pCurve[i].lpStaPoint[j].x+=10;
for(j=0;j<pCurve[i].RetCount;j++)
{
m_pCurve[i].lpRetPoint[j]=pCurve[curveIndex].lpRetPoint[j];
m_pCurve[i].lpRetPoint[j].x+=intersect;
if(DoubleCmp(m_pCurve[i].lpRetPoint[j].x-dMaxOfX)>0)
{
dMaxOfX=m_pCurve[i].lpRetPoint[j].x;
}
if(DoubleCmp(fabs(m_pCurve[i].lpRetPoint[j].y)-dMaxCurrentY)>0)
{
dMaxCurrentY = fabs(m_pCurve[i].lpRetPoint[j].y);
}
}
m_pCurve[i].lpRetPoint[j]=m_pCurve[i].lpRetPoint[j-1];
m_pCurve[i].lpRetPoint[j].x+=10;
int index=0;
halfPointCnt =m_pCurve[i].nPointInCircle/2;
//1600曲线采样启动段点数 表示启动采样段点数组的长度为1600 保存电压的采样值
for (j = 0; j< m_pCurve[i].startCount ; j++)
{
m_pCurve[i].lpStartSecPoint[j]=pCurve[curveIndex].lpStartSecPoint[j];
if(DoubleCmp(m_pCurve[i].lpStartSecPoint[j].x-dMaxOfX)>0)
{
dMaxOfX=m_pCurve[i].lpStartSecPoint[j].x;
}
if(DoubleCmp(fabs(m_pCurve[i].lpStartSecPoint[j].y)-dMaxVolY)>0)
{
dMaxVolY = fabs(m_pCurve[i].lpStartSecPoint[j].y);
}
//感觉它在这里保存到数组中的数据并没有什么用
if (j%halfPointCnt == 0)
{//半个周波取一次角差
AngleAnalyse[angleIndex][index].x = m_pCurve[i].lpStartSecPoint[j].x;
AngleAnalyse[angleIndex][index].y = 0;
//3个未赋值的变量,他是第几个数据,32的倍数,起始段点数组,段点数
if (GetFreqSwingAngle(freq,swing,angle,i,j,m_pCurve[i].lpStartSecPoint,m_pCurve[i].startCount))
{
AngleAnalyse[angleIndex][index].y = angle;
}
index++;
}
}
//曲线采样返回段点数4800 电压采样值
for (j = 0; j< m_pCurve[i].returnCount ; j++)
{
m_pCurve[i].lpReturnSecPoint[j]=pCurve[curveIndex].lpReturnSecPoint[j];
m_pCurve[i].lpReturnSecPoint[j].x+=(intersect+sampleRetBegin);
if(DoubleCmp(m_pCurve[i].lpReturnSecPoint[j].x-dMaxOfX)>0)
{
dMaxOfX=m_pCurve[i].lpReturnSecPoint[j].x;
}
if(DoubleCmp(fabs(m_pCurve[i].lpReturnSecPoint[j].y)-dMaxVolY)>0)
{
dMaxVolY = fabs(m_pCurve[i].lpReturnSecPoint[j].y);
}
if (j%halfPointCnt == 0)
{
AngleAnalyse[angleIndex][index].x = m_pCurve[i].lpReturnSecPoint[j].x;
AngleAnalyse[angleIndex][index].y = 0;
if (GetFreqSwingAngle(freq,swing,angle,i,j, m_pCurve[i].lpReturnSecPoint, m_pCurve[i].returnCount))
{
AngleAnalyse[angleIndex][index].y = angle;
}
index++;
}
}
}
else
{//角度,频率等处理
//曲线的全程启动段点数50 只需要拷贝全程启动段点数,和全程返回段点数
for(j=0;j<pCurve[curveIndex].StaCount;j++)
{
m_pCurve[i].lpStaPoint[j]=pCurve[curveIndex].lpStaPoint[j];
if(DoubleCmp(m_pCurve[i].lpStaPoint[j].x-dMaxOfX)>0)
{
dMaxOfX=m_pCurve[i].lpStaPoint[j].x;
}
if(DoubleCmp(fabs(m_pCurve[i].lpStaPoint[j].y)-dMaxVal)>0)
{
//这个是候dMaxVal被更新为30
dMaxVal = fabs(m_pCurve[i].lpStaPoint[j].y);
}
}
m_pCurve[i].lpStaPoint[j]=m_pCurve[i].lpStaPoint[j-1];
m_pCurve[i].lpStaPoint[j].x+=10;
for(j=0;j<pCurve[curveIndex].RetCount;j++)
{
m_pCurve[i].lpRetPoint[j]=pCurve[curveIndex].lpRetPoint[j];
m_pCurve[i].lpRetPoint[j].x+=intersect;
if(DoubleCmp(m_pCurve[i].lpRetPoint[j].x-dMaxOfX)>0)
{
dMaxOfX=m_pCurve[i].lpRetPoint[j].x;
}
if(DoubleCmp(fabs(m_pCurve[i].lpRetPoint[j].y)-dMaxVal)>0)
{
dMaxVal = fabs(m_pCurve[i].lpRetPoint[j].y);
}
}
m_pCurve[i].lpRetPoint[j]=m_pCurve[i].lpRetPoint[j-1];
m_pCurve[i].lpRetPoint[j].x+=10;
//如果通道名称为主控插件相角差 事实证明主控插件相角差的通道序号是第一个
if ( m_pCurve[i].name.Find(_T("主控插件相角差")) >= 0 || m_pCurve[i].name.Find(_T("Mainboard Angle Diff.")) >= 0 )
{
//全程启动段点数 里面的y就是角差 49
for(j=0;j<pCurve[curveIndex].StaCount-1;j++)
{
//前后两点的角度相差180°,则波形
if (fabs(m_pCurve[i].lpStaPoint[j].y-m_pCurve[i].lpStaPoint[j+1].y)>180)
{
m_pCurve[i].lpStaPoint[j].x=m_pCurve[i].lpStaPoint[j+1].x;
}
}
//全程返回段点数 1620
for(j=0;j<pCurve[curveIndex].RetCount-1;j++)
{
if (fabs(m_pCurve[i].lpRetPoint[j].y-m_pCurve[i].lpRetPoint[j+1].y)>180)
{
m_pCurve[i].lpRetPoint[j].x=m_pCurve[i].lpRetPoint[j+1].x;
}
}
//以下代码没有被调用 就问你气不气
for (j = 0; j< m_pCurve[i].startCount ; j++)
{//有存在采样前段
m_pCurve[i].lpStartSecPoint[j].x = AngleAnalyse[1][j].x;
m_pCurve[i].lpStartSecPoint[j].y = AngleAnalyse[0][j].y-AngleAnalyse[1][j].y; //us - ug,开始前段
if(DoubleCmp(m_pCurve[i].lpStartSecPoint[j].y+180)<0)
{
m_pCurve[i].lpStartSecPoint[j].y += 360;
}
else if(DoubleCmp(m_pCurve[i].lpStartSecPoint[j].y-180)>0)
{
m_pCurve[i].lpStartSecPoint[j].y -= 360;
}
if(DoubleCmp(fabs(m_pCurve[i].lpStartSecPoint[j].y)-dMaxVal)>0)
{
dMaxVal = fabs(m_pCurve[i].lpStartSecPoint[j].y);
}
}
int retPos;
//不被调用
for (j = 0; j< m_pCurve[i].returnCount ; j++)
{
retPos = j+m_pCurve[i].startCount;
m_pCurve[i].lpReturnSecPoint[j].x = AngleAnalyse[0][retPos].x;
m_pCurve[i].lpReturnSecPoint[j].y = AngleAnalyse[0][retPos].y-AngleAnalyse[1][retPos].y;
if(DoubleCmp(m_pCurve[i].lpReturnSecPoint[j].y+180)<0)
{
m_pCurve[i].lpReturnSecPoint[j].y += 360;
}
else if(DoubleCmp(m_pCurve[i].lpReturnSecPoint[j].y-180)>0)
{
m_pCurve[i].lpReturnSecPoint[j].y -= 360;
}
if(DoubleCmp(fabs(m_pCurve[i].lpReturnSecPoint[j].y)-dMaxVal)>0)
{
dMaxVal = fabs(m_pCurve[i].lpReturnSecPoint[j].y);
}
}
//不被调用
for(j=0;j<m_pCurve[i].startCount-1;j++)
{
if (fabs(m_pCurve[i].lpStartSecPoint[j].y-m_pCurve[i].lpStartSecPoint[j+1].y)>180)
{
m_pCurve[i].lpStartSecPoint[j].x=m_pCurve[i].lpStartSecPoint[j+1].x;
}
}
//不被调用
for(j=0;j<m_pCurve[i].returnCount-1;j++)
{
if (fabs(m_pCurve[i].lpReturnSecPoint[j].y-m_pCurve[i].lpReturnSecPoint[j+1].y)>180)
{
m_pCurve[i].lpReturnSecPoint[j].x=m_pCurve[i].lpReturnSecPoint[j+1].x;
}
}
}
//dMaxVal=30
if(dMaxVal<m_pCurve[i].minRange)
{
dMaxVal=m_pCurve[i].minRange;
}
//30 30
temp_n=(long)dMaxVal;
//调用判断函数
if(DoubleCmp(dMaxVal-temp_n)>0)
{
//31
temp_n++;
}
//4 y轴上一个刻度的逻辑值
dValueOfCellY=(long)((temp_n%10)==0)?(temp_n/10):(temp_n/10+1);
if(DoubleCmp(dMaxVal-1) ==0)
{
dValueOfCellY = dMaxVal/10;
}
//这里是的等于4,表示为让系统自行设置 y轴上一个刻度的单位
m_pCurve[i].valueOfCellY = dValueOfCellY;
}
}
}
//初始化指针缓存空间
int nStaAngleCount = 0,nRetAngleCount = 0; //保存角度值的缓存的大小
int nIndexChannel = 0;
int nCacluIndex = 1;
for(nIndexChannel = 0;nIndexChannel < m_nCurveCount;nIndexChannel++)
{
if (m_pCurve[nIndexChannel].name.Find(_T("主控插件相角差")) >= 0 || m_pCurve[nIndexChannel].name.Find(_T("Mainboard Angle Diff")) >= 0 )
{
nStaAngleCount = m_pCurve[nIndexChannel].StaCount;
nRetAngleCount = m_pCurve[nIndexChannel].RetCount;
break;
}
}
if (nStaAngleCount != 0 )
{
lpStaPhaseAngle = new double[nStaAngleCount*2];
//特殊处理一
lpStaPhaseAngle[0] = m_pCurve[nIndexChannel].lpStaPoint[0].y;
//对数据进行处理
for (nCacluIndex = 1; nCacluIndex < nStaAngleCount ; nCacluIndex++)
{
double nIntervalSample = m_pCurve[nIndexChannel].lpStaPoint[nCacluIndex - 1].y + (double)(m_pCurve[nIndexChannel].lpStaPoint[nCacluIndex].y - m_pCurve[nIndexChannel].lpStaPoint[nCacluIndex - 1].y)/2;
lpStaPhaseAngle[nCacluIndex*2 - 1] = nIntervalSample;
//
lpStaPhaseAngle[nCacluIndex*2] = m_pCurve[nIndexChannel].lpStaPoint[nCacluIndex].y;
}
lpStaPhaseAngle[nStaAngleCount*2 - 1] = m_pCurve[nIndexChannel].lpStaPoint[nStaAngleCount - 1].y;
}
if (nRetAngleCount != 0 )
{
lpRetPhaseAngle = new double[nRetAngleCount*2];
//特殊处理一
lpRetPhaseAngle[0] = m_pCurve[nIndexChannel].lpRetPoint[0].y;
//对数据进行处理
for (nCacluIndex = 1; nCacluIndex < nRetAngleCount ; nCacluIndex++)
{
double nIntervalSample = m_pCurve[nIndexChannel].lpRetPoint[nCacluIndex - 1].y + (double)(m_pCurve[nIndexChannel].lpRetPoint[nCacluIndex].y - m_pCurve[nIndexChannel].lpRetPoint[nCacluIndex - 1].y)/2;
lpRetPhaseAngle[nCacluIndex*2 - 1] = nIntervalSample;
//
lpRetPhaseAngle[nCacluIndex*2] = m_pCurve[nIndexChannel].lpRetPoint[nCacluIndex].y;
}
lpRetPhaseAngle[nRetAngleCount*2 - 1] = m_pCurve[nIndexChannel].lpRetPoint[nRetAngleCount - 1].y;
}
//#define OUTPUT_FILE 0x01
#ifdef OUTPUT_FILE
CString strTemp,strAngle;
// for (int nDot = 0 ;nDot < nStaAngleCount*2;nDot++)
// {
// strTemp.Format(_T("第%d个点:%0.2f\r\n"),nDot,lpStaPhaseAngle[nDot]);
// strAngle += strTemp;
// }
for (int nDot = 0 ;nDot < nRetAngleCount*2 ;nDot++)
{
strTemp.Format(_T("第%d个点:%0.2f\r\n"),nDot,lpRetPhaseAngle[nDot]);
strAngle += strTemp;
}
char Buff[100000] = {0};
//把获取到的数据全部以文本形式提取
FILE *mFile = fopen("E:\\us_ug.txt","a+");
if (mFile == NULL)
{
AfxMessageBox(_T("文件打开失败"));
}
WideCharToMultiByte(CP_ACP,0,strAngle,-1,Buff,100000,NULL,NULL);
fwrite(Buff,strlen(Buff),1,mFile);
fclose(mFile);
#endif
//自己显示的三个波形都需要显示脉振电压
if (isShowCurveMZ)
{
if (!InitAddChannel())
{
return;
}
}
//计算电流中的dValueOfCellY
//不被执行
if(dMaxCurrentY<dCurrentMinRange)
{
dMaxCurrentY=dCurrentMinRange;
}
//100 100
temp_n=(long)dMaxCurrentY;
//如果tempY大于temp_n
if(DoubleCmp(dMaxCurrentY-temp_n)>0)
{
//101
temp_n++;
}
//11
dValueOfCellY=(long)((temp_n%10)==0)?(temp_n/10):(temp_n/10+1);
//不被执行
if(DoubleCmp(dMaxCurrentY-1) ==0)
{
dValueOfCellY = dMaxCurrentY/10;
}
//容器里面有内容,所以不执行下面的代码程序段
while(!qCurrentIndex.empty())
{
m_pCurve[qCurrentIndex.front()].valueOfCellY = dValueOfCellY;
qCurrentIndex.pop();
}
//计算电压中的dValueOfCellY
//不被执行 dMaxVal=146
if(dMaxVolY<dVolMinRange)
{
dMaxVolY=dVolMinRange;
}
//146
temp_n=(long)dMaxVolY;
//如果tempY大于temp_n
if(DoubleCmp(dMaxVolY-temp_n)>0)
{
//147了
temp_n++;
}
//15
dValueOfCellY=(long)((temp_n%10)==0)?(temp_n/10):(temp_n/10+1);
//不被执行
if(DoubleCmp(dMaxVolY-1) ==0)
{
dValueOfCellY = dMaxVolY/10;
}
//在算频率的时候好像被执行两次
while(!qVolIndex.empty())
{
m_pCurve[qVolIndex.front()].valueOfCellY = dValueOfCellY;
qVolIndex.pop();
}
//最大的X轴坐标 16709
m_nMaxOfX=(long)dMaxOfX;
if(m_nMaxOfX<dMaxOfX)
{
//16710了
m_nMaxOfX++;
}
//计算区域大小
//一个可读的逻辑值
m_dMulti=1;
//新的逻辑值
m_dNewMulti = 1;
//16710
m_dWindowSizeOfX = m_nMaxOfX;
//初始显示曲线时最左边显示的X坐标0
m_dInitDisPosOfx = 0-m_pCurve[2].startTime;
SetCoorHeight(20,60);
//获取窗口信息
CRect rc;
//获取电脑的屏幕分辨率
GetDesktopWindow()->GetWindowRect(rc);
//230 230这个位置是画布长
rc.right -= WIDTH_PROJECT+CHANNEL_INFO_WIDTH+20;
//50130
double d1=m_clientRc.Width()-CHANNEL_INFO_WIDTH;
//1366*16710/(50130*16710)
//放大的倍数
m_dMulti = rc.Width()*m_nMaxOfX/(d1*m_dWindowSizeOfX);
m_dMinMulti = m_dMulti;
m_dNewMulti = m_dMulti;
//16710
m_dWindowSizeOfX = m_nMaxOfX;
//0
m_dInitDisPosOfx = 0-m_pCurve[2].startTime;
SetCoorHeight(20,60); // POINT origital,tempPoint;
POINT origital,tempPoint;
Point rightPoint;
//230
origital.x=m_rectCurve.left;
origital.y=0;
//0
rightPoint.x=m_dInitDisPosOfx+m_pCurve[2].startTime;
origital.y=0;
MapPoint(rightPoint,tempPoint,0,origital,0);
//0
tempPoint.x -= m_rectCurve.left;
//把视图移动到给定的点
ScrollToPosition(tempPoint);
}
/**********************************************
1041L 开始调用
**********************************************/
POINT CCurveView::MapPoint(Point p1, POINT &p2,double cellOfY,POINT origitalPoint,int nWidthOfCell)
{
//为了统一x坐标,这里的xWidthOfCell全按模拟量计算
int xWidthOfCell;
//好像不被执行
if(m_bPrint)
{
//x轴上每格刻度的逻辑值为3 m_nCellOfX 记录X轴上一个刻度所表示的X的逻辑值 m_curRect当前显示的区域
xWidthOfCell = abs(m_nHeightOfAnalogCoor/CELL_COUNT);
//现在传入的Point结构体的X*3*当前的倍数/逻辑值+传入进来的点坐标的x值-当前窗体X的坐标值+x坐标值
p2.x=p1.x*xWidthOfCell*m_dMulti/m_nCellOfX+origitalPoint.x-m_curRect.left+m_rcPrintCurve.left;