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