OSATE 插件 Cheddar 的安装与简单使用

一、Cheddar简介

Cheddar是一个开源的实时系统任务调度模拟器/分析仪,可以使用Cheddar进行任务的可调度性分析以及相关的性能分析。对于Cheddar的详细信息可以参考其官网:

Cheddar - open-source real-time scheduling simulator/analyzer (univ-brest.fr)

二、Cheddar的安装与使用

1. 下载

从官网链接下载Cheddar程序。

Download and Install - Cheddar 3.3 User Guide (univ-brest.fr)

(我将资源在这里发布,也可以选择从此处下载:[免费] Cheddar-任务调度分析工具)。

下载完成后,解压压缩包到某文件夹 (我将其解压到E盘的OSATE文件夹下并重命名为Cheddar_bin)

注:Cheddar插件默认的位置为桌面下的Cheddar_bin文件夹,如果想在后续的AADL代码中免去Cheddar路径的配置,可以将其解压到当前用户的Desktop文件夹下并重命名为Cheddar_bin。

2.  安装Cheddar插件

打开 OSATE “帮助”菜单,选择“安装其他 OSATE 组件”。

选择Cheddar Plugin,并安装。

 3.  配置Cheddar安装路径

这一步是对Cheddar的安装路径进行配置(没有将压缩包解压到桌面上并重命名的用户需要进行此步操作)。

首先需要引用Cheddar_Parameters_Properties

with Cheddar_Parameters_Properties;

然后需要在最顶层的组件(一般为system组件)的属性中,声明Cheddar的安装位置

properties
    Cheddar_Parameters_Properties::Cheddar_Install_Folder => "E://OSATE//Cheddar_bin//";
    Cheddar_Parameters_Properties::Cheddar_Working_Folder => "E://OSATE//Cheddar_bin//";

配置完成后:

注意,需要对Cheddar_Install_Folder和Cheddar_Working_Folder进行配置,并且这两个文件路径需要一致。

补充:在Cheddar插件的源码(......\OSATE\plugins\cheddar-osate2_1.0.0.202011071011.jar)中可以看到(如下图所示),Cheddar的默认引用路径是“C:\Users\用户名/Desktop/Cheddar_Bin/”,所以在上一步需要声明Chedder的安装路径。

4. 实例化模型并使用Cheddar进行分析

实例化模型(选中要实例化的组件并实例化),这会生成.aaxl2文件。

选中刚刚生成的.aaxl2文件,Cheddar会提供三个按钮,从左到右分别是:

左:生成切达 XML 模型

中:生成 XML 切达模型并启动切达

右:生成切达 ADL 模型并启动切达工具以计算线程响应时间

比如点击中间的按钮,可以看到Cheddar被成功启动。

即可在Tools菜单中进行相关分析。

 三、参考资料

本文主要参考以下资料:

Cheddar - open-source real-time scheduling simulator/analyzer

Download and Compile - Cheddar 3.3 User Guide

Cheddar Release 3.x user's guide

如有不当或错误之处,恳请您的指正,谢谢!!!

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 9
    评论
