Commit 90a942ac authored by mogos's avatar mogos
Browse files

PSAP tests compile

parent 39bf6a04
Loading
Loading
Loading
Loading
+169 −169

File changed.

Preview size limit exceeded, changes collapsed.

+236 −100
Original line number Diff line number Diff line
@@ -99,37 +99,6 @@ module LibItsECall_Functions {

        template MSDMessage mw_msdMessage := f_generateMSDTemplate();


        var MSDMessage msg := {
            msdStructure := {
                messageIdentifier := 1,
                control_ := {
                    automaticActivation := false,
                    testCall := true,
                    positionCanBeTrusted := false,
                    vehicleType := PX_VEHICLE_TYPE
                },
                vehicleIdentificationNumber := PX_VIN,
                vehiclePropulsionStorageType := PX_VEHICLE_PROPULSION_STORAGE_TYPE,
                timestamp := 1234,
                vehicleLocation := {
                    positionLatitude := 0,
                    positionLongitude := 0
                },
                vehicleDirection := 10,
                recentVehicleLocationN1 := {
                    latitudeDelta := 0,
                    longitudeDelta := 0
                },
                recentVehicleLocationN2 := {
                    latitudeDelta := 0,
                    longitudeDelta := 0
                },
                numberOfPassengers := 1
            },
            optionalAdditionalData := omit
        };
		
        //
        // Wait for InbandMsdReceivedEvent event
        //
@@ -344,26 +313,54 @@ module LibItsECall_Functions {
    }
    
    /**
     * @desc  Set the eCall message to be sent by simulated IVS
     * @param p_eCall   eCall message to be sent
     * @desc Construct an ECallMesasge based on the given MSDMessage 
     * @param p_version MSD version
     * @param p_msdMessage MSD content 
     */
    function f_setMSD(in ECallMessage p_eCall) runs on IvsMtc {
        var ModemConfiguration v_newConfig := {eCallMessage := p_eCall};
    function f_buildECallMessage(in integer p_version, in MSDMessage p_msdMessage) return ECallMessage {
        var ECallMessage v_eCallMessage;
        
        adapterControl.send(m_setConfig(PX_MODEM_INSTANCES[0].id, v_newConfig));
        var bitstring v_encodedMSDMessage := encvalue(p_msdMessage);
        
        if (lengthof(v_encodedMSDMessage) mod 8 != 0) {
            v_encodedMSDMessage := v_encodedMSDMessage & int2bit(0, 8 - (lengthof(v_encodedMSDMessage) mod 8));
        }
        
        v_eCallMessage := {
            msdVersion := p_version,
            msd := bit2oct(v_encodedMSDMessage)
        };
        
        return v_eCallMessage;
    }
    
    /**
     * @desc  Verify that eCall message is sent
     * @param p_alAckValue  Expected AL Ack value
     * @desc Construct a MSDMessage
     * @param p_messageIdentifier message identifier to use
     */
    function f_verifyMsdSentSuccesfully(template(present) AckValueType p_alAckValue := c_positiveAlAck) runs on IvsMtc {
//        f_expectFeedback(mw_inbandStartSignalReceived(PX_WORKERS[0].id, -, -, true));
//
//        f_verifyAckReceived(p_alAckValue);
//
//        vc_eCallMessage.decoded.msd.msdStructure.messageIdentifier := vc_eCallMessage.decoded.msd.msdStructure.messageIdentifier + 1;
//        f_setMSD(vc_eCallMessage);
    function f_buildMSDMessage(in integer p_messageIdentifier) return MSDMessage {
        var MSDMessage v_msd := {
            msdStructure := {
                messageIdentifier := p_messageIdentifier,
                control_ := {
                    automaticActivation := false,
                    testCall := true,
                    positionCanBeTrusted := not PX_IGNORE_MSD_POSITION,
                    vehicleType := PX_VEHICLE_TYPE
                },
                vehicleIdentificationNumber := PX_VIN,
                vehiclePropulsionStorageType := PX_VEHICLE_PROPULSION_STORAGE_TYPE,
                timestamp := 1234,
                vehicleLocation := PX_VEHICLE_LOCATION,
                vehicleDirection := PX_VEHICLE_DIRECTION,
                recentVehicleLocationN1 := PX_RECENT_VEHICLE_LOCATION_N1,
                recentVehicleLocationN2 := PX_RECENT_VEHICLE_LOCATION_N2,
                numberOfPassengers := PX_NUMBER_OF_PASSENGERS
            },
            optionalAdditionalData := omit
        };

        return v_msd;
    }
    
    /**
@@ -423,29 +420,6 @@ module LibItsECall_Functions {
        stop;
    }

    /**
     * @desc Sets the initial simulator configuration (IVS mode), all previous state is lost.
     * @param p_workerConf    Worker to use
     * @param p_configuration Configuration to use
     */
    function f_setSimulatorConfigurationIvs(in WorkerConf p_workerConf, in  template(value) ModemConfiguration p_configuration) runs on IvsMtc {
    //TODO implement
//        var ECallMessage v_eCallMessageExpanded := valueof(f_expandMsd(p_configuration.eCallMessage));
//        var ModemConfiguration v_psapConfig := {mode := PSAP};
//        
//        // Final configuration
//        p_configuration.internalSubscriber := p_workerConf.internalSubscriber;
//        p_configuration.eCallMessage := v_eCallMessageExpanded;
//
//        vc_eCallMessage := v_eCallMessageExpanded;
//
//        adapterControl.send(m_setConfig(PX_MODEM_INSTANCES[0].id, v_psapConfig));
////        f_adapterExpect(p_e := mw_ivsConfigChanged(p_workerConf.id, ?, ?), p_ignoreOtherMessages := true);
//
//        adapterControl.send(m_setConfig(PX_MODEM_INSTANCES[0].id, p_configuration));
////        f_adapterExpect(p_e := mw_ivsConfigChanged(p_workerConf.id, ?, p_configuration), p_ignoreOtherMessages := true);
    }

    /**
     * @desc   Wait for a specific event
     * @param  p_e                      Expected event to be received
@@ -941,35 +915,6 @@ module LibItsECall_Functions {
        }
    }
    
    /**
     * @desc    Request user to perfrom an action
     * @param   p_msg   Description of the action to be performed
     */
    function f_userActionPsap(in charstring p_msg) runs on IvsMtc {
        var integer v_button := f_messageBox("Action", p_msg, {"Done", "Cancel"}, 0);
        if (v_button != 0) { // message box was closed or cancel was clicked
            f_stopPsapTestcase(inconc, "Action """ & p_msg & """ canceled by user.");
        }
    }

    /**
     * @desc    Request user to verify something
     * @param   p_question      Verification to be performed by the user
     * @param   p_passMessage   Verdict message for success
     * @param   p_failMessage   Verdict message for failure
     * @param   p_passOption    Expected success answer
     * @verdict Pass if user's response matches p_passOption. Fail otherwise
     */
    function f_userVerifyPsap(in charstring p_question, in charstring p_passMessage, in charstring p_failMessage, in integer p_passOption := c_mbYes) runs on IvsMtc {
        var integer v_button := f_messageBoxYesNo("Verify", p_question);
        if (v_button == p_passOption) {
            setverdict(pass, p_passMessage);
        }
        else {
            f_stopPsapTestcase(fail, p_failMessage);
        }
    }

    /**
     * @desc Validate that all redial attempts from the IVS terminate after <code>IVS_REDIAL_WINDOW</code> has passed.
     *
@@ -1028,4 +973,195 @@ module LibItsECall_Functions {
            return duration + duration * c_timer_tolerance;
        }
    }
    
    group psap {
        /**
         * @desc  Set the eCall message to be sent by simulated IVS
         * @param p_messageIdentifier   messageIdentifier of the next msd
         */
        function f_setMSD(in integer p_messageIdentifier) runs on IvsMtc  {
            var MSDMessage v_msd := f_buildMSDMessage(p_messageIdentifier);
            var ECallMessage v_eCallMessage := f_buildECallMessage(c_msdVersion, v_msd);
            var ModemConfiguration v_newConfig := {eCallMessage := v_eCallMessage};

            adapterControl.send(m_setConfig(PX_MODEM_INSTANCES[0].id, v_newConfig));
        }

        /**
         * @desc  Verify that eCall message is sent
         * @param p_alAckValue  Expected AL Ack value
         */
        function f_verifyMsdSentSuccesfully(template(present) AckValueType p_alAckValue := c_positiveAlAck) runs on IvsMtc {
            f_expectFeedbackPsap(mw_inbandStartSignalReceived(PX_MODEM_INSTANCES[0].id, -, -, true));

            f_verifyAckReceived(p_alAckValue);

            vc_messageIdentifier := vc_messageIdentifier + 1;
            f_setMSD(vc_messageIdentifier);
        }

        /**
         * @desc   Wait for a specific adapter control event
         * @param  p_e                      Expected event to be received
         * @param  p_event_timeout          Timeout value for receiving the event
         * @param  p_ignoreOtherMessages    Whether other events shall be ignored or not
         * @return FeedbackResult           Received event if reception is successful, or failure
         */
        function f_adapterExpectPsap(template AdapterEvent p_e, float p_event_timeout := PX_TIMEOUT, in boolean p_ignoreOtherMessages := false) runs on IvsMtc return ExpectResult {
            timer t := p_event_timeout;
            var AdapterEvent v_received;
            var ExpectResult v_result;
            v_result.failure := false;

            if (getverdict == fail or getverdict == inconc) {
                return v_result;
            }

            t.start;
            alt {
                [] adapterControl.receive(p_e) -> value v_received {
                    v_result.adapterEvent := v_received;
                    t.stop;
                }

                [p_ignoreOtherMessages] callControl.receive {
                    repeat;
                }

                [] t.timeout {
                    v_result.failure := true;
                    log("Expecting", p_e);
                    f_stopPsapTestcase(inconc, "Timeout!");
                }
            }

            return v_result;
        }
        
        /**
         * @desc   Wait for a specific event
         * @param  p_e                      Expected event to be received
         * @param  p_event_timeout          Timeout value for receiving the event
         * @param  p_ignoreOtherMessages    Whether other events shall be ignored or not
         * @return FeedbackResult           Received event if reception is successful, or failure
         */
        function f_expectFeedbackPsap(template Event p_e, float p_event_timeout := PX_TIMEOUT, in boolean p_ignoreOtherMessages := false) runs on IvsMtc return ExpectResult {
            timer t := p_event_timeout;
            var Event v_received;
            var ExpectResult v_result;
            v_result.failure := false;

            if (getverdict == fail or getverdict == inconc) {
                return v_result;
            }

            t.start;
            alt {
                [] modem.receive(p_e) -> value v_received {
                    v_result.event := v_received;
                    t.stop;
                }

                [p_ignoreOtherMessages] modem.receive {
                    repeat;
                }

                [] t.timeout {
                    v_result.failure := true;
                    log("Expecting", p_e);
                    f_stopPsapTestcase(inconc, "Timeout!");
                }
            }

            return v_result;
        }
        
        /**
         * @desc   Wait for a specific mno event
         * @param  p_e                      Expected event to be received
         * @param  p_event_timeout          Timeout value for receiving the event
         * @param  p_ignoreOtherMessages    Whether other events shall be ignored or not
         * @return FeedbackResult           Received event if reception is successful, or failure
         */
        function f_callControlExpectPsap(template CallEvent p_e, float p_event_timeout := PX_TIMEOUT, in boolean p_ignoreOtherMessages := false) runs on IvsMtc return ExpectResult {
            timer t := p_event_timeout;
            var CallEvent v_received;
            var ExpectResult v_result;
            v_result.failure := false;

            if (getverdict == fail or getverdict == inconc) {
                return v_result;
            }

            t.start;
            alt {
                [] callControl.receive(p_e) -> value v_received {
                    v_result.callEvent := v_received;
                    t.stop;
                }

                [p_ignoreOtherMessages] callControl.receive {
                    repeat;
                }

                [] t.timeout {
                    v_result.failure := true;
                    log("Expecting", p_e);
                    f_stopPsapTestcase(inconc, "Timeout!");
                }
            }

            return v_result;
        }
        
        /**
         * @desc    Request user to perfrom an action
         * @param   p_msg   Description of the action to be performed
         */
        function f_userActionPsap(in charstring p_msg) runs on IvsMtc {
            var integer v_button := f_messageBox("Action", p_msg, {"Done", "Cancel"}, 0);
            if (v_button != 0) { // message box was closed or cancel was clicked
                f_stopPsapTestcase(inconc, "Action """ & p_msg & """ canceled by user.");
            }
        }

        /**
         * @desc    Request user to verify something
         * @param   p_question      Verification to be performed by the user
         * @param   p_passMessage   Verdict message for success
         * @param   p_failMessage   Verdict message for failure
         * @param   p_passOption    Expected success answer
         * @verdict Pass if user's response matches p_passOption. Fail otherwise
         */
        function f_userVerifyPsap(in charstring p_question, in charstring p_passMessage, in charstring p_failMessage, in integer p_passOption := c_mbYes) runs on IvsMtc {
            var integer v_button := f_messageBoxYesNo("Verify", p_question);
            if (v_button == p_passOption) {
                setverdict(pass, p_passMessage);
            }
            else {
                f_stopPsapTestcase(fail, p_failMessage);
            }
        }

        /**
         * @desc Sets the initial simulator configuration (IVS mode), all previous state is lost.
         * @param p_workerConf    Worker to use
         * @param p_configuration Configuration to use
         */
        function f_setSimulatorConfigurationIvs(in WorkerConf p_workerConf, in  template(value) ModemConfiguration p_configuration) runs on IvsMtc {
            var MSDMessage v_msd := f_buildMSDMessage(c_initialMessageIdentifier);
            var ECallMessage v_eCallMessage := f_buildECallMessage(c_msdVersion, v_msd);
            var ModemConfiguration v_psapConfig := {mode := PSAP};
            
            // Final configuration
            p_configuration.internalSubscriber := p_workerConf.internalSubscriber;
            p_configuration.eCallMessage := v_eCallMessage;

            adapterControl.send(m_setConfig(PX_MODEM_INSTANCES[0].id, v_psapConfig));
            f_adapterExpectPsap(p_e := mw_ivsConfigChanged(p_workerConf.id, ?, ?), p_ignoreOtherMessages := true);

            adapterControl.send(m_setConfig(PX_MODEM_INSTANCES[0].id, p_configuration));
            f_adapterExpectPsap(p_e := mw_ivsConfigChanged(p_workerConf.id, ?, p_configuration), p_ignoreOtherMessages := true);
        }
    }
}
+4 −2
Original line number Diff line number Diff line
@@ -534,7 +534,8 @@ module LibItsECall_Templates {
                    ignoreAlClearDown := p_parameters.ignoreAlClearDown,
                    noAckOfMsd := *,
                    simulateCrcError := p_parameters.simulateCrcError,
                    ignoreSendSignal := *
                    ignoreSendSignal := *,
                    disableInitiationSignal := p_parameters.disableInitiationSignal
                }
            }
        }
@@ -572,7 +573,8 @@ module LibItsECall_Templates {
                    ignoreAlClearDown := *,
                    noAckOfMsd := p_parameters.noAckOfMsd,
                    simulateCrcError := *,
                    ignoreSendSignal := p_parameters.ignoreSendSignal
                    ignoreSendSignal := p_parameters.ignoreSendSignal,
                    disableInitiationSignal := *
                }
            }
        }
+4 −1
Original line number Diff line number Diff line
@@ -97,7 +97,10 @@ module LibItsECall_TestSystem {
         * @member vc_eCallMessage
         */
        type component IvsMtc extends ECallMtc {
            var ECallMessage vc_eCallMessage;
            /**
             * @desc value of the next MSD messageIdentifier
             */
            var integer vc_messageIdentifier := c_initialMessageIdentifier;
        }

        /**
+6 −3
Original line number Diff line number Diff line
@@ -69,6 +69,7 @@ module LibItsECall_TypesAndValues {
         * @member  noAckOfMsd           P:   Do not acknoledge the MSD
         * @member  simulateCrcError     I:   Calculate and transmit a wrong CRC value
         * @member  ignoreSendSignal     P:   Setting this to true will cause the modem to not send START signal upon reception of SEND
         * @member  ignoreSendSignal     I:   Setting this to true will cause the modem to not send the initiation signal
         */
        type record ModemConfiguration {
            SimulatorModeType mode optional,
@@ -89,7 +90,8 @@ module LibItsECall_TypesAndValues {
            boolean ignoreAlClearDown optional,
            boolean noAckOfMsd optional,
            boolean simulateCrcError optional,
            boolean ignoreSendSignal optional
            boolean ignoreSendSignal optional,
            boolean disableInitiationSignal optional
        } with {
            variant (mode) "mode";
            variant (t3Timer) "t3_timer";
@@ -110,6 +112,7 @@ module LibItsECall_TypesAndValues {
            variant (simulateCrcError) "simulate_crc_error";
            variant (noAckOfMsd) "no_ack_of_msd";
            variant (ignoreSendSignal) "ignore_send_signal";
            variant (disableInitiationSignal) "disable_initiation_signal"
            encode (eCallMessage) "MSDEncode";
        }

@@ -720,11 +723,11 @@ module LibItsECall_TypesAndValues {
            t5Timer := c_t5_timer,
            t6Timer := c_t6_timer,
            t7Timer := c_t7_timer,
            //eCallMessage := f_expandMsdValue(PX_ECALL_MESSAGE),
            inbandDirection := PULL,
            internalSubscriber := "",
            ignoreAlClearDown := false,
            simulateCrcError := false
            simulateCrcError := false,
            disableInitiationSignal := false
        }
        with {
            optional "implicit omit";