Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Copyright 2019 TomorrowData SRL
- Licensed under the Software License Agreement ("Agreement") contained in the root
- directory of this project (LICENCE.txt).
- You may not use this file except in compliance with the License.
- You may obtain a copy of the License writing to tomorrowdatasrl@legalmail.it
- YOU ASSUME ALL RISKS AND ALL COSTS ASSOCIATED WITH YOUR USE
- OF THE SERVICE, INCLUDING, WITHOUT LIMITATION, ANY INTERNET ACCESS FEES, BACK-UP
- EXPENSES, COSTS INCURRED FOR THE USE OF YOUR DEVICE AND PERIPHERALS, AND ANY
- DAMAGE TO ANY EQUIPMENT, SOFTWARE, INFORMATION OR DATA.
- See the License for the specific language governing permissions and
- limitations under the License.
- """
- from datetime import timedelta
- import monotonic
- from plc.base_machine_data_processor import BaseNormalizer
- class Normalizer(BaseNormalizer):
- def __init__(self, args, get_asac_data):
- self.logger = self.get_logger()
- self.args = args
- self.get_asac_data = get_asac_data
- self.status = None
- def elaborate_asac(self):
- self.status = self.get_asac_data()
- self.logger.info(
- 'Custom normalizer asac elaboration with: {}'.format(self.status)
- )
- def run(self, date, payload):
- """
- calculate oee parameters from payload
- """
- active_time = self.active_time(payload)
- Local_1_CPt00FilterOffOn = self.Local_1_CPt00FilterOffOn(payload)
- Slot4Output_Select = self.Slot4Output_Select(payload)
- Slot4Test_IntervalPRE = self.Slot4Test_IntervalPRE(payload)
- combo = Local_1_CPt00FilterOffOn * Slot4Test_IntervalPRE
- return {
- "date": str(date),
- "Local_1_CPt00FilterOffOn": Local_1_CPt00FilterOffOn,
- "Slot4Output_Select": Slot4Output_Select,
- "Slot4Test_IntervalPRE": Slot4Test_IntervalPRE,
- "combo": combo,
- "comment": "'combo' is Local_1_CPt00FilterOffOn * Slot4Test_IntervalPRE"
- }
- def active_time(self, payload):
- """
- override this function to customize your active time calculation
- """
- try:
- active_time = timedelta(
- hours=payload.get(
- self.args['active_hours'].get('mem_ref_id'),
- self.args['active_hours'].get('default_value', None)
- ),
- minutes=payload.get(
- self.args['active_minutes'].get('mem_ref_id'),
- self.args['active_minutes'].get('default_value', None)
- ),
- seconds=payload.get(
- self.args['active_seconds'].get('mem_ref_id'),
- self.args['active_seconds'].get('default_value', None)
- )
- ).total_seconds()
- except Exception as e:
- self.logger.error('Unable to calculate active time: {}'.format(e))
- raise
- return active_time
- def Local_1_CPt00FilterOffOn(self, payload):
- """
- override this function to customize your nominal_speed calculation
- """
- try:
- Local_1_CPt00FilterOffOn = payload.get(
- self.args['Local_1_CPt00FilterOffOn'].get('mem_ref_id'),
- self.args['Local_1_CPt00FilterOffOn'].get('default_value', None)
- )
- except Exception as e:
- self.logger.error('Unable to calculate Local_1_CPt00FilterOffOn: {}'.format(e))
- raise
- return Local_1_CPt00FilterOffOn
- def Slot4Output_Select(self, payload):
- """
- override this function to customize your pieces_produced calculation
- """
- try:
- Slot4Output_Select = payload.get(
- self.args['Slot4Output_Select'].get('mem_ref_id'),
- self.args['Slot4Output_Select'].get('default_value', None)
- )
- except Exception as e:
- self.logger.error('Unable to calculate Slot4Output_Select: {}'.format(e))
- raise
- return Slot4Output_Select
- def Slot4Test_IntervalPRE(self, payload):
- """
- override this function to customize your pieces_wasted calculation
- """
- try:
- Slot4Test_IntervalPRE = payload.get(
- self.args['Slot4Test_IntervalPRE'].get('mem_ref_id'),
- self.args['Slot4Test_IntervalPRE'].get('default_value', None)
- )
- except Exception as e:
- self.logger.error('Unable to calculate Slot4Test_IntervalPRE: {}'.format(e))
- raise
- return Slot4Test_IntervalPRE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement