Update led manager to consume DutyOn and Period values

Previous code only considered the Name and Action for the LED but then
DutyOn and Period are also the properties that are associated with LED
and this patchset handles that.

Change-Id: Ifb57719ed3bcf01a4704618089d9ce676e4b951c
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
diff --git a/led.yaml b/led.yaml
index a4e1f89..cced3ab 100755
--- a/led.yaml
+++ b/led.yaml
@@ -1,119 +1,122 @@
-EnclosureIdentify:
-    EnclosureIdentifyFront:
-        action: Blink
-    EnclosureIdentifyBack:
-        action: Blink
-
 EnclosureFault:
-    EnclosureFaultFront:
-        action: 'On'
-    EnclosureFaultBack:
-        action: 'On'
-
-PowerSupply1Identify:
-    PowerSupply_1:
-        action: Blink
-    EnclosureIdentifyFront:
-        action: 'On'
-    EnclosureIdentifyBack:
-        action: 'On'
-
-PowerSupply1Fault:
-    PowerSupply_1:
-        action: 'On'
-    EnclosureFaultFront:
-        action: 'On'
-    EnclosureFaultBack:
-        action: 'On'
-
-PowerSupply2Identify:
-    PowerSupply_2:
-        action: Blink
-    EnclosureIdentifyFront:
-        action: 'On'
-    EnclosureIdentifyBack:
-        action: 'On'
-
-PowerSupply2Fault:
-    PowerSupply_2:
-        action: 'On'
-    EnclosureFaultFront:
-        action: 'On'
-    EnclosureFaultBack:
-        action: 'On'
-
-FanA1Identify:
-    Fan_A1:
-        action: Blink
-    EnclosureIdentifyFront:
-        action: 'On'
-    EnclosureIdentifyBack:
-        action: 'On'
-
-FanA1Fault:
-    Fan_A1:
-        action: 'On'
-    EnclosureFaultFront:
-        action: 'On'
-    EnclosureFaultBack:
-        action: 'On'
-
-FanA2Identify:
-    Fan_A2:
-        action: Blink
-    EnclosureIdentifyFront:
-        action: 'On'
-    EnclosureIdentifyBack:
-        action: 'On'
-
-FanA2Fault:
-    Fan_A2:
-        action: 'On'
-    EnclosureFaultFront:
-        action: 'On'
-    EnclosureFaultBack:
-        action: 'On'
-
-FanA3Identify:
-    Fan_A3:
-        action: Blink
-    EnclosureIdentifyFront:
-        action: 'On'
-    EnclosureIdentifyBack:
-        action: 'On'
-
-FanA3Fault:
-    Fan_A3:
-        action: 'On'
-    EnclosureFaultFront:
-        action: 'On'
-    EnclosureFaultBack:
-        action: 'On'
-
-FanA4Identify:
-    Fan_A4:
-        action: Blink
-    EnclosureIdentifyFront:
-        action: 'On'
-    EnclosureIdentifyBack:
-        action: 'On'
-
-FanA4Fault:
-    Fan_A4:
-        action: 'On'
-    EnclosureFaultFront:
-        action: 'On'
-    EnclosureFaultBack:
-        action: 'On'
-
-PowerOn:
-    OpPanelFront:
-        action: 'On'
-    PanelPowerButtOnNote1:
-        action: 'On'
-
-PowerOff:
-    OpPanelFront:
-        action: Blink
-    PanelPowerButtOnNote1:
-        action: Blink
+    rear-fault-led:
+        Action: 'On'
+        DutyOn: 50
+        Period: 0
+    front-fault-led:
+        Action: 'On'
+        DutyOn: 50
+        Period: 0
+EnclosureIdentify:
+    front-id-led:
+        Action: 'Blink'
+        DutyOn: 50
+        Period: 1000
+    rear-id-led:
+        DutyOn: 50
+        Action: 'Blink'
+        Period: 1000
+Fan0Fault:
+    front-fault-led:
+        Period: 0
+        DutyOn: 50
+        Action: 'On'
+    fan0:
+        DutyOn: 50
+        Action: 'On'
+        Period: 0
+    rear-fault-led:
+        Period: 0
+        DutyOn: 50
+        Action: 'On'
+Fan0Identify:
+    front-id-led:
+        Period: 1000
+        Action: 'Blink'
+        DutyOn: 50
+    rear-id-led:
+        Period: 1000
+        Action: 'Blink'
+        DutyOn: 50
+    fan0:
+        DutyOn: 50
+        Action: 'Blink'
+        Period: 1000
+Fan1Fault:
+    front-fault-led:
+        Period: 0
+        Action: 'On'
+        DutyOn: 50
+    fan1:
+        Period: 0
+        DutyOn: 50
+        Action: 'On'
+    rear-fault-led:
+        Period: 0
+        Action: 'On'
+        DutyOn: 50
+Fan1Identify:
+    front-id-led:
+        Period: 1000
+        DutyOn: 50
+        Action: 'Blink'
+    fan1:
+        Period: 1000
+        DutyOn: 50
+        Action: 'Blink'
+    rear-id-led:
+        DutyOn: 50
+        Action: 'Blink'
+        Period: 1000
+Fan2Fault:
+    fan2:
+        Action: 'On'
+        DutyOn: 50
+        Period: 0
+    rear-fault-led:
+        Period: 0
+        Action: 'On'
+        DutyOn: 50
+    front-fault-led:
+        DutyOn: 50
+        Action: 'On'
+        Period: 0
+Fan2Identify:
+    fan2:
+        DutyOn: 50
+        Action: 'Blink'
+        Period: 1000
+    front-id-led:
+        Period: 1000
+        Action: 'Blink'
+        DutyOn: 50
+    rear-id-led:
+        DutyOn: 50
+        Action: 'Blink'
+        Period: 1000
+Fan3Fault:
+    front-fault-led:
+        DutyOn: 50
+        Action: 'On'
+        Period: 0
+    rear-fault-led:
+        Action: 'On'
+        DutyOn: 50
+        Period: 0
+    fan3:
+        DutyOn: 50
+        Action: 'On'
+        Period: 0
+Fan3Identify:
+    rear-id-led:
+        Action: 'Blink'
+        DutyOn: 50
+        Period: 1000
+    front-id-led:
+        Action: 'Blink'
+        DutyOn: 50
+        Period: 1000
+    fan3:
+        DutyOn: 50
+        Action: 'On'
+        Period: 0
diff --git a/ledlayout.hpp b/ledlayout.hpp
index d3d0e40..998feb5 100644
--- a/ledlayout.hpp
+++ b/ledlayout.hpp
@@ -28,6 +28,8 @@
     {
         std::string name;
         Action action;
+        uint8_t dutyOn;
+        uint16_t period;
 
         // Needed for inserting elements into sets
         bool operator<(const LedAction& right) const
diff --git a/parse_led.py b/parse_led.py
index 35f67aa..c86764c 100755
--- a/parse_led.py
+++ b/parse_led.py
@@ -15,15 +15,23 @@
         ofile.write(' std::set<phosphor::led::Layout::LedAction>>')
         ofile.write(' systemLedMap = {\n\n')
         for group in ifile.iterkeys():
-            # Value of this group is a std::set<string, led structure>
+            # This section generates an std::map of LedGroupNames to std::set
+            # of LEDs containing the name and properties
             ledset = ifile[group]
             ofile.write('   {\"' + "/xyz/openbmc_project/ledmanager/groups/" + group + '\",{\n')
 
             for led_dict, list_dict in ledset.iteritems():
+                # Need this to make sure the LED name is printed once
+                name_printed = False
                 for name, value in list_dict.iteritems():
-                    if group and led_dict and name and value:
-                        ofile.write('        {\"' + led_dict + '\",')
-                        ofile.write('phosphor::led::Layout::' + value + '},\n')
+                    if group and led_dict and name:
+                        if name_printed is False:
+                            ofile.write('        {\"' + led_dict + '\",')
+                            name_printed = True
+                        if name == 'Action':
+                            ofile.write('phosphor::led::Layout::')
+                        ofile.write(str(value) + ',')
+                ofile.write('},\n')
             ofile.write('   }},\n')
         ofile.write('};\n')