Example #1
0
    def test_serial_conversion(self):
        procedure = Procedure()

        templates = PROCEDURE_TEMPLATE_DIR

        test_file = 'diagnosticV3.000'
        json_file = 'test.json'

        proc_dict = procedure.from_file(os.path.join(templates, test_file))

        test_step_dict = proc_dict['MaccorTestProcedure']['ProcSteps'][
            'TestStep']

        converter = ProcedureToSchedule(test_step_dict)
        step_name_list, step_flow_ctrl = converter.create_metadata()

        for step_index, step in enumerate(test_step_dict):
            if 'Loop' in step['StepType']:
                print(step_index, step)
            step_arbin = converter.compile_to_arbin(test_step_dict[step_index],
                                                    step_index, step_name_list,
                                                    step_flow_ctrl)
            if 'Loop' in step['StepType']:
                self.assertEqual(step_arbin['m_szStepCtrlType'],
                                 'Set Variable(s)')
                self.assertEqual(step_arbin['m_uLimitNum'], '2')
            if step_index == 15:
                self.assertEqual(step_arbin['Limit0']['m_szGotoStep'],
                                 '11-None')
                self.assertEqual(step_arbin['Limit1']['m_szGotoStep'],
                                 'Next Step')
Example #2
0
    def test_serial_conversion(self):
        procedure = Procedure()

        templates = PROCEDURE_TEMPLATE_DIR

        test_file = "diagnosticV3.000"
        json_file = "test.json"

        proc_dict = procedure.from_file(os.path.join(templates, test_file))

        test_step_dict = proc_dict["MaccorTestProcedure"]["ProcSteps"][
            "TestStep"]

        converter = ProcedureToSchedule(test_step_dict)
        step_name_list, step_flow_ctrl = converter.create_metadata()

        for step_index, step in enumerate(test_step_dict):
            if "Loop" in step["StepType"]:
                print(step_index, step)
            step_arbin = converter.compile_to_arbin(test_step_dict[step_index],
                                                    step_index, step_name_list,
                                                    step_flow_ctrl)
            if "Loop" in step["StepType"]:
                self.assertEqual(step_arbin["m_szStepCtrlType"],
                                 "Set Variable(s)")
                self.assertEqual(step_arbin["m_uLimitNum"], "2")
            if step_index == 15:
                self.assertEqual(step_arbin["Limit0"]["m_szGotoStep"],
                                 "11-None")
                self.assertEqual(step_arbin["Limit1"]["m_szGotoStep"],
                                 "Next Step")
Example #3
0
    def test_schedule_creation(self):
        procedure = Procedure()

        templates = PROCEDURE_TEMPLATE_DIR

        test_file = 'diagnosticV3.000'
        json_file = 'test.json'
        sdu_test_input = os.path.join(SCHEDULE_TEMPLATE_DIR,
                                      '20170630-3_6C_9per_5C.sdu')
        sdu_test_output = os.path.join(TEST_FILE_DIR,
                                       'schedule_test_output.sdu')

        proc_dict = procedure.from_file(os.path.join(templates, test_file))
        test_step_dict = proc_dict['MaccorTestProcedure']['ProcSteps'][
            'TestStep']

        converter = ProcedureToSchedule(test_step_dict)
        converter.create_sdu(sdu_test_input, sdu_test_output)
        parsed = open(sdu_test_output, encoding='latin-1').readlines()
        self.assertEqual(parsed[329], '[Schedule_Step3_Limit0]\n')
        os.remove(sdu_test_output)
Example #4
0
    def test_single_step_conversion(self):
        procedure = Procedure()

        templates = PROCEDURE_TEMPLATE_DIR

        test_file = "diagnosticV3.000"
        json_file = "test.json"

        proc_dict = procedure.from_file(os.path.join(templates, test_file))
        test_step_dict = proc_dict["MaccorTestProcedure"]["ProcSteps"][
            "TestStep"]

        converter = ProcedureToSchedule(test_step_dict)
        step_index = 5
        step_name_list, step_flow_ctrl = converter.create_metadata()

        self.assertEqual(step_flow_ctrl[7], "5-reset cycle C/20")
        self.assertEqual(step_flow_ctrl[68], "38-reset cycle")

        step_arbin = converter.compile_to_arbin(test_step_dict[step_index],
                                                step_index, step_name_list,
                                                step_flow_ctrl)
        self.assertEqual(step_arbin["m_szLabel"], "6-None")
        self.assertEqual(step_arbin["Limit0"]["m_szGotoStep"], "Next Step")
        self.assertEqual(step_arbin["Limit0"]["Equation0_szLeft"],
                         "PV_CHAN_Voltage")
        self.assertEqual(step_arbin["Limit2"]["m_szGotoStep"],
                         "70-These are the 2 reset cycles")

        step_index = 8
        step_arbin = converter.compile_to_arbin(test_step_dict[step_index],
                                                step_index, step_name_list,
                                                step_flow_ctrl)

        self.assertEqual(step_arbin["Limit0"]["Equation0_szLeft"],
                         "PV_CHAN_CV_Stage_Current")
        self.assertEqual(
            step_arbin["Limit0"]["Equation0_szRight"],
            test_step_dict[step_index]["Ends"]["EndEntry"][0]["Value"],
        )
