[352] | 1 | /*
|
---|
| 2 | * サンプルプログラム(2)のコンポーネント記述ファイル
|
---|
| 3 | *
|
---|
| 4 | * $Id$
|
---|
| 5 | */
|
---|
| 6 | /*
|
---|
| 7 | * カーネルオブジェクトの定義
|
---|
| 8 | */
|
---|
| 9 | import("kernel.cdl");
|
---|
| 10 |
|
---|
| 11 | /*
|
---|
| 12 | * ターゲット非依存のセルタイプの定義
|
---|
| 13 | */
|
---|
| 14 | import("syssvc/tSerialPort.cdl");
|
---|
| 15 | import("syssvc/tSysLog.cdl");
|
---|
| 16 | import("syssvc/tLogTask.cdl");
|
---|
| 17 | import("syssvc/tBanner.cdl");
|
---|
| 18 |
|
---|
| 19 | /*
|
---|
| 20 | * ターゲット依存部の取り込み
|
---|
| 21 | */
|
---|
| 22 | import("target.cdl");
|
---|
| 23 |
|
---|
| 24 | /*
|
---|
| 25 | * 「セルの組上げ記述」とは,"cell"で始まる行から,それに対応する"};"
|
---|
| 26 | * の行までのことを言う.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
| 29 | /*
|
---|
| 30 | * システムログ機能の組上げ記述
|
---|
| 31 | *
|
---|
| 32 | * システムログ機能を外す場合には,以下のセルの組上げ記述を削除し,コ
|
---|
| 33 | * ンパイルオプションに-DTOPPERS_OMIT_SYSLOGを追加すればよい.ただし,
|
---|
| 34 | * システムログタスクはシステムログ機能を使用するため,それも外すこと
|
---|
| 35 | * が必要である.また,システムログ機能のアダプタも外さなければならな
|
---|
| 36 | * い.tecsgenが警告メッセージを出すが,無視してよい.
|
---|
| 37 | */
|
---|
| 38 | cell tSysLog SysLog {
|
---|
| 39 | logBufferSize = 32; /* ログバッファのサイズ */
|
---|
| 40 | initLogMask = C_EXP("LOG_UPTO(LOG_NOTICE)");
|
---|
| 41 | /* ログバッファに記録すべき重要度 */
|
---|
| 42 | initLowMask = C_EXP("LOG_UPTO(LOG_EMERG)");
|
---|
| 43 | /* 低レベル出力すべき重要度 */
|
---|
| 44 |
|
---|
| 45 | /* 低レベル出力との結合 */
|
---|
| 46 | cPutLog = PutLogTarget.ePutLog;
|
---|
| 47 | };
|
---|
| 48 |
|
---|
| 49 | /*
|
---|
| 50 | * シリアルインタフェースドライバの組上げ記述
|
---|
| 51 | *
|
---|
| 52 | * シリアルインタフェースドライバを外す場合には,以下のセルの組上げ記
|
---|
| 53 | * 述を削除すればよい.ただし,システムログタスクはシリアルインタフェー
|
---|
| 54 | * スドライバを使用するため,それも外すことが必要である.また,シリア
|
---|
| 55 | * ルインタフェースドライバのアダプタも外さなければならない.
|
---|
| 56 | */
|
---|
| 57 | cell tSerialPort SerialPort1 {
|
---|
| 58 | receiveBufferSize = 256; /* 受信バッファのサイズ */
|
---|
| 59 | sendBufferSize = 256; /* 送信バッファのサイズ */
|
---|
| 60 |
|
---|
| 61 | /* ターゲット依存部との結合 */
|
---|
| 62 | cSIOPort = SIOPortTarget1.eSIOPort;
|
---|
| 63 | eiSIOCBR <= SIOPortTarget1.ciSIOCBR; /* コールバック */
|
---|
| 64 | };
|
---|
| 65 |
|
---|
| 66 | /*
|
---|
| 67 | * システムログタスクの組上げ記述
|
---|
| 68 | *
|
---|
| 69 | * システムログタスクを外す場合には,以下のセルの組上げ記述を削除すれ
|
---|
| 70 | * ばよい.
|
---|
| 71 | */
|
---|
| 72 | cell tLogTask LogTask {
|
---|
| 73 | priority = 3; /* システムログタスクの優先度 */
|
---|
| 74 | stackSize = LogTaskStackSize; /* システムログタスクのスタックサイズ */
|
---|
| 75 |
|
---|
| 76 | /* シリアルインタフェースドライバとの結合 */
|
---|
| 77 | cSerialPort = SerialPort1.eSerialPort;
|
---|
| 78 | cnSerialPortManage = SerialPort1.enSerialPortManage;
|
---|
| 79 |
|
---|
| 80 | /* システムログ機能との結合 */
|
---|
| 81 | cSysLog = SysLog.eSysLog;
|
---|
| 82 |
|
---|
| 83 | /* 低レベル出力との結合 */
|
---|
| 84 | cPutLog = PutLogTarget.ePutLog;
|
---|
| 85 | };
|
---|
| 86 |
|
---|
| 87 | /*
|
---|
| 88 | * カーネル起動メッセージ出力の組上げ記述
|
---|
| 89 | *
|
---|
| 90 | * カーネル起動メッセージの出力を外す場合には,以下のセルの組上げ記述
|
---|
| 91 | * を削除すればよい.
|
---|
| 92 | */
|
---|
| 93 | cell tBanner Banner {
|
---|
| 94 | /* 属性の設定 */
|
---|
| 95 | targetName = BannerTargetName;
|
---|
| 96 | copyrightNotice = BannerCopyrightNotice;
|
---|
| 97 | };
|
---|
| 98 |
|
---|
| 99 | /*
|
---|
| 100 | * サンプルプログラムの定義
|
---|
| 101 | */
|
---|
| 102 | [singleton]
|
---|
| 103 | celltype tSample2 {
|
---|
| 104 | require tKernel.eKernel; /* 呼び口名なし(例:delay)*/
|
---|
| 105 | /*require cKernel = tKernel.eKernel;/* 呼び口名あり(例:cKernel_delay)*/
|
---|
| 106 | require ciKernel = tKernel.eiKernel;/* 呼び口名あり(例:ciKernel_)*/
|
---|
| 107 |
|
---|
| 108 | call sTask cTask[4]; /* タスク操作 */
|
---|
| 109 | call sTask cExceptionTask;
|
---|
| 110 | call sCyclic cCyclic;
|
---|
| 111 | call sAlarm cAlarm;
|
---|
| 112 |
|
---|
| 113 | [optional] call sSerialPort cSerialPort;/* シリアルドライバとの接続 */
|
---|
| 114 | call sSysLog cSysLog; /* システムログ機能との接続 */
|
---|
| 115 |
|
---|
| 116 | entry sTaskBody eMainTask; /* Mainタスク */
|
---|
| 117 | entry sTaskBody eSampleTask[3]; /* 並行実行されるタスク */
|
---|
| 118 | entry sTaskBody eExceptionTask; /* 例外処理タスク */
|
---|
| 119 |
|
---|
| 120 | entry siHandlerBody eiCyclicHandler;/* 周期ハンドラ*/
|
---|
| 121 | entry siHandlerBody eiAlarmHandler; /* アラームハンドラ */
|
---|
| 122 | };
|
---|
| 123 |
|
---|
| 124 | /*
|
---|
| 125 | * 組み上げ記述
|
---|
| 126 | */
|
---|
| 127 |
|
---|
| 128 | /* Sample2のプロトタイプ宣言 */
|
---|
| 129 | cell tSample2 Sample2;
|
---|
| 130 |
|
---|
| 131 | cell tKernel ASPKernel{
|
---|
| 132 | };
|
---|
| 133 |
|
---|
| 134 | cell tTask MainTask {
|
---|
| 135 | /* 呼び口の結合 */
|
---|
| 136 | cTaskBody = Sample2.eMainTask;
|
---|
| 137 | /* 属性の設定 */
|
---|
| 138 | attribute = C_EXP("TA_ACT");
|
---|
| 139 | priority = C_EXP("MAIN_PRIORITY");
|
---|
| 140 | stackSize = C_EXP("STACK_SIZE");
|
---|
| 141 | };
|
---|
| 142 |
|
---|
| 143 | cell tTask Task1 {
|
---|
| 144 | /* 呼び口の結合 */
|
---|
| 145 | cTaskBody = Sample2.eSampleTask[0];
|
---|
| 146 | /* 属性の設定 */
|
---|
| 147 | priority = C_EXP("MID_PRIORITY");
|
---|
| 148 | stackSize = C_EXP("STACK_SIZE");
|
---|
| 149 | };
|
---|
| 150 |
|
---|
| 151 | cell tTask Task2 {
|
---|
| 152 | /* 呼び口の結合 */
|
---|
| 153 | cTaskBody = Sample2.eSampleTask[1];
|
---|
| 154 | /* 属性の設定 */
|
---|
| 155 | priority = C_EXP("MID_PRIORITY");
|
---|
| 156 | stackSize = C_EXP("STACK_SIZE");
|
---|
| 157 | };
|
---|
| 158 |
|
---|
| 159 | cell tTask Task3 {
|
---|
| 160 | /* 呼び口の結合 */
|
---|
| 161 | cTaskBody = Sample2.eSampleTask[2];
|
---|
| 162 | /* 属性の設定 */
|
---|
| 163 | priority = C_EXP("MID_PRIORITY");
|
---|
| 164 | stackSize = C_EXP("STACK_SIZE");
|
---|
| 165 | };
|
---|
| 166 |
|
---|
| 167 | cell tTask ExceptionTask {
|
---|
| 168 | /* 呼び口の結合 */
|
---|
| 169 | cTaskBody = Sample2.eExceptionTask;
|
---|
| 170 | /* 属性の設定 */
|
---|
| 171 | priority = C_EXP("EXC_PRIORITY");
|
---|
| 172 | stackSize = C_EXP("STACK_SIZE");
|
---|
| 173 | };
|
---|
| 174 |
|
---|
| 175 | cell tCyclicHandler CyclicHandler {
|
---|
| 176 | /* 呼び口の結合 */
|
---|
| 177 | ciHandlerBody = Sample2.eiCyclicHandler;
|
---|
| 178 | /* 属性の設定 */
|
---|
| 179 | cycleTime = 2000000;
|
---|
| 180 | };
|
---|
| 181 |
|
---|
| 182 | cell tAlarmHandler AlarmHandler {
|
---|
| 183 | ciHandlerBody = Sample2.eiAlarmHandler;
|
---|
| 184 | };
|
---|
| 185 |
|
---|
| 186 | cell tSample2 Sample2 {
|
---|
| 187 | /* 呼び口の結合 */
|
---|
| 188 | cTask[ 0 ] = MainTask.eTask;
|
---|
| 189 | cTask[ 1 ] = Task1.eTask;
|
---|
| 190 | cTask[ 2 ] = Task2.eTask;
|
---|
| 191 | cTask[ 3 ] = Task3.eTask;
|
---|
| 192 |
|
---|
| 193 | cExceptionTask = ExceptionTask.eTask;
|
---|
| 194 |
|
---|
| 195 | cCyclic = CyclicHandler.eCyclic;
|
---|
| 196 | cAlarm = AlarmHandler.eAlarm;
|
---|
| 197 |
|
---|
| 198 | cSerialPort = SerialPort1.eSerialPort;
|
---|
| 199 | cSysLog = SysLog.eSysLog;
|
---|
| 200 | };
|
---|