2 from PLC.Faults import *
3 from PLC.Method import Method
4 from PLC.Parameter import Parameter, Mixed
5 from PLC.PCUTypes import PCUType, PCUTypes
6 from PLC.Auth import Auth
8 can_update = lambda (field, value): field in \
11 class AddPCUType(Method):
15 Returns the new pcu_type_id (> 0) if successful, faults otherwise.
20 pcu_type_fields = dict(filter(can_update, PCUType.fields.items()))
27 returns = Parameter(int, 'New pcu_type_id (> 0) if successful')
30 def call(self, auth, pcu_type_fields):
31 pcu_type_fields = dict(filter(can_update, pcu_type_fields.items()))
32 pcu_type = PCUType(self.api, pcu_type_fields)
34 self.event_object = {'PCUType': [pcu_type['pcu_type_id']]}
36 return pcu_type['pcu_type_id']