Example #5
0
    def test_single_step_conversion(self):
        procedure = Procedure()

        templates = PROCEDURE_TEMPLATE_DIR

        test_file = 'diagnosticV3.000'
        json_file = 'test.json'

        proc_dict = procedure.from_file(os.path.join(templates, test_file))
        test_step_dict = proc_dict['MaccorTestProcedure']['ProcSteps'][
            'TestStep']

        converter = ProcedureToSchedule(test_step_dict)
        step_index = 5
        step_name_list, step_flow_ctrl = converter.create_metadata()

        self.assertEqual(step_flow_ctrl[7], '5-reset cycle C/20')
        self.assertEqual(step_flow_ctrl[68], '38-reset cycle')

        step_arbin = converter.compile_to_arbin(test_step_dict[step_index],
                                                step_index, step_name_list,
                                                step_flow_ctrl)
        self.assertEqual(step_arbin['m_szLabel'], '6-None')
        self.assertEqual(step_arbin['Limit0']['m_szGotoStep'], 'Next Step')
        self.assertEqual(step_arbin['Limit0']['Equation0_szLeft'],
                         'PV_CHAN_Voltage')
        self.assertEqual(step_arbin['Limit2']['m_szGotoStep'],
                         '70-These are the 2 reset cycles')

        step_index = 8
        step_arbin = converter.compile_to_arbin(test_step_dict[step_index],
                                                step_index, step_name_list,
                                                step_flow_ctrl)

        self.assertEqual(step_arbin['Limit0']['Equation0_szLeft'],
                         'PV_CHAN_CV_Stage_Current')
        self.assertEqual(
            step_arbin['Limit0']['Equation0_szRight'],
            test_step_dict[step_index]['Ends']['EndEntry'][0]['Value'])
Example #6
0
    def test_schedule_creation(self):
        protocol_params_dict = {
            'project_name': ['PreDiag'],
            'seq_num': [100],
            'template': ['diagnosticV3.000'],
            'charge_constant_current_1': [1],
            'charge_percent_limit_1': [30],
            'charge_constant_current_2': [1],
            'charge_cutoff_voltage': [3.6],
            'charge_constant_voltage_time': [30],
            'charge_rest_time': [5],
            'discharge_constant_current': [1],
            'discharge_cutoff_voltage': [3.0],
            'discharge_rest_time': [15],
            'cell_temperature_nominal': [25],
            'cell_type': ['Tesla_Model3_21700'],
            'capacity_nominal': [1.1],
            'diagnostic_type': ['HPPC+RPT'],
            'diagnostic_parameter_set': ['Tesla21700'],
            'diagnostic_start_cycle': [30],
            'diagnostic_interval': [100]
        }
        procedure_to_convert = 'test_procedure.000'
        with ScratchDir('.') as scratch_dir:
            protocol_params_df = pd.DataFrame.from_dict(protocol_params_dict)
            protocol_params = protocol_params_df.iloc[[0]].squeeze()

            diag_params_df = pd.read_csv(
                os.path.join(PROCEDURE_TEMPLATE_DIR,
                             "PreDiag_parameters - DP.csv"))
            diagnostic_params = diag_params_df[
                diag_params_df['diagnostic_parameter_set'] == 'A123LFP']

            procedure = Procedure.generate_procedure_regcyclev3(
                0, protocol_params)
            procedure.generate_procedure_diagcyclev3(
                protocol_params["capacity_nominal"], diagnostic_params)
            procedure.set_skip_to_end_diagnostic(3.8, 2.0, step_key='070')
            self.assertEqual(procedure['MaccorTestProcedure']['ProcSteps']['TestStep'][0]\
                                 ['Ends']['EndEntry'][1]['Value'], 3.8)
            self.assertEqual(procedure['MaccorTestProcedure']['ProcSteps']['TestStep'][0]\
                                 ['Ends']['EndEntry'][2]['Value'], 2.0)
            procedure.to_file(os.path.join(scratch_dir, procedure_to_convert))

            sdu_test_input = os.path.join(SCHEDULE_TEMPLATE_DIR,
                                          '20170630-3_6C_9per_5C.sdu')
            converted_sdu_name = 'schedule_test_20200724.sdu'
            proc_dict = procedure.from_file(
                os.path.join(scratch_dir, procedure_to_convert))

            sdu_test_output = os.path.join(TEST_FILE_DIR, converted_sdu_name)
            test_step_dict = proc_dict['MaccorTestProcedure']['ProcSteps'][
                'TestStep']

            converter = ProcedureToSchedule(test_step_dict)
            global_min_cur = -2 * 1.5 * protocol_params['capacity_nominal']
            global_max_cur = 2 * 1.5 * protocol_params['capacity_nominal']
            converter.create_sdu(
                sdu_test_input,
                sdu_test_output,
                current_range='Range2',
                global_v_range=[2.0, 3.8],
                global_temp_range=[0, 60],
                global_current_range=[global_min_cur, global_max_cur])
            parsed = open(sdu_test_output, encoding='latin-1').readlines()
            self.assertEqual(parsed[328], '[Schedule_Step3_Limit0]\n')
            self.assertEqual(parsed[6557], '[Schedule_UserDefineSafety15]\n')
            schedule = Schedule.from_file(os.path.join(sdu_test_output))
            self.assertEqual(schedule['Schedule']['Step15']['m_uLimitNum'],
                             '2')
            self.assertEqual(schedule['Schedule']['Step14']['m_uLimitNum'],
                             '6')
            self.assertEqual(schedule['Schedule']['m_uStepNum'], '96')
            self.assertEqual(schedule['Schedule']['Step86']['m_szCtrlValue'],
                             '15')
            self.assertEqual(
                schedule['Schedule']['Step86']['m_szExtCtrlValue1'], '1')
            self.assertEqual(
                schedule['Schedule']['Step86']['m_szExtCtrlValue2'], '0')