使用LINQ查询和操作集合 改进代码 namespace SandwichCalories { class Program { static void Main(string[] args) { // sandwich ingredients and their associated calories Dictionary<string, int> ingredients = new Dictionary<string, int>() { { "Bread", 66 }, { "Ham", 72 }, { "Bologna", 57 }, { "Chicken", 17 }, { "Corned Beef", 53 }, { "Salami", 40 }, { "Cheese, American", 104 }, { "Cheese, Cheddar", 113 }, { "Cheese, Havarti", 105 }, { "Mayonnaise", 94 }, { "Mustard", 10 }, { "Butter", 102 }, { "Garlic Aioli", 100 }, { "Sriracha", 15 }, { "Dressing, Ranch", 73 }, { "Dressing, 1000 Island", 59 }, { "Lettuce", 5 }, { "Tomato", 4 }, { "Cucumber", 4 }, { "Banana Pepper", 10 }, { "Green Pepper", 3 }, { "Red Onion", 6 }, { "Spinach", 7 }, { "Avocado", 64 } }; // prompt user for calorie range Console.Write("Enter minimum calories: "); int min_calories = int.Parse(Console.ReadLine()); Console.Write("Enter maximum calories: "); int max_calories = int.Parse(Console.ReadLine()); // calculate the minimum and maximum calories for the sandwich int min_sandwich_calories = 2 * ingredients["Bread"] + ingredients.Values.Min() * 2; int max_sandwich_calories = 2 * ingredients["Bread"] + ingredients.Values.Max() * 2; // check if the calorie range is valid if (max_calories < min_sandwich_calories) { Console.WriteLine("Sorry, it is impossible to create a sandwich within the given calorie range."); } else { // create the sandwich List<string> sandwich = new List<string> { "Bread" }; int sandwich_calories = 1 * ingredients["Bread"]; while (sandwich_calories < min_calories) { // add random ingredient string ingredient = ingredients.Keys.ElementAt(new Random().Next(ingredients.Count)); sandwich.Add(ingredient); sandwich_calories += ingredients[ingredient]; } while (sandwich_calories <= max_calories) { // add random ingredient string ingredient = ingredients.Keys.ElementAt(new Random().Next(ingredients.Count)); // check if the ingredient is the same as the previous one if (sandwich.Count >= 3 && ingredient == sandwich[sandwich.Count - 2]) { continue; } sandwich.Add(ingredient); sandwich_calories += ingredients[ingredient]; // check if the sandwich is already at the maximum calorie limit if (sandwich_calories == max_sandwich_calories) { break; } } // add the last slice of bread sandwich.Add("Bread"); // print the sandwich and its total calories Console.WriteLine("Your sandwich: " + string.Join(", ", sandwich)); Console.WriteLine("Total calories: " + sandwich_calories); } } } }
06-10
以下是不使用LINQ查询和操作集合改进的代码,这里使用了foreach循环和if条件语句来实现相同的功能: ```csharp using System; using System.Collections.Generic; namespace SandwichCalories { class Program { static void Main(string[] args) { // sandwich ingredients and their associated calories Dictionary<string, int> ingredients = new Dictionary<string, int>() { { "Bread", 66 }, { "Ham", 72 }, { "Bologna", 57 }, { "Chicken", 17 }, { "Corned Beef", 53 }, { "Salami", 40 }, { "Cheese, American", 104 }, { "Cheese, Cheddar", 113 }, { "Cheese, Havarti", 105 }, { "Mayonnaise", 94 }, { "Mustard", 10 }, { "Butter", 102 }, { "Garlic Aioli", 100 }, { "Sriracha", 15 }, { "Dressing, Ranch", 73 }, { "Dressing, 1000 Island", 59 }, { "Lettuce", 5 }, { "Tomato", 4 }, { "Cucumber", 4 }, { "Banana Pepper", 10 }, { "Green Pepper", 3 }, { "Red Onion", 6 }, { "Spinach", 7 }, { "Avocado", 64 } }; // prompt user for calorie range Console.Write("Enter minimum calories: "); int min_calories = int.Parse(Console.ReadLine()); Console.Write("Enter maximum calories: "); int max_calories = int.Parse(Console.ReadLine()); // calculate the minimum and maximum calories for the sandwich int min_sandwich_calories = 2 * ingredients["Bread"] + GetMinValue(ingredients.Values) * 2; int max_sandwich_calories = 2 * ingredients["Bread"] + GetMaxValue(ingredients.Values) * 2; // check if the calorie range is valid if (max_calories < min_sandwich_calories) { Console.WriteLine("Sorry, it is impossible to create a sandwich within the given calorie range."); } else { // create the sandwich List<string> sandwich = new List<string> { "Bread" }; int sandwich_calories = 1 * ingredients["Bread"]; while (sandwich_calories < min_calories) { // add random ingredient string ingredient = GetRandomIngredient(ingredients); sandwich.Add(ingredient); sandwich_calories += ingredients[ingredient]; } while (sandwich_calories <= max_calories) { // add random ingredient string ingredient = GetRandomIngredient(ingredients); // check if the ingredient is the same as the previous one if (sandwich.Count >= 3 && ingredient == sandwich[sandwich.Count - 2]) { continue; } sandwich.Add(ingredient); sandwich_calories += ingredients[ingredient]; // check if the sandwich is already at the maximum calorie limit if (sandwich_calories == max_sandwich_calories) { break; } } // add the last slice of bread sandwich.Add("Bread"); // print the sandwich and its total calories Console.WriteLine("Your sandwich: " + string.Join(", ", sandwich)); Console.WriteLine("Total calories: " + sandwich_calories); } } // helper methods static int GetMinValue(IEnumerable<int> values) { int minValue = int.MaxValue; foreach (int value in values) { if (value < minValue) { minValue = value; } } return minValue; } static int GetMaxValue(IEnumerable<int> values) { int maxValue = int.MinValue; foreach (int value in values) { if (value > maxValue) { maxValue = value; } } return maxValue; } static string GetRandomIngredient(Dictionary<string, int> ingredients) { int index = new Random().Next(ingredients.Count); int i = 0; foreach (string key in ingredients.Keys) { if (i == index) { return key; } i++; } return null; } } } ``` 在这个改进的代码,我们使用了GetMinValue和GetMaxValue方法来获取字典值的最小值和最大值,使用GetRandomIngredient方法来获取随机的食材名称。虽然这种方式代码量增加了,但是这种方式可以更好地理解代码的每个步骤,也可以更好地掌控代码的细节。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值