Exemple #1
0
        public virtual void SendEnergyData(eEnergyThingCaps pSenderType, double pWatts, double pVolts, double pAmps)
        {
            TheEnergyData LastEnergyData = new TheEnergyData()
            {
                Watts = pWatts,
                Volts = pVolts,
                Amps  = pAmps,
            };

            SendEnergyData(pSenderType, LastEnergyData);
        }
Exemple #2
0
        public virtual void SendEnergyData(eEnergyThingCaps pSenderType, TheEnergyData LastEnergyData, bool Force = false)
        {
            if (LastEnergyData == null || (Force == false && (PublishInterval == 0 || DateTimeOffset.Now.Subtract(LastPublish).TotalSeconds < PublishInterval)))
            {
                return;
            }
            LastPublish              = DateTimeOffset.Now;
            LastEnergyData.Time      = DateTime.Now;
            LastEnergyData.StationID = MyBaseThing.cdeMID;
            string tMessageTxt = eEnergyMessages.EnergyConsumerUpdate;

            switch (pSenderType)
            {
            case eEnergyThingCaps.EnergyBreaker:
                tMessageTxt = eEnergyMessages.EnergyBreakerUpdate;
                break;

            case eEnergyThingCaps.EnergyStorage:
                tMessageTxt = eEnergyMessages.EnergyStorageUpdate;
                break;

            case eEnergyThingCaps.EnergyPanel:
                tMessageTxt = eEnergyMessages.EnergyPanelUpdate;
                break;

            case eEnergyThingCaps.EnergyProducer:
                tMessageTxt = eEnergyMessages.EnergyProducerUpdate;
                break;

            case eEnergyThingCaps.EnergyTank:
                tMessageTxt = eEnergyMessages.EnergyTankUpdate;
                break;
            }
            LastEnergyData.StationName = $"{tMessageTxt}: {MyBaseThing.FriendlyName}";;
            TSM msgEnergy2 = new TSM("EnergyMessages", $"{tMessageTxt}:{MyBaseThing.cdeMID}", CU.SerializeObjectToJSONString(LastEnergyData));

            msgEnergy2.SetNoDuplicates(true);
            TCC.PublishCentral(msgEnergy2, true);
        }