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
using Bro.Common.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Bro.Common.Model
{
    public class ScrewResult : ICSVOutput
    {
        public DateTime DT { get; set; }
 
        /// <summary>
        /// 锁螺丝PSet序号
        /// </summary>
        public int PSetNo { get; set; } = 1;
 
        /// <summary>
        /// 产品序号
        /// </summary>
        public string SN { get; set; }
 
        /// <summary>
        /// 螺丝序号
        /// </summary>
        public int ScrewIndex { get; set; }
 
        /// <summary>
        /// 螺丝枪反馈的结果 true OK  false NG
        /// </summary>
        public bool Result { get; set; } = false;
 
        /// <summary>
        /// 检测是否浮钉  true:浮钉  false: 不是浮钉
        /// </summary>
        public bool IsFloatingScrew { get; set; } = false;
 
        /// <summary>
        /// 浮钉检测的扭矩相关角度
        /// </summary>
        public float TorqueRelatedAngle { get; set; }
 
        /// <summary>
        /// 浮钉检测的步骤相关角度
        /// </summary>
        public float StepRelatedAngle { get; set; }
 
        /// <summary>
        /// 扭矩变化最大斜率
        /// </summary>
        public float MaxTorqueSlope { get; set; }
 
        /// <summary>
        /// 最终力矩
        /// </summary>
        public float LastTorque { get; set; }
 
        /// <summary>
        /// 最终角度
        /// </summary>
        public float LastAngle { get; set; }
 
        /// <summary>
        /// 力矩波形图数据
        /// </summary>
        public List<float> CurveTorque { get; set; } = new List<float>();
 
        /// <summary>
        /// 角度波形图数据
        /// </summary>
        public List<float> CurveAngle { get; set; } = new List<float>();
 
        /// <summary>
        /// NG描述
        /// </summary>
        public string ErrorCode { get; set; }
 
        /// <summary>
        /// 步骤扭矩集合
        /// </summary>
        public float[] TorqueList { get; set; } = new float[3];
 
        /// <summary>
        /// 步骤角度集合
        /// </summary>
        public float[] AngleList { get; set; } = new float[3];
 
        public string GetCSVHead()
        {
            List<string> heads = new List<string>()
            {
                "Time",
                "SN",
                "ScrewIndex",
                "Result",
                "PSetNo",
                "IsFloating",
                "FinalTorque",
                "FinalAngle",
                "Step1Torque",
                "Step1Angle",
                "Step2Torque",
                "Step2Angle",
                "Step3Torque",
                "Step3Angle",
                "TorqueRelatedAngle",
                "StepRelatedAngle",
                "MaxTorqueSlope",
                "NGDesc"
            };
 
            return string.Join(",", heads);
        }
 
        public string GetCSVData()
        {
            List<string> datas = new List<string>()
            {
                DT.ToString("HH:mm:ss"),
                SN,
                ScrewIndex.ToString(),
                Result?"OK":"NG",
                PSetNo.ToString(),
                IsFloatingScrew?"Floating":"No",
                LastTorque.ToString("f2"),
                LastAngle.ToString("f2"),
                TorqueList[0].ToString("f2"),
                AngleList[0].ToString("f2"),
                TorqueList[1].ToString("f2"),
                AngleList[1].ToString("f2"),
                TorqueList[2].ToString("f2"),
                AngleList[2].ToString("f2"),
                TorqueRelatedAngle.ToString("f2"),
                StepRelatedAngle.ToString("f2"),
                MaxTorqueSlope.ToString("f2"),
                ErrorCode,
            };
 
            return string.Join(",", datas);
        }
    }
}