Newer
Older
SensorHub / SensorHub.LampNB / LampData.cs
root on 17 Sep 2021 2 KB first commit
using Newtonsoft.Json;
using SensorHub.Servers.JsonFormat;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SensorHub.LampNBServer
{
    public class LampData : DatasJson
    {
        [JsonProperty("state", DefaultValueHandling = DefaultValueHandling.Ignore)]
        [DefaultValue(null)]
        public int? state { get; set; }//异常状态

        [JsonProperty("electricity", DefaultValueHandling = DefaultValueHandling.Ignore)]
        [DefaultValue(null)]
        public float? electricity { get; set; }

        [JsonProperty("voltage", DefaultValueHandling = DefaultValueHandling.Ignore)]
        [DefaultValue(null)]
        public float? voltage { get; set; }

        [JsonProperty("activePower", DefaultValueHandling = DefaultValueHandling.Ignore)]
        [DefaultValue(null)]
        public float? activePower { get; set; }

        [JsonProperty("reactivePower", DefaultValueHandling = DefaultValueHandling.Ignore)]
        [DefaultValue(null)]
        public float? reactivePower { get; set; }

        //public float? apparentPower { get; set; }
        [JsonProperty("activeEnergy", DefaultValueHandling = DefaultValueHandling.Ignore)]
        [DefaultValue(null)]
        public float? activeEnergy { get; set; }

        [JsonProperty("reactiveEnergy", DefaultValueHandling = DefaultValueHandling.Ignore)]
        [DefaultValue(null)]
        public float? reactiveEnergy { get; set; }
        //public float? apparentEnergy { get; set; }

        public LampData(int? state, float? electricity, float? voltage,
          float? activePower, float? reactivePower, float? activeEnergy, float? reactiveEnergy)
        {
            this.state = state;
            this.electricity = electricity;
            this.voltage = voltage;
            this.activePower = activePower;
            this.reactivePower = reactivePower;
            this.activeEnergy = activeEnergy;
            this.reactiveEnergy = reactiveEnergy;

            DateTime now = DateTime.Now;
            this.uptime = now.ToString("yyyy") + now.ToString("MM") + now.ToString("dd")
                                + now.ToString("HH") + now.ToString("mm") + now.ToString("ss");
        }

        public LampData(int? state, float? electricity)
        {
            this.state = state;
            this.electricity = electricity;

            DateTime now = DateTime.Now;
            this.uptime = now.ToString("yyyy") + now.ToString("MM") + now.ToString("dd")
                                + now.ToString("HH") + now.ToString("mm") + now.ToString("ss");
        }

        public LampData(int? state)
        {
            this.state = state;

            DateTime now = DateTime.Now;
            this.uptime = now.ToString("yyyy") + now.ToString("MM") + now.ToString("dd")
                                + now.ToString("HH") + now.ToString("mm") + now.ToString("ss");
        }
    }
}