コード例 #1
0
        private void interval()
        {
            Log.Debug("--- interval started");
            intervalLength = Int32.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Interval").Value);
            foreach (PowerCollection pc in pcList)
            {
                try
                {
                    if (pc.PacketCount >= intervalLength)
                    {
                        string errorStr = OSAEObjectPropertyManager.GetObjectPropertyValue(OSAEObjectManager.GetObjectByAddress("KAW" + pc.Address).Name, "Error Correction").Value;
                        Log.Debug("  errorStr: " + errorStr);
                        Double errorCorrection = 0, currentWatts;
                        System.Globalization.NumberStyles styles = System.Globalization.NumberStyles.AllowTrailingSign | System.Globalization.NumberStyles.Float;

                        try
                        {
                            if (errorStr.Length > 1)
                            {
                                errorCorrection = Double.Parse(errorStr, styles);
                            }
                        }
                        catch
                        { }

                        currentWatts = pc.GetInterval() + errorCorrection;
                        if (currentWatts < 0)
                        {
                            currentWatts = 0;
                        }

                        Log.Debug("  device address: " + pc.Address);
                        Log.Debug("  dataWattBuffer: " + pc.DataWattBuffer);
                        Log.Debug("  dataWattCount: " + pc.PacketCount);
                        Log.Debug("  errorStr: " + errorStr);
                        OSAEObjectPropertyManager.ObjectPropertySet(OSAEObjectManager.GetObjectByAddress("KAW" + pc.Address).Name, "RSSI", pc.RSSI.ToString(), pName);
                        OSAEObjectPropertyManager.ObjectPropertySet(OSAEObjectManager.GetObjectByAddress("KAW" + pc.Address).Name, "Current Watts", currentWatts.ToString(), pName);
                        pc.DataWattBuffer = 0;
                        pc.PacketCount    = 0;
                    }
                }
                catch (Exception ex)
                {
                    Log.Error("  error inserting dat!", ex);
                    break;
                }
            }
            //addToLog("--- interval ended");
        }