// Update is called once per frame void Update() { string timestamp = System.DateTime.UtcNow.ToLongTimeString() + ":" + System.DateTime.UtcNow.Millisecond; if (requestPool.Count > 0) { foreach (Request request in requestPool) { request.Execute(phase1, phase2, phase3); request.IsRequestDone = true; if (logger != null) { logger.PhasesStates(phase1, phase2, phase3); } else { InitLogger(); } } } // StartCoroutine(database.InsertElectricityData(timestamp, "1", phase1.Active_power, phase1.Reactive_power)); // StartCoroutine(database.InsertElectricityData(timestamp, "2", phase2.Active_power, phase2.Reactive_power)); // StartCoroutine(database.InsertElectricityData(timestamp, "3", phase3.Active_power, phase3.Reactive_power)); shServer.InsertElectricityData(timestamp, "1", phase1.Active_power, phase1.Reactive_power); shServer.InsertElectricityData(timestamp, "2", phase2.Active_power, phase2.Reactive_power); shServer.InsertElectricityData(timestamp, "3", phase3.Active_power, phase3.Reactive_power); requestPool.Clear(); }
protected override void IESensorUpdate() { base.IESensorUpdate(); lastUpdate -= Time.deltaTime; if (lastUpdate <= 0) { string timestamp = System.DateTime.UtcNow.ToLongTimeString() + ":" + System.DateTime.UtcNow.Millisecond; ElectricPhase _electricPhase; for (int i = 0; i < phasesNumber; i++) { _electricPhase = electricPhases [i] as ElectricPhase; SmartHomeServer.InsertElectricityData(timestamp, "" + i, _electricPhase.ActivePower, _electricPhase.ReactivePower); } lastUpdate = updateFrequence; } }