コード例 #1
0
        public override bool Save(IInverter inv, ConverterStatus value)
        {
            if (_timeService.GetCurrentDateTime().Subtract(_lastAdd).TotalSeconds < 10)
            {
                return(false);
            }

            ushort uiValue = (ushort)value.TypeStatus.GetProperty(CommonPropertyType.ProduzioneCorrente);
            float  temp1   = (float)value.TypeStatus.GetProperty(CommonPropertyType.Temperatura1);

            _localData.CurrentProductions.Add((int)(value.CommonStatus.EnergieTag * 1000));
            _localData.CurrentPowers.Add((int)uiValue);
            _localData.Taketimes.Add(_timeService.GetCurrentDateTime());
            _localData.Temps.Add(temp1);
            _lastAdd = _timeService.GetCurrentDateTime();
            _logger.LogDebug($"Data added: Count={_localData.CurrentPowers.Count}");
            if (_localData.CurrentPowers.Count >= 30)
            {
                lock (this)
                {
                    _logger.LogDebug("Comunicate to pvoutput for addbatchstatus");

                    string        key = "key=024fe8dd52991266562af15510ab1a999c927805&sid=9627";
                    List <string> sb  = new List <string>();

                    for (int index = 0; index < _localData.CurrentPowers.Count; index++)
                    {
                        sb.Add(String.Format("{0:yyyyMMdd},{1:HH:mm},{2},{3},{4},{5},{6},{7}",
                                             _localData.Taketimes[index],
                                             _localData.Taketimes[index],
                                             _localData.CurrentProductions[index],
                                             (int)_localData.CurrentPowers[index],
                                             -1,
                                             -1,
                                             _localData.Temps[index].ToString("0.0", new System.Globalization.CultureInfo("en-US")),
                                             value.TypeStatus.GetProperty(Enums.CommonPropertyType.UAC)
                                             ));
                    }

                    string statusParameters = "data=" + String.Join(";", sb.ToArray());
                    string statusURI        = "http://pvoutput.org/service/r2/addbatchstatus.jsp?";
                    string statusUrl        = statusURI + key + "&" + statusParameters;
                    _logger.LogDebug("status url:" + statusUrl);
                    string responseValue = "";
                    bool   response      = _doGETRequest(statusUrl, ref responseValue);

                    _localData.Clear();
                    return(response);
                }
            }
            return(false);
        }
コード例 #2
0
        public override bool Save(IInverter inv, ConverterStatus value)
        {
            if (_currentInformations.ContainsKey(inv.SerialeNumber) == false)
            {
                _currentInformations.Add(inv.SerialeNumber, new CurrentInformation()
                {
                    CurrentDay = _timeService.GetCurrentDate().Day
                });
            }

            CurrentInformation ci = _currentInformations[inv.SerialeNumber];

            ushort uiValue = (ushort)value.TypeStatus.GetProperty(CommonPropertyType.ProduzioneCorrente);
            float  temp1   = (float)value.TypeStatus.GetProperty(CommonPropertyType.Temperatura1);

            ci.CurrentProduction = (int)(value.CommonStatus.EnergieTag * 1000);
            ci.CurrentPowers.Add((int)uiValue);
            ci.Temps.Add(temp1);

            if (_timeService.GetCurrentDateTime().Subtract(_lastSend).TotalSeconds > _sendIntervalSeconds)
            {
                // LogFactory.GetLog().WriteToLog(TraceEventType.Verbose, "Comunicate to pvoutput for addstatus");

                int prodGiornaliera = ci.CurrentProduction;

                string key = "key=024fe8dd52991266562af15510ab1a999c927805&sid=9627";
                string statusParameters = String.Format("d={0:yyyyMMdd}&t={2:HH:mm}&v1={1}&v2={3}&v5={4}&v6={5}",
                                                        _timeService.GetCurrentDate(),
                                                        prodGiornaliera,
                                                        _timeService.GetCurrentDateTime(),
                                                        ci.MaxPower,
                                                        ci.AverangeTemps.ToString("0.0", new System.Globalization.CultureInfo("en-US")),
                                                        value.TypeStatus.GetProperty(Enums.CommonPropertyType.UAC)
                                                        );
                string statusURI = "http://pvoutput.org/service/r2/addstatus.jsp?";
                string statusUrl = statusURI + key + "&" + statusParameters;
                // LogFactory.GetLog().WriteToLog(TraceEventType.Verbose, "status url:" + statusUrl);
                string responseValue = "";
                bool   response      = _doGETRequest(statusUrl, ref responseValue);

                _lastSend = _timeService.GetCurrentDateTime();
                ci.CurrentPowers.Clear();

                return(response);
            }
            return(false);
        }
コード例 #3
0
ファイル: EmonCMSPersister.cs プロジェクト: flecce/HomeBot
        public override bool Save(IInverter inv, ConverterStatus value)
        {
            if (_currentInformations.ContainsKey(inv.SerialeNumber) == false)
            {
                _currentInformations.Add(inv.SerialeNumber, new CurrentInformation()
                {
                    CurrentDay = _timeService.GetCurrentDate().Day
                });
            }

            CurrentInformation ci = _currentInformations[inv.SerialeNumber];

            ushort uiValue = (ushort)value.TypeStatus.GetProperty(CommonPropertyType.ProduzioneCorrente);
            float  temp1   = (float)value.TypeStatus.GetProperty(CommonPropertyType.Temperatura1);

            ci.CurrentProduction = (int)(value.CommonStatus.EnergieTag * 1000);
            ci.CurrentPowers.Add((int)uiValue);
            ci.Temps.Add(temp1);

            if (_timeService.GetCurrentDateTime().Subtract(_lastSend).TotalSeconds > _sendIntervalSeconds)
            {
                // LogFactory.GetLog().WriteToLog(TraceEventType.Verbose, "Comunicating... to emoncms for post");

                int prodGiornaliera = ci.CurrentProduction;

                string statusURI = "http://emoncms.org/input/post?apikey=cfe3a5e1be7b49c6d6a1aa372f32ec3a&json={invtotgen:" + ci.CurrentProduction.ToString() + ",invcurpwd:" + ci.MaxPower.ToString() + "}";
                //string statusUrl = String.Format(statusURI, ci.CurrentProduction, ci.MaxPower);
                // LogFactory.GetLog().WriteToLog(TraceEventType.Verbose, "status url:" + statusURI);
                string responseValue = "";
                bool   response      = _doGETRequest(statusURI, ref responseValue);
                // LogFactory.GetLog().WriteToLog(TraceEventType.Verbose, "  Comunication ok");

                _lastSend = _timeService.GetCurrentDateTime();
                ci.CurrentPowers.Clear();

                return(response);
            }
            return(false);
        }
コード例 #4
0
 private void UpdateConverterStatus(ConverterStatus state)
 {
     ConverterStatusText.Text  = $"Status: {state}";
     Converter.ConverterActive = state == ConverterStatus.Active;
 }