CRVM-redis-6/IDExcuter/Stand.cs

353 lines
16 KiB
C#
Raw Permalink Normal View History

2025-11-07 02:02:31 +08:00
using System;
using System.Collections.Generic;
using CRVM.Entity;
namespace CRVM.SIDExcuter
{
//[DataContract]
public class Stand
{
public double[] vib { get; set; }
public double[] vib2 { get; set; }
public double[] vibLow { get; set; }
public double[] vibMid { get; set; }
public double[] vibHig { get; set; }
//分频段能量、速度
public double energy_All { get; set; }
public double energy_L { get; set; }
public double energy_M { get; set; }
public double energy_H { get; set; }
public double speed { get; set; }
//能量 报警 曲线 [中,高,低]--2025-01-09 新增
public double[] VibRms { get; set; }
public double[] AlarmRms { get; set; }
public double[] DefectRms { get; set; }
//用于绘制时域曲线
public double[] tVib { get; set; }
//用于绘制能量曲线
public RollingArray<double> list_Energy_All { get; set; }
public RollingArray<double> list_Energy_L { get; set; }
public RollingArray<double> list_Energy_M { get; set; }
public RollingArray<double> list_Energy_H { get; set; }
public RollingArray<double> list_Energy_Speed { get; set; }
//用于绘制报警线
public RollingArray<double> list_Alarm_L { set; get; }
public RollingArray<double> list_Alarm_M { set; get; }
public RollingArray<double> list_Alarm_H { set; get; }
//用于绘制缺陷线
public RollingArray<double> list_Defect_L { set; get; }
public RollingArray<double> list_Defect_M { set; get; }
public RollingArray<double> list_Defect_H { set; get; }
#region
private EntityAlarmSpeed[] _alarm_spd = new EntityAlarmSpeed[10];
public EntityAlarmSpeed[] alarm_spd
{
get { return _alarm_spd; }
set { _alarm_spd = value; }
}
public int[] fre_l_S1 { get; set; }
public int[] fre_l_S2 { get; set; }
public double[] fre_l_V { get; set; }
public double[] fre_l_D { get; set; }
public int[] fre_m_S1 { get; set; }
public int[] fre_m_S2 { get; set; }
public double[] fre_m_V { get; set; }
public double[] fre_m_D { get; set; }
public int[] fre_h_S1 { get; set; }
public int[] fre_h_S2 { get; set; }
public double[] fre_h_V { get; set; }
public double[] fre_h_D { get; set; }
public void SetAlarmFred(EntityAlarmSpeed[] alarmspd)
{
_alarm_spd = alarmspd;
if (_alarm_spd != null)
{
if (_alarm_spd.Length <= 1)
{
fre_l_S1 = new int[1];
fre_l_S2 = new int[1];
fre_l_V = new double[1];
fre_l_D = new double[1];
fre_m_S1 = new int[1];
fre_m_S2 = new int[1];
fre_m_V = new double[1];
fre_m_D = new double[1];
fre_h_S1 = new int[1];
fre_h_S2 = new int[1];
fre_h_V = new double[1];
fre_h_D = new double[1];
fre_l_S1[0] = _alarm_spd[0].lowPassL;
fre_l_S2[0] = _alarm_spd[0].lowPassU;
fre_l_V[0] = _alarm_spd[0].lowAlarmValue;
fre_l_D[0] = _alarm_spd[0].lowDefectValue;
fre_m_S1[0] = _alarm_spd[0].midPassL;
fre_m_S2[0] = _alarm_spd[0].midPassU;
fre_m_V[0] = _alarm_spd[0].midAlarmValue;
fre_m_D[0] = _alarm_spd[0].midDefectValue;
fre_h_S1[0] = _alarm_spd[0].highPassL;
fre_h_S2[0] = _alarm_spd[0].highPassU;
fre_h_V[0] = _alarm_spd[0].highAlarmValue;
fre_h_D[0] = _alarm_spd[0].highDefectValue;
}
else
{
int iIndCount = _alarm_spd[_alarm_spd.Length - 1].alarmSpeed - _alarm_spd[0].alarmSpeed + 1;
fre_l_S1 = new int[iIndCount];
fre_l_S2 = new int[iIndCount];
fre_l_V = new double[iIndCount];
fre_l_D = new double[iIndCount];
fre_m_S1 = new int[iIndCount];
fre_m_S2 = new int[iIndCount];
fre_m_V = new double[iIndCount];
fre_m_D = new double[iIndCount];
fre_h_S1 = new int[iIndCount];
fre_h_S2 = new int[iIndCount];
fre_h_V = new double[iIndCount];
fre_h_D = new double[iIndCount];
fre_l_S1[0] = _alarm_spd[0].lowPassL;
fre_l_S2[0] = _alarm_spd[0].lowPassU;
fre_l_V[0] = _alarm_spd[0].lowAlarmValue;
fre_l_D[0] = _alarm_spd[0].lowDefectValue;
fre_m_S1[0] = _alarm_spd[0].midPassL;
fre_m_S2[0] = _alarm_spd[0].midPassU;
fre_m_V[0] = _alarm_spd[0].midAlarmValue;
fre_m_D[0] = _alarm_spd[0].midDefectValue;
fre_h_S1[0] = _alarm_spd[0].highPassL;
fre_h_S2[0] = _alarm_spd[0].highPassU;
fre_h_V[0] = _alarm_spd[0].highAlarmValue;
fre_h_D[0] = _alarm_spd[0].highDefectValue;
int i_start_l_s1 = _alarm_spd[0].lowPassL;
int i_start_l_s2 = _alarm_spd[0].lowPassU;
double i_start_l_v = _alarm_spd[0].lowAlarmValue;
double i_start_l_d = _alarm_spd[0].lowDefectValue;
int i_start_m_s1 = _alarm_spd[0].midPassL;
int i_start_m_s2 = _alarm_spd[0].midPassU;
double i_start_m_v = _alarm_spd[0].midAlarmValue;
double i_start_m_d = _alarm_spd[0].midDefectValue;
int i_start_h_s1 = _alarm_spd[0].highPassL;
int i_start_h_s2 = _alarm_spd[0].highPassU;
double i_start_h_v = _alarm_spd[0].highAlarmValue;
double i_start_h_d = _alarm_spd[0].highDefectValue;
int i_start_spd = _alarm_spd[0].alarmSpeed;
int i_end_l_s1, i_end_l_s2, i_end_m_s1, i_end_m_s2, i_end_h_s1, i_end_h_s2, i_end_spd;
double i_end_l_v, i_end_m_v, i_end_h_v, i_end_l_d, i_end_m_d, i_end_h_d;
double i_step_l_s1, i_step_l_s2, i_step_l_v, i_step_l_d, i_step_m_s1, i_step_m_s2, i_step_m_v, i_step_m_d, i_step_h_s1, i_step_h_s2, i_step_h_v, i_step_h_d;
int i_sub_tmp = 0;
int i_index = 0;
for (int i = 1; i < _alarm_spd.Length; i++)
{
i_end_l_s1 = _alarm_spd[i].lowPassL;
i_end_l_s2 = _alarm_spd[i].lowPassU;
i_end_l_v = _alarm_spd[i].lowAlarmValue;
i_end_l_d = _alarm_spd[i].lowDefectValue;
i_end_m_s1 = _alarm_spd[i].midPassL;
i_end_m_s2 = _alarm_spd[i].midPassU;
i_end_m_v = _alarm_spd[i].midAlarmValue;
i_end_m_d = _alarm_spd[i].midDefectValue;
i_end_h_s1 = _alarm_spd[i].highPassL;
i_end_h_s2 = _alarm_spd[i].highPassU;
i_end_h_v = _alarm_spd[i].highAlarmValue;
i_end_h_d = _alarm_spd[i].highDefectValue;
i_end_spd = _alarm_spd[i].alarmSpeed;
i_sub_tmp = i_end_spd - i_start_spd;
i_step_l_s1 = ((i_end_l_s1 - i_start_l_s1) / (i_sub_tmp * 1.0f));
i_step_l_s2 = ((i_end_l_s2 - i_start_l_s2) / (i_sub_tmp * 1.0f));
i_step_l_v = ((i_end_l_v - i_start_l_v) / (i_sub_tmp * 1.0f));
i_step_l_d = ((i_end_l_d - i_start_l_d) / (i_sub_tmp * 1.0f));
i_step_m_s1 = ((i_end_m_s1 - i_start_m_s1) / (i_sub_tmp * 1.0f));
i_step_m_s2 = ((i_end_m_s2 - i_start_m_s2) / (i_sub_tmp * 1.0f));
i_step_m_v = ((i_end_m_v - i_start_m_v) / (i_sub_tmp * 1.0f));
i_step_m_d = ((i_end_m_d - i_start_m_d) / (i_sub_tmp * 1.0f));
i_step_h_s1 = ((i_end_h_s1 - i_start_h_s1) / (i_sub_tmp * 1.0f));
i_step_h_s2 = ((i_end_h_s2 - i_start_h_s2) / (i_sub_tmp * 1.0f));
i_step_h_v = ((i_end_h_v - i_start_h_v) / (i_sub_tmp * 1.0f));
i_step_h_d = ((i_end_h_d - i_start_h_d) / (i_sub_tmp * 1.0f));
for (int k = 1; k <= i_sub_tmp; k++)
{
fre_l_S1[k + i_index] = Convert.ToInt32(i_start_l_s1 + i_step_l_s1 * (k - 1));
fre_l_S2[k + i_index] = Convert.ToInt32(i_start_l_s2 + i_step_l_s2 * (k - 1));
fre_l_V[k + i_index] = (i_start_l_v + i_step_l_v * (k - 1));
fre_l_D[k + i_index] = (i_start_l_d + i_step_l_d * (k - 1));
fre_m_S1[k + i_index] = Convert.ToInt32(i_start_m_s1 + i_step_m_s1 * (k - 1));
fre_m_S2[k + i_index] = Convert.ToInt32(i_start_m_s2 + i_step_m_s2 * (k - 1));
fre_m_V[k + i_index] = (i_start_m_v + i_step_m_v * (k - 1));
fre_m_D[k + i_index] = (i_start_m_d + i_step_m_d * (k - 1));
fre_h_S1[k + i_index] = Convert.ToInt32(i_start_h_s1 + i_step_h_s1 * (k - 1));
fre_h_S2[k + i_index] = Convert.ToInt32(i_start_h_s2 + i_step_h_s2 * (k - 1));
fre_h_V[k + i_index] = (i_start_h_v + i_step_h_v * (k - 1));
fre_h_D[k + i_index] = (i_start_h_d + i_step_h_d * (k - 1));
}
i_start_l_s1 = i_end_l_s1;
i_start_l_s2 = i_end_l_s2;
i_start_l_v = i_end_l_v;
i_start_l_d = i_end_l_d;
i_start_m_s1 = i_end_m_s1;
i_start_m_s2 = i_end_m_s2;
i_start_m_v = i_end_m_v;
i_start_m_d = i_end_m_d;
i_start_h_s1 = i_end_h_s1;
i_start_h_s2 = i_end_h_s2;
i_start_h_v = i_end_h_v;
i_start_h_d = i_end_h_d;
i_start_spd = i_end_spd;
i_index += i_sub_tmp;
fre_l_S1[i_index] = _alarm_spd[i].lowPassL;
fre_l_S2[i_index] = _alarm_spd[i].lowPassU;
fre_l_V[i_index] = _alarm_spd[i].lowAlarmValue;
fre_l_D[i_index] = _alarm_spd[i].lowDefectValue;
fre_m_S1[i_index] = _alarm_spd[i].midPassL;
fre_m_S2[i_index] = _alarm_spd[i].midPassU;
fre_m_V[i_index] = _alarm_spd[i].midAlarmValue;
fre_m_D[i_index] = _alarm_spd[i].midDefectValue;
fre_h_S1[i_index] = _alarm_spd[i].highPassL;
fre_h_S2[i_index] = _alarm_spd[i].highPassU;
fre_h_V[i_index] = _alarm_spd[i].highAlarmValue;
fre_h_D[i_index] = _alarm_spd[i].highDefectValue;
}
fre_l_S1[iIndCount - 1] = _alarm_spd[_alarm_spd.Length - 1].lowPassL;
fre_l_S2[iIndCount - 1] = _alarm_spd[_alarm_spd.Length - 1].lowPassU;
fre_l_V[iIndCount - 1] = _alarm_spd[_alarm_spd.Length - 1].lowAlarmValue;
fre_l_D[iIndCount - 1] = _alarm_spd[_alarm_spd.Length - 1].lowDefectValue;
fre_m_S1[iIndCount - 1] = _alarm_spd[_alarm_spd.Length - 1].midPassL;
fre_m_S2[iIndCount - 1] = _alarm_spd[_alarm_spd.Length - 1].midPassU;
fre_m_V[iIndCount - 1] = _alarm_spd[_alarm_spd.Length - 1].midAlarmValue;
fre_m_D[iIndCount - 1] = _alarm_spd[_alarm_spd.Length - 1].midDefectValue;
fre_h_S1[iIndCount - 1] = _alarm_spd[_alarm_spd.Length - 1].highPassL;
fre_h_S2[iIndCount - 1] = _alarm_spd[_alarm_spd.Length - 1].highPassU;
fre_h_V[iIndCount - 1] = _alarm_spd[_alarm_spd.Length - 1].highAlarmValue;
fre_h_D[iIndCount - 1] = _alarm_spd[_alarm_spd.Length - 1].highDefectValue;
}
}
}
#endregion
#region
//分频频率范围
public int band_Fre_L1 { get; set; }
public int band_Fre_L2 { get; set; }
public int band_Fre_M1 { get; set; }
public int band_Fre_M2 { get; set; }
public int band_Fre_H1 { get; set; }
public int band_Fre_H2 { get; set; }
//报警参考值
public double alarm_L_Value_ck { get; set; }
public double alarm_M_Value_ck { get; set; }
public double alarm_H_Value_ck { get; set; }
public double defect_L_Value_ck { get; set; }
public double defect_M_Value_ck { get; set; }
public double defect_H_Value_ck { get; set; }
//报警参考次数
public int alarm_L_Times_ck { get; set; }
public int alarm_M_Times_ck { get; set; }
public int alarm_H_Times_ck { get; set; }
//记录能量值超过报警线次数
public int alarm_L_Times { get; set; }
public int alarm_M_Times { get; set; }
public int alarm_H_Times { get; set; }
public class AlarmInfo
{
public DateTime time { set; get; }
public int startPos { set; get; }
public int endPos { set; get; }
public double value { set; get; }
}
public int tempAlarmLowInfostart { set; get; }
public int tempAlarmMidInfostart { set; get; }
public int tempAlarmHighInfostart { set; get; }
public List<AlarmInfo> alarmLowInfo = new List<AlarmInfo>();
public List<AlarmInfo> alarmMidInfo = new List<AlarmInfo>();
public List<AlarmInfo> alarmHighInfo = new List<AlarmInfo>();
//统计报警次数
public int indexLow { get; set; }
public int indexMid { get; set; }
public int indexHigh { get; set; }
#endregion
public double rollDiameterBU { set; get; }
public double rollDiameterBL { set; get; }
public double rollDiameterMU { set; get; }
public double rollDiameterML { set; get; }
public double rollDiameterWU { set; get; }
public double rollDiameterWL { set; get; }
public void Initial(int vibLength, int tvibLength, int energyLength)
{
vib = new double[vibLength];
vibLow = new double[vibLength];
vibMid = new double[vibLength];
vibHig = new double[vibLength];
tVib = new double[tvibLength];
list_Energy_Speed = new RollingArray<double>(energyLength + 1);
list_Energy_All = new RollingArray<double>(energyLength + 1);
list_Energy_L = new RollingArray<double>(energyLength + 1);
list_Energy_M = new RollingArray<double>(energyLength + 1);
list_Energy_H = new RollingArray<double>(energyLength + 1);
list_Alarm_L = new RollingArray<double>(energyLength + 1);
list_Alarm_M = new RollingArray<double>(energyLength + 1);
list_Alarm_H = new RollingArray<double>(energyLength + 1);
list_Defect_L = new RollingArray<double>(energyLength + 1);
list_Defect_M = new RollingArray<double>(energyLength + 1);
list_Defect_H = new RollingArray<double>(energyLength + 1);
for (int i = 0; i < energyLength + 1; i++)
{
list_Energy_Speed.Add(0.0);
list_Energy_All.Add(0.0);
list_Energy_L.Add(0.0);
list_Energy_M.Add(0.0);
list_Energy_H.Add(0.0);
list_Alarm_L.Add(0.0);
list_Alarm_M.Add(0.0);
list_Alarm_H.Add(0.0);
list_Defect_L.Add(0.0);
list_Defect_M.Add(0.0);
list_Defect_H.Add(0.0);
}
// 初始化2025-01-09 新增
VibRms = new double[] { 0, 0, 0 };
AlarmRms = new double[] { 0, 0, 0 };
DefectRms = new double[] { 0, 0, 0 };
}
}
}