using System;
using System.Collections.Generic;
namespace Shared
{
[System.Serializable]
public class Sensor : Common
{
public Sensor ()
{
Type = DeviceType.Sensor;
DeviceTextID = SimpleControl.R.MyInternationalizationString.Sensor;
}
public int SensorTypeTestID = SimpleControl.R.MyInternationalizationString.Sensor;
public byte DevicePushType {
get {
byte devicePushType = 255;
switch (Type) {
case DeviceType.SensorPM25:
devicePushType = 0;
break;
case DeviceType.SensorCO2:
devicePushType = 1;
break;
case DeviceType.SensorTVOC:
devicePushType = 2;
break;
case DeviceType.SensorTemperature:
devicePushType = 3;
break;
case DeviceType.SensorHumidity:
devicePushType = 4;
break;
}
return devicePushType;
}
}
}
///
/// 自动化设备
/// 一个内存类,存放传感器自动化设备的数据
///
public class SensorAutomationDevice : Common
{
//public byte SubnetID;
//public byte DeviceID;
public byte DevicePushType {
get {
byte devicePushType = 255;
switch (Type) {
case DeviceType.SensorPM25:
devicePushType = 0;
break;
case DeviceType.SensorCO2:
devicePushType = 1;
break;
case DeviceType.SensorTVOC:
devicePushType = 2;
break;
case DeviceType.SensorTemperature:
devicePushType = 3;
break;
case DeviceType.SensorHumidity:
devicePushType = 4;
break;
}
return devicePushType;
}
}
public List sensorAutomationList {
get {
var sss = new List ();
List readAdd = new List ();
for (int i = 0; i < 40; i++) {//自动化一共40个,总排序中找出自动化ID相同的,组合成一个自动化
if (ConditionIdList == null || AutomationEnableList == null ) {
continue;
}
if (AutomationEnableList [i] == 1 || AutomationEnableList [i] == 2) {
var automation = new SensorAutomation ();
automation.AutomationId = (byte)i;
automation.AutomationStatus = AutomationEnableList [i];
//if (ConditionIdList [i] != 255) {
for (int j = 0; j < 40; j++) {//找到第一个自动化之后,取出自动化ID,循环后面的列表,如果相同,就把这个序号加进自动化的条件ID列表里面,这个序号就是条件的ID
if (ConditionIdList [j] == (byte)i) {
automation.AutomationConditionIdList.Add (j);
}
}
//}
readAdd.Add (ConditionIdList [i]);
sss.Add (automation);
}
}
return sss;
}
}
///
/// 自动化状态列表数据 40byte
///
public byte [] AutomationEnableList;
///
/// 自动化ID列表数据 40byte
///
public byte [] ConditionIdList;
}
///
/// 自动化
/// 一个内存类,存放传感器自动化的数据
///
public class SensorAutomation
{
///
/// 自动化的名称
///
public string AutomationName = "";
///
/// 自动化的状态
///
public byte AutomationStatus;
///
/// 自动化的ID
///
public byte AutomationId;
///
/// 自动化包含的条件ID列表
///
public List AutomationConditionIdList = new List();
///
/// 自动化包含的条件目标列表
///
public List sensorAutomationConditionList {
get {
var sss = new List ();
for (int i = 0; i < AutomationConditionIdList.Count; i++) {
var automationMsg = new SensorAutomationCondition ();
automationMsg.Id = (byte)AutomationConditionIdList [i];
automationMsg.Status = AutomationStatus;
sss.Add (automationMsg);
}
return sss;
}
}
///
/// 自动化触发的目标数据列表
///
public List TargetBytesList = new List ();
//public SensorAutonmationCycle AutonmationCycle;
}
public class SensorAutonmationCycle
{
//1 类型 1.PM2.5 0
//2.CO2浓度 1
//3.TVOC浓度 2
//4.温度 3
//5.湿度 4
//2 通道号 预留,这里只有一个通道
//3 目标级别 Level: 0 ~ 7 每一级别对不同的组范围
//注:0级为差
// 1.级为良
// 2 级为优
///
/// 4 重复周期类型
/// 0:系统
/// 1:自定义
///
public byte CycleType = 0;
///
/// 5 重复周期设置 系统:
/// 0:只执行一次
/// 1:每天一次
/// 2:工作日
/// 3:周末,非工作日
///
public byte CycleType_System = 0;
///
/// 自定义:
/// 启用第 6 个byte 来自定义一周里面的重复时间
/// 6 自定义重复周期 Bit0 - bit6 代表周日到周六 ( 1:为选定 0:为取消) 第 4 byte(CycleType) 为 1 时有效
/// 7 年 范围:公元年与2000的差
/// 8 月 0 - 11
/// 9 日 0 - 30
/// 10 时 0 - 23
/// 11 分 0 - 59
///
public byte CycleType_Custom_Begin = 0;
///
/// 12 年 范围:公元年与2000的差
/// 13 月 0 - 11
/// 14 日 0 - 30
/// 15 时 0 - 23
/// 16 分 0 - 59
///
public byte CycleType_Custom_End = 0;
}
///
/// 自动化的具体条件
/// 一个内存类,存放传感器自动化条件的数据
///
public class SensorAutomationCondition
{
///
/// 自动化条件的具体状态,与自动化类里面的条件是一样的
/// 0:delete;
/// 1:enable;
/// 2:unused
///
public byte Status;
///
/// 自动化条件ID、条件在自动化里面的index
/// 0-39
///
public byte Id;
public byte PushId {
get {
return ((byte)(Id / 8));
}
}
public byte ConditionLevel {
get {
return ((byte)(Id % 8));
}
}
///
/// 自动化条件的名称
///
public string Name = "";
}
[System.Serializable]
public class SensorMobileDetection : Sensor
{
public SensorMobileDetection ()
{
// 移动探测(01)增加状态广播项设置, 通道号,备注,使能位,灵敏度,状态,
Type = DeviceType.SensorMobileDetection;
DeviceTextID = SimpleControl.R.MyInternationalizationString.Sensor;
SensorTypeTestID = SimpleControl.R.MyInternationalizationString.SensorMobileDetection;
}
public bool Enable = true;
public byte Sensitivity;
public byte Status;
}
[System.Serializable]
public class SensorTemperature : Sensor
{
public SensorTemperature ()
{
//温度(02)增加状态广播项设置,详见操作码4.29 通道号,备注,当前温度(同时支持整形,浮点类型)E3E5的返回数据
Type = DeviceType.SensorTemperature;
DeviceTextID = SimpleControl.R.MyInternationalizationString.Environmental;
SensorTypeTestID = SimpleControl.R.MyInternationalizationString.SensorTemperature;
}
public double CurrentTemperature;
}
[System.Serializable]
public class SensorHumidity : Sensor
{
public SensorHumidity ()
{
//湿度(03)增加状态广播项设置,详见操作码4.29 通道号,备注,使能位,当前湿度
Type = DeviceType.SensorHumidity;
DeviceTextID = SimpleControl.R.MyInternationalizationString.Environmental;
SensorTypeTestID = SimpleControl.R.MyInternationalizationString.SensorHumidity;
}
public bool Enable = true;
public double CurrentHumidity;
}
[System.Serializable]
public class SensorIllumination : Sensor
{
public SensorIllumination ()
{
//照度(04)增加状态广播项设置,详见操作码4.29 通道号,备注,使能位,当前照度
Type = DeviceType.SensorIllumination;
DeviceTextID = SimpleControl.R.MyInternationalizationString.Environmental;
SensorTypeTestID = SimpleControl.R.MyInternationalizationString.SensorIllumination;
}
public bool Enable = true;
public int CurrentIllumination;
}
[System.Serializable]
public class SensorTVOC : Sensor
{
public SensorTVOC ()
{
//TVOC(05) 通道号,备注,使能位,当前空气质量等级
Type = DeviceType.SensorTVOC;
DeviceTextID = SimpleControl.R.MyInternationalizationString.Environmental;
SensorTypeTestID = SimpleControl.R.MyInternationalizationString.SensorTVOC;
}
public bool Enable = true;
public double CurrentTVOC;
}
[System.Serializable]
public class SensorPM25 : Sensor
{
public SensorPM25 ()
{
//PM2.5(06) 通道号,备注,使能位,当前空气PM2.5值
Type = DeviceType.SensorPM25;
DeviceTextID = SimpleControl.R.MyInternationalizationString.Sensor;
SensorTypeTestID = SimpleControl.R.MyInternationalizationString.SensorPM25;
}
public bool Enable = true;
public int CurrentPM25;
}
[System.Serializable]
public class SensorCO2 : Sensor
{
public SensorCO2 ()
{
//CO2(07) 通道号,备注,使能位,当前CO2 ppm值
Type = DeviceType.SensorCO2;
DeviceTextID = SimpleControl.R.MyInternationalizationString.Environmental;
SensorTypeTestID = SimpleControl.R.MyInternationalizationString.SensorCO2;
}
public bool Enable = true;
public int CurrentCO2;
}
[System.Serializable]
public class SensorLPG : Sensor
{
public SensorLPG ()
{
//液化石油气(LPG)(08) 通道号,备注,使能位,当前LPG ppm值
Type = DeviceType.SensorLPG;
DeviceTextID = SimpleControl.R.MyInternationalizationString.Sensor;
SensorTypeTestID = SimpleControl.R.MyInternationalizationString.SensorLPG;
//人工煤气(CO,H2)(09) 通道号,备注,使能位,当前综合ppm值
//天然气(CH4)(10) 通道号,备注,使能位,当前综合ppm值
}
public bool Enable = true;
public byte CurrentLPG;
}
[System.Serializable]
public class SensorCOH2 : Sensor
{
public SensorCOH2 ()
{
//人工煤气(CO,H2)(09) 通道号,备注,使能位,当前综合ppm值
Type = DeviceType.SensorCOH2;
DeviceTextID = SimpleControl.R.MyInternationalizationString.Sensor;
SensorTypeTestID = SimpleControl.R.MyInternationalizationString.SensorCOH2;
}
public bool Enable = true;
public int CurrentCOH2;
}
[System.Serializable]
public class SensorCH4 : Sensor
{
public SensorCH4 ()
{
//天然气(CH4)(10) 通道号,备注,使能位,当前综合ppm值
Type = DeviceType.SensorCH4;
DeviceTextID = SimpleControl.R.MyInternationalizationString.Sensor;
SensorTypeTestID = SimpleControl.R.MyInternationalizationString.SensorCH4;
}
public bool Enable = true;
public int CurrentCH4;
}
[System.Serializable]
public class SensorSmoke : Sensor
{
public SensorSmoke ()
{
// 烟雾(11) 通道号,备注,使能位,当前状态
Type = DeviceType.SensorSmoke;
DeviceTextID = SimpleControl.R.MyInternationalizationString.Sensor;
SensorTypeTestID = SimpleControl.R.MyInternationalizationString.SensorSmoke;
}
public bool Enable = true;
public int CurrentStatus;
}
[System.Serializable]
public class SensorWindSpeed : Sensor
{
public SensorWindSpeed ()
{
//风速(12) 通道号,备注,使能位,当前风速
Type = DeviceType.SensorWindSpeed;
DeviceTextID = SimpleControl.R.MyInternationalizationString.Sensor;
SensorTypeTestID = SimpleControl.R.MyInternationalizationString.SensorWindSpeed;
}
public bool Enable = true;
public int CurrentWindSpeed;
}
[System.Serializable]
public class SensorWindPressure : Sensor
{
public SensorWindPressure ()
{
//风压(13) 通道号,备注,使能位,当前风压
Type = DeviceType.SensorWindPressure;
DeviceTextID = SimpleControl.R.MyInternationalizationString.Sensor;
SensorTypeTestID = SimpleControl.R.MyInternationalizationString.SensorWindPressure;
}
public bool Enable = true;
public int CurrentWindPressure;
}
[System.Serializable]
public class SensorLiquidFlow : Sensor
{
public SensorLiquidFlow ()
{
//液体流量(14) 通道号,备注,使能位,当前液体流量
Type = DeviceType.SensorLiquidFlow;
DeviceTextID = SimpleControl.R.MyInternationalizationString.Sensor;
SensorTypeTestID = SimpleControl.R.MyInternationalizationString.SensorLiquidFlow;
}
public bool Enable = true;
public int CurrentLiquidFlow;
}
[System.Serializable]
public class SensorLiquidPressure : Sensor
{
public SensorLiquidPressure ()
{
//液体压力(15) 通道号,备注,使能位,当前液体压力
Type = DeviceType.SensorLiquidPressure;
DeviceTextID = SimpleControl.R.MyInternationalizationString.Sensor;
SensorTypeTestID = SimpleControl.R.MyInternationalizationString.SensorLiquidPressure;
}
public bool Enable = true;
public int CurrentLiquidPressure;
}
[System.Serializable]
public class SensorLiquidDepth : Sensor
{
public SensorLiquidDepth ()
{
//液体深度(16) 通道号,备注,使能位,当前液体深度(mm)
Type = DeviceType.SensorLiquidDepth;
DeviceTextID = SimpleControl.R.MyInternationalizationString.Sensor;
SensorTypeTestID = SimpleControl.R.MyInternationalizationString.SensorLiquidDepth;
}
public bool Enable = true;
public int CurrentLiquidDepth;
}
[System.Serializable]
public class SensorRainfall : Sensor
{
public SensorRainfall ()
{
//雨量(17) 通道号,备注,使能位,当前雨量(无雨,小雨,大雨)
Type = DeviceType.SensorRainfall;
DeviceTextID = SimpleControl.R.MyInternationalizationString.Sensor;
SensorTypeTestID = SimpleControl.R.MyInternationalizationString.SensorRainfall;
}
public bool Enable = true;
public int CurrentRainfall;
}
[System.Serializable]
public class SensorWeight : Sensor
{
public SensorWeight ()
{
//重量(18) 通道号,备注,使能位,当前物体重量(KG)
Type = DeviceType.SensorWeight;
DeviceTextID = SimpleControl.R.MyInternationalizationString.Sensor;
SensorTypeTestID = SimpleControl.R.MyInternationalizationString.SensorWeight;
}
public bool Enable = true;
public int CurrentWeight;
}
[System.Serializable]
public class SensorHeightLength : Sensor
{
public SensorHeightLength ()
{
//高度/长度(19) 通道号,备注,使能位,测量高度/长度(mm)
Type = DeviceType.SensorHeightLength;
DeviceTextID = SimpleControl.R.MyInternationalizationString.Sensor;
SensorTypeTestID = SimpleControl.R.MyInternationalizationString.SensorHeightLength;
}
public bool Enable = true;
public int CurrentHeightLength;
}
[System.Serializable]
public class SensorVelocity : Sensor
{
public SensorVelocity ()
{
//物体速度(20) 通道号,备注,当前物体速度(m/s)
Type = DeviceType.SensorHeightLength;
DeviceTextID = SimpleControl.R.MyInternationalizationString.Sensor;
SensorTypeTestID = SimpleControl.R.MyInternationalizationString.SensorVelocity;
}
public bool Enable = true;
public int CurrentVelocity;
}
[System.Serializable]
public class SensorVibration : Sensor
{
public SensorVibration ()
{
//震动(21) 通道号,备注,使能位,震动状态
Type = DeviceType.SensorVibration;
DeviceTextID = SimpleControl.R.MyInternationalizationString.Sensor;
SensorTypeTestID = SimpleControl.R.MyInternationalizationString.SensorVibration;
}
public bool Enable = true;
public int CurrentVibration;
}
[System.Serializable]
public class SensorVoltage : Sensor
{
public SensorVoltage ()
{
//电压(22) 通道号,备注,使能位,当前电压
Type = DeviceType.SensorVoltage;
DeviceTextID = SimpleControl.R.MyInternationalizationString.Sensor;
SensorTypeTestID = SimpleControl.R.MyInternationalizationString.SensorVoltage;
}
public bool Enable = true;
public int CurrentVoltage;
}
[System.Serializable]
public class SensorCurrent : Sensor
{
public SensorCurrent ()
{
//电流(23) 通道号,备注,使能位,当前电流
Type = DeviceType.SensorVoltage;
DeviceTextID = SimpleControl.R.MyInternationalizationString.Sensor;
SensorTypeTestID = SimpleControl.R.MyInternationalizationString.SensorCurrent;
}
public bool Enable = true;
public int CurrentCurrent;
}
[System.Serializable]
public class SensorPower : Sensor
{
public SensorPower ()
{
//功率(24) 通道号,备注,使能位,当前功率
Type = DeviceType.SensorPower;
DeviceTextID = SimpleControl.R.MyInternationalizationString.Sensor;
SensorTypeTestID = SimpleControl.R.MyInternationalizationString.SensorPower;
}
public bool Enable = true;
public int CurrentPower;
}
}