プログラム・サンプル |
#include <karacrix.h> main( argc, argv ) int argc; char *argv[]; { int objid_ai001, objid_do001; int alm_ai001, stat_do001; kcxinit( argc, argv ); objid_ai001 = kcxobj_open( "ai001" ); objid_do001 = kcxobj_open( "do001" ); for(;;){ kcxobj_alm_stat_ird( objid_ai001, &alm_ai001 ); /*S1制御下の警報状態取得*/ kcxobj_stat_ird( objid_do001, &stat_do001 ); /*do001の状態取得*/ if( alm_ai001 == 1 ){ /*ai001警報発生の場合*/ if( stat_do001 == 0 ){ /*do001がOFFの場合*/ kcxobj_sndistat_tokcx( objid_do001, 1 ); /*do001のONをS1に送り操作してもらう*/ } }else{ /*ai001警報解除の場合*/ if( stat_do001 == 1 ){ /*do001がONの場合*/ kcxobj_sndistat_tokcx( objid_do001, 0 ); /*do001のOFFをS1に送り操作してもらう*/ } } sleep( 1 ); /*必須:CPUを負荷らせない待ち時間*/ } }
#include <karacrix.h> main( argc, argv ) int argc; char *argv[]; { int objid_ai001, objid_do001; int stat_do001; double fdata; double Hval, Lval; kcxinit( argc, argv ); objid_ai001 = kcxobj_open( "ai001" ); objid_do001 = kcxobj_open( "do001" ); Hval = 80.0; /*上限リミット値設定*/ Lval = 20.0; /*下限リミット値設定*/ for(;;){ kcxobj_stat_frd( objid_ai001, &fdata ); /*ai001の計測値取得*/ kcxobj_stat_ird( objid_do001, &stat_do001 ); /*do001の状態取得*/ if( fdata > Hval ){ /*ai001がH(80.0)以上の場合*/ if( stat_do001 == 0 ){ /*do001がOFFの場合*/ kcxobj_sndistat_tokcx( objid_do001, 1 ); /*do001のONをS1に送り操作してもらう*/ } }else if( fdata < Lval ){ /*ai001がL(20.0)以下の場合*/ if( stat_do001 == 0 ){ /*do001がOFFの場合*/ kcxobj_sndistat_tokcx( objid_do001, 1 ); /*do001のONをS1に送り操作してもらう*/ } }else{ /*ai001がH(80.0)以下L(20.0)以上の場合*/ if( stat_do001 == 1 ){ /*do001がONの場合*/ kcxobj_sndistat_tokcx( objid_do001, 0 ); /*do001のOFFをS1に送り操作してもらう*/ } } sleep( 1 ); /*必須:CPUを負荷らせない待ち時間*/ } }
#include <karacrix.h> main( argc, argv ) int argc; char *argv[]; { int objid_di001, objid_do001; int stat_di001, stat_do001; kcxinit( argc, argv ); objid_di001 = kcxobj_open( "di001" ); objid_do001 = kcxobj_open( "do001" ); for(;;){ kcxobj_stat_ird( objid_di001, &stat_di001 ); /*di001の状態取得*/ kcxobj_stat_ird( objid_do001, &stat_do001 ); /*do001の状態取得*/ if( stat_di001 == 0 ){ /*di001がOFFの場合*/ if( stat_do001 == 1 ){ /*do001がONの場合*/ kcxobj_sndistat_tokcx( objid_do001, 0 ); /*do001のOFFをS1に送り操作してもらう*/ } }else{ /*di001がONの場合*/ if( stat_do001 == 0 ){ /*do001がOFFの場合*/ kcxobj_sndistat_tokcx( objid_do001, 1 ); /*do001のONをS1に送り操作してもらう*/ } } sleep( 1 ); /*必須:CPUを負荷らせない待ち時間*/ } }
#include <karacrix.h> main( argc, argv ) int argc; char *argv[]; { int objid_di001, objid_do001; int switch_flag, control_flag; int idata1,idata2; kcxinit( argc, argv ); objid_di001 = kcxobj_open( "di001" ); objid_do001 = kcxobj_open( "do001" ); switch_flag = 0; for(;;){ kcxobj_alm_stat_ird( objid_di001, &idata1 ); /*警報状態値の読込*/ kcxobj_lock_ird( objid_do001, &idata2 ); /*ロック状態値の読込*/ if(( idata1 >= 1 )||( idata2 >= 1 )){ control_flag = 1; /*di001が警報あるいはdo001がロック時*/ }else{ control_flag = 0; } if( switch_flag == 0 ){ if( control_flag == 1 ){ /*do001操作許可時*/ kcxobj_sndistat_tokcx( objid_do001, 0 ); /*do001のOFFをS1に送り操作してもらう*/ } switch_flag = 1; }else{ if( control_flag == 1 ){ /*do001操作許可時*/ kcxobj_sndistat_tokcx( objid_do001, 1 ); /*do001のONをS1に送り操作してもらう*/ } switch_flag = 0; } sleep( 3 ); /*待ち時間、かつCPUを負荷らせない為の待ち時間*/ } }
#include <karacrix.h> main( argc, argv ) int argc; char *argv[]; { int objid_di001; int objid_di002; int stat_di001; int save_di001; int Ev_KEY, Ev_STAT; KcxIntFlt_t udata10[10]; kcxinit( argc, argv ); objid_di001 = kcxobj_open( "di001" ); objid_di002 = kcxobj_open( "di002" ); kcxobj_stat_ird( objid_di001, &save_di001 ); /*di001の初期状態取得*/ for(;;){ kcxobj_stat_ird( objid_di001, &stat_di001 ); /*di001の状態取得*/ if( stat_di001 == 0 ){ /*di001が現在OFFの場合*/ if( save_di001 == 1 ){ /*di001が前回ONの場合*/ save_di001 = 0; /*di001の状態記憶*/ memset( (void *)udata10,0,sizeof(udata10) ); /*履歴メモリ作業前クリア*/ /* OFF操作履歴生成 */ Ev_KEY = 10; /*例えば"状態"表示用識別子*/ Ev_STAT = 0; /*例えば"OFF"表示用識別子 */ kcxobj_ope_log_10uwt( objid_di001,Ev_KEY,Ev_STAT,udata10 ); /* 警報解除履歴生成 */ Ev_KEY = 53; /*例えば"警報"表示用識別子*/ Ev_STAT = 0; /*例えば"解除"表示用識別子*/ kcxobj_alm_log_10uwt( objid_di002,Ev_KEY,Ev_STAT,udata10 ); } }else{ /*di001が現在ONの場合*/ if( save_di001 == 0 ){ /*di001が前回OFFの場合*/ save_di001 = 1; /*di001の状態記憶*/ memset( (void *)udata10,0,sizeof(udata10) ); /*履歴メモリ作業前クリア*/ /* ON操作履歴生成 */ Ev_KEY = 10; /*例えば"状態"表示用識別子*/ Ev_STAT = 1; /*例えば"ON"表示用識別子 */ kcxobj_ope_log_10uwt( objid_di001,Ev_KEY,Ev_STAT,udata10 ); /* 警報発生履歴生成 */ Ev_KEY = 53; /*例えば"警報"表示用識別子*/ Ev_STAT = 1; /*例えば"発生"表示用識別子*/ kcxobj_alm_log_10uwt( objid_di002,Ev_KEY,Ev_STAT,udata10 ); } } sleep( 1 ); /*必須:CPUを負荷らせない待ち時間*/ } }
#include <karacrix.h> main( argc, argv ) int argc; char *argv[]; { int objid_di001,objid_ai002,cnt; char text[BUFSIZ]; kcxinit( argc, argv ); objid_di001 = kcxobj_open( "di001" ); objid_ai002 = kcxobj_open( "ai002" ); cnt = 0; for(;;){ sprintf( text,"監視画面にメッセージ表示 CNT=%d",cnt++ ); /*文字データの生成*/ kcxobj_atbut_cwt( objid_di001, 1, text ); /*di001の文字属性1にtext書込*/ kcxobj_atbut_cwt( objid_ai002, 4, text ); /*ai002の文字属性4にtext書込*/ kcxobj_atbut_iwt( objid_di001, 8, cnt ); /*di001の整数属性8にcnt値書込*/ kcxobj_atbut_fwt( objid_ai002, 3, (double)cnt ); /*ai002の実数属性3に実数化したcnt値書込*/ sleep( 10 ); /*10秒毎にカウントアップ、かつCPUを負荷らせない為の待ち時間*/ } }