<CANoe_C#>常用代码片段

3 篇文章 3 订阅


XML测试模块

<testmodule title="NetworkTester_XML" version="1.0"> 
	<testgroup title="DTC920723 test 使用继电器Channel3"> 
		<nettestcase name="testcase1" title="TC-1 连接时间为1.0S,不应记录DTC" 
			class="NetLibrary" assembly="NetTestLib"> 
		</nettestcase>
		
		<nettestcase name="testcase2" title="TC-2 连接时间为1.8S,不应记录DTC" 
			class="NetLibrary" assembly="NetTestLib"> 
		</nettestcase>
		
		<nettestcase name="testcase3" title="TC-3 连接时间为2.5S,应记录DTC" 
			class="NetLibrary" assembly="NetTestLib"> 
		</nettestcase> 

		<nettestcase name="testcase4" title="TC-4 连接时间为3.0S,应记录DTC" 
			class="NetLibrary" assembly="NetTestLib"> 
		</nettestcase> 
	</testgroup> 
</testmodule>

检查DUT发出的报文周期

using System;
using Vector.Tools;
using Vector.CANoe.Runtime;
using Vector.CANoe.Sockets;
using Vector.CANoe.Threading;
using Vector.Diagnostics;
using Vector.Scripting.UI;
using Vector.CANoe.TFS;
using Vector.CANoe.VTS;
using NetworkDB;



public class TestModuleDome: TestModule
{
    public override void Main()
    {
        // The title is written to the report
        Title = "C# Test Module";
        // Diagnostics test using the Vector Diagnostics Library
        TestGroupBegin("CycleTime Test ", "");

        ChkCycleTime(0x134, 8, 20, 0.1);//周期检测
        ChkCycleTime(0x1D0, 8, 50, 0.1);
        ChkCycleTime(0x1D1, 8, 20, 0.1);
        ChkCycleTime(0x4F4, 8, 1000, 0.1);
        ChkCycleTime(0x3D0, 8, 50, 0.1);

        TestGroupEnd();	

        
    }

    /// <summary>
    /// Check CycleTime of Messages
    /// </summary>
    /// <param name="ID"></param>
    /// <param name="DLC"></param>
    /// <param name="minAbsoluteCycleTime"></param>
    /// <param name="maxAbsoluteCycleTime"></param>
    [TestCase("ChkCycleTime Test")]
    public static void ChkCycleTime(int ID, int DLC, float CycleTime, double diff)
    {
        int kTIMEOUT;
        int minAbsoluteCycleTime;
        int maxAbsoluteCycleTime;

        double minAbsoluteCycleTime_f = CycleTime * (1 - diff);
        double maxAbsoluteCycleTime_f = CycleTime * (1 + diff);
        byte DLC2;

        //强制转换
        DLC2 = (byte)DLC;
        minAbsoluteCycleTime = (int)minAbsoluteCycleTime_f;
        maxAbsoluteCycleTime = (int)maxAbsoluteCycleTime_f;

        kTIMEOUT = 10 * maxAbsoluteCycleTime;

        CANFrame frame = new CANFrame(ID, DLC2);
        ICheck check = new AbsoluteCycleTimeCheck<CANFrame>(frame, CheckType.Condition, minAbsoluteCycleTime, maxAbsoluteCycleTime);
        check.Activate();
        Execution.Wait(kTIMEOUT); // observation active
        check.Deactivate();
        check.Dispose();


    }

}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
"an-ind-1-011_using_canoe_net_api.pdf" 是一个关于使用 Canoe Net API 的文档。Canoe 是一种网络分析工具,Canoe Net API 是 Canoe 提供的用于与其它系统进行集成和交互的应用程序接口。 这个文档主要介绍了如何使用 Canoe Net API 进行网络分析和数据处理。它包含了使用 Canoe Net API 的基本概念和操作步骤,以及示例代码和实际应用场景。通过阅读这个文档,开发人员可以了解如何使用 Canoe Net API 对网络数据进行收集、分析、过滤和可视化,并可以根据自己的需求进行定制和扩展。 使用 Canoe Net API,开发人员可以实现以下功能: 1. 收集网络数据:通过 Canoe Net API,可以获取网络传输层(如 TCP、UDP)上的数据包,包括源地址、目标地址、数据负载等信息。 2. 网络分析:可以利用 Canoe Net API 提供的功能,对网络数据进行分析和统计,例如计算网络流量、检测网络异常等。 3. 数据过滤:通过 Canoe Net API 可以对网络数据进行过滤,只保留感兴趣的数据包,以便后续处理和分析。 4. 可视化展示:Canoe Net API 还提供了可视化工具,可以将网络数据以图表、图形等形式展示,便于用户直观地了解网络情况。 总之,"an-ind-1-011_using_canoe_net_api.pdf" 是一份介绍 Canoe Net API 的文档,通过学习和应用其的内容,开发人员可以使用 Canoe Net API 进行网络数据处理和分析,提升网络管理和安全性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值