/* v1.25 2015/7/17 : RaspberryPiのPiカウント機能追加(di001~4:OnCount=>pi001~4:SD-1Hsave)*/ /* v1.24 2015/2/14 : RaspberryPiのGPIOのパーミッションをsudoでa+rx変更*/ /* v1.23 2014/11/1 : KBRS31A(RaspberryPiBoard)対応*/ /* v1.22 2014/4/15 : 64Bit対応時のバグがARM/CPUで発生。CentOS,Ubuntuでは問題無し*/ /* v1.21 2012/10/10: メルアド間接直接格納、kcxobj_lock_ird()関数変更 */ /* v1.20 2012/07/01: GK0580A対応 */ /* v1.10 2011/03/09: リモートI/O複数使用時のDo送信バグ修正 */ /* v1.00 2010/05/01: AK0620A対応 */ /* v0.88 2009/10/12: メールバッファ定義増量変更:KaracrixBuilder-v3.00以上 */ /* v0.87 2008/08/15: 64BitOS対応(単精度実数->倍精度実数) */ /* v0.86 2008/01/20: コンソールメッセージ表示追加 */ /* v0.85 2007/12/02: 通信ステータス表示バグ修正、メール送信ログ記録追加 */ /* v0.84 2007/11/04: OBJIDをdi01からdi001等に桁を3に増やした */ /* v0.83 2007/10/21: メール装置名とメール送信時間追加 */ /* v0.82 2007/08/07: I/O通信リセット検出表示追加 */ /* v0.81 2007/07/13: リリース */ /* 制御対象ドライバ機器(BK1682A,AK0822A,AK0620A,GK0580A,TK0040A,IOB30RTA,KBRS31A) */ #include #define DEBUGMSGSEC1st (2) /*接続試験モード時の初回のメッセージ表示時間(秒)*/ #define DEBUGMSGSEC2nd (1) /*パラメータ書込更新の時のメッセージ表示時間(秒)*/ #define ModelNULLtp (0) #define ModelBK1682Atp (1) #define ModelAK0822Atp (2) #define ModelAK0620Atp (3) #define ModelGK0580Atp (4) #define ModelTK0040Atp (5) #define ModelIOB30RTAtp (6) #define ModelRASPBERRYtp (7) #define NETBOXs (20) /*接続装置最大数*/ #define BK1622A_DIs (16) #define BK1622A_PIs (16) #define BK1622A_DOs (8) #define BK1622A_DO2s (2) #define AK0822A_AIs (8) #define AK0822A_AOs (2) #define AK0822A_DO2s (2) #define AK0620A_DIs (2) #define AK0620A_PIs (2) #define AK0620A_DOs (2) #define AK0620A_AIs (12) #define AK0620A_AOs (2) #define GK0580A_DIs (14) #define GK0580A_PIs (14) #define GK0580A_DOs (8) #define GK0580A_AIs (8) #define GK0580A_AOs (2) #define TK0040A_DIs (6) #define TK0040A_PIs (6) #define TK0040A_DOs (4) #define TK0040A_AIs (4) #define TK0040A_AOPWMs (3) #define IOB30RTA_DIs (4) #define IOB30RTA_DOs (4) #define IOB30RTA_AIs (8) #define RASPBERRYx_DIs (4) #define RASPBERRYx_PIs (4) #define RASPBERRYx_DOs (6) #define RASPBERRYx_AIs (4) #define LOGTMSETITVSECs (20) #define LAN_COMMANDRETRYs (3) #define LAN_RCVTOUTSECs (10) /* 経路に無線LAN有る場合:30〜60秒が安全 */ #define LAN_RCVTOUTUSECs (0) #define LAN_RCVTOUTSEC_ERR (1) #define LAN_RCVTOUTUSEC_ERR (0) #define LAN_ERRORRETRYSECs (20) #define LAN_MYPORT (3000) #define PARA_EMAILTOADDRs (5) #define PARA_RMTOBJIDs (64) #define PARA_KEYWORDs (512) #define PARA_PARAWORDs (512) #define EMAILADDRGETTYPE (0) /* 0:間接タイプ,1:直接タイプ */ #define EMAILTEXTs (400) /* メール行数(最大仕様) */ #define EMAILTEXTBUFLENs (256) /* メール文字数[1バイト換算](最大仕様) */ #define KCXDEBUG (0) #define DIOtp (0) #define AIOtp (1) #define HLOtp (2) #define NRMtp (0) #define ALMtp (1) #define NULLi (0) #define NULLf (0.0) #define KcxRASPI_PORT_IN (0) #define KcxRASPI_PORT_OUT (1) #define KcxRASPORT_Di_1 (9) #define KcxRASPORT_Di_2 (25) #define KcxRASPORT_Di_3 (10) #define KcxRASPORT_Di_4 (24) #define KcxRASPORT_Do_1 (23) #define KcxRASPORT_Do_2 (27) #define KcxRASPORT_Do_3 (17) #define KcxRASPORT_Do_4 (18) #define KcxRASPORT_Do_5 (7) #define KcxRASPORT_Do_6 (22) #define KcxRASPORT_AD_din (3) //out #define KcxRASPORT_AD_cs (2) //out #define KcxRASPORT_AD_sclk (14) //out #define KcxRASPORT_AD_dout (15) //in #define KcxRASPORT_AD_sstrb (4) //in #define KcxRASPORT_AiCMP (11) //in #define KcxRASPORT_WdtPulse (8) //out typedef struct _com_ { int type; int set; int objids; time_t cputtime; int cpureset; char ipaddress[32]; int rmtport; int run; int net_error; time_t net_error_ttime; int net_error_cos_flag; struct sockaddr_in sndaddr; } KcxHeaderSX; typedef struct _1682 { KcxHeaderSX x; int di_rt0tm1; /*Diの状態をDiデータにするかDtiデータにするかの選択(0or1)*/ int objid_di [BK1622A_DIs ]; int objid_pi [BK1622A_PIs ]; int objid_do [BK1622A_DOs ]; int objid_do2[BK1622A_DO2s]; int ch_do [BK1622A_DOs ]; int ch_do2 [BK1622A_DO2s]; int log_enable; time_t log_ttime; } KcxBK1682aSX; typedef struct _0822 { KcxHeaderSX x; int objid_ai [AK0822A_AIs ]; int objid_ao [AK0822A_AOs ]; int objid_do2[AK0822A_DO2s]; int ch_do2 [AK0822A_DO2s]; int ch_ao [AK0822A_AOs]; } KcxAK0822aSX; typedef struct _0620 { KcxHeaderSX x; int di_rt0tm1; int objid_di[AK0620A_DIs]; int objid_pi[AK0620A_PIs]; int objid_do[AK0620A_DOs]; int objid_ai[AK0620A_AIs]; int objid_ao[AK0620A_AOs]; int ch_do [AK0620A_DOs]; int ch_ao [AK0620A_AOs]; int log_enable; time_t log_ttime; } KcxAK0620aSX; typedef struct _0580 { KcxHeaderSX x; int di_rt0tm1; int objid_di[GK0580A_DIs]; int objid_pi[GK0580A_PIs]; int objid_do[GK0580A_DOs]; int objid_ai[GK0580A_AIs]; int objid_ao[GK0580A_AOs]; int ch_do [GK0580A_DOs]; int ch_ao [GK0580A_AOs]; int log_enable; time_t log_ttime; } KcxGK0580aSX; typedef struct _0040 { KcxHeaderSX x; int di_rt0tm1; int objid_di[TK0040A_DIs ]; int objid_pi[TK0040A_PIs ]; int objid_do[TK0040A_DOs ]; int objid_ai[TK0040A_AIs ]; int objid_ao[TK0040A_AOPWMs]; int ch_do [TK0040A_DOs ]; int ch_ao [TK0040A_AOPWMs]; int log_enable; time_t log_ttime; } KcxTK0040aSX; typedef struct _0030 { KcxHeaderSX x; int analog_rate; int objid_di[IOB30RTA_DIs]; int objid_do[IOB30RTA_DOs]; int objid_ai[IOB30RTA_AIs]; int ch_do [IOB30RTA_DOs]; } KcxIOB30RTaSX; typedef struct _RASPBERRYy { KcxHeaderSX x; int objid_di[RASPBERRYx_DIs]; int objid_pi[RASPBERRYx_PIs]; int objid_do[RASPBERRYx_DOs]; int objid_ai[RASPBERRYx_AIs]; int ch_do [RASPBERRYx_DOs]; int do_stat [RASPBERRYx_DOs]; int last_di [RASPBERRYx_PIs]; char objidname_pi[RASPBERRYx_PIs][KcxOBJCTLcf_OBJIDNAMELENs+1]; } KcxRASPBERRYaSX; typedef struct _0000 { KcxHeaderSX x; } KcxNetBoxComSX; typedef union _io { KcxNetBoxComSX co; KcxBK1682aSX bk; KcxAK0822aSX ak1; KcxAK0620aSX ak2; KcxGK0580aSX gk; KcxTK0040aSX tk; KcxIOB30RTaSX rt; KcxRASPBERRYaSX rs1; } KcxNetBOX; struct { int idle; int sockid; struct sockaddr_in rcvaddr; int sys_objid; int bzbtn_objid; int bz_on_send_flag; int bz_objids; int bz_objid[500]; int msgsec; char *mtextbuff[EMAILTEXTs]; } svm; struct { KcxNetBOX io[NETBOXs]; int fullarea_objid_DIs; int fullarea_objid_AIs; int fullarea_objid_di[500]; int fullarea_objid_ai[500]; int almjudge_objid_full_or_connect; int dicnt_nb_backup_mode; int monip_nxs; int mailperm; int mailperm_time1; int mailperm_time2; char mailaddress[PARA_EMAILTOADDRs][128]; char mailmessage0[128]; char mailmessage9[128]; char *keyword[PARA_KEYWORDs]; /*PRGパラメータキーワード格納*/ char *keydata[PARA_KEYWORDs]; int test_connect_chk_mode; int raspinit_error; } gvm; main( argc, argv ) int argc; char *argv[]; { int i,j,k,N,cnt,don,dis,ais,flag; int objid,status,para_change; int objtype,objatttype; int objvaltype,objiotype; int top_objid,end_objid; int perm,get_data_flag; int nxs,paralines; int lbreak,raspionly_flag; int Ev_KEY,Ev_STAT; time_t crnt_ttime; struct tm *jikan; char text[BUFSIZ]; KcxIntFlt_t udata; KcxIntFlt_t udata10[10]; KcxObjCtlSX objdata; kcxinit( argc, argv ); /* A.1) 初期メモリゼロクリア設定 */ memset((void *)&svm,0,sizeof(svm)); memset((void *)&gvm,0,sizeof(gvm)); /* A.2) EMAILバッファメモリ割当(UTF漢字1文字当たり3バイト以上必要) */ for(i=0;itm_mon+1, jikan->tm_mday, jikan->tm_hour, jikan->tm_min, jikan->tm_sec ); kcxcns_msg_cwt( 0, 1, text ); prgmesg(1,"通信モード" ); prgmesg(2,"通信中です" ); svm.idle = 5; for(;;){ time( &crnt_ttime ); if( svm.idle > 0 ){ svm.idle--; } /* C.1) パラメータデータ変更のチェック */ para_change = kcxprg_para_data_get( 0, gvm.keyword, gvm.keydata, PARA_KEYWORDs ); if( para_change > 0 ){ svm.msgsec = DEBUGMSGSEC2nd; goto ReSTART; } /* C.2) システムブザーボタンの扱い */ if( svm.bzbtn_objid >= 0 ){ kcxobj_stat_ird( svm.bzbtn_objid, &k ); /*BzSTOPボタン状態取得*/ if(( k == 0 ) && ( svm.bz_on_send_flag == 1 ) ){ /* 警報BzON送信済かつシステムボタンBzSTOP押されてクリア(0)の状態 */ for(i=0;i LOGTMSETITVSECs ){ gvm.io[nxs].bk.log_ttime = crnt_ttime; netbox_logtimeset_check( nxs ); } } //netbox_offline_set( nxs ); break; case ModelAK0822Atp: //netbox_offline_set( nxs ); break; case ModelAK0620Atp: if( gvm.io[nxs].ak2.log_enable == 1 ){ /* 約1時間毎にNetBox内のLog時間をUNIX時間に修正する */ if(( crnt_ttime - gvm.io[nxs].ak2.log_ttime ) > LOGTMSETITVSECs ){ gvm.io[nxs].ak2.log_ttime = crnt_ttime; netbox_logtimeset_check( nxs ); } } //netbox_offline_set( nxs ); break; case ModelGK0580Atp: if( gvm.io[nxs].gk.log_enable == 1 ){ /* 約1時間毎にNetBox内のLog時間をUNIX時間に修正する */ if(( crnt_ttime - gvm.io[nxs].gk.log_ttime ) > LOGTMSETITVSECs ){ gvm.io[nxs].gk.log_ttime = crnt_ttime; netbox_logtimeset_check( nxs ); } } //netbox_offline_set( nxs ); break; case ModelTK0040Atp: if( gvm.io[nxs].tk.log_enable == 1 ){ /* 約1時間毎にNetBox内のLog時間をUNIX時間に修正する */ if(( crnt_ttime - gvm.io[nxs].tk.log_ttime ) > LOGTMSETITVSECs ){ gvm.io[nxs].tk.log_ttime = crnt_ttime; netbox_logtimeset_check( nxs ); } } //netbox_offline_set( nxs ); break; case ModelIOB30RTAtp: //netbox_offline_set( nxs ); break; case ModelRASPBERRYtp: //netbox_offline_set( nxs ); break; default: break; } //gvm.io[nxs].co.x.net_error_cos_flag = 0; } /* C.5) 警報イベント */ alarm_di_judge_and_event_act(); alarm_ai_judge_and_event_act(); /* C.6) DOAO 出力 */ for(get_data_flag=1,don=0;don<100;don++){ switch( kcxobj_sndstat_fromkcx( &objid, &udata ) ){ case KcxINTEGER: get_data_flag = 1; /* リレー操作 */ status = netbox_do_do2_output_send( objid, (int)udata.i/*long long*/ ); if( status >= 1 ){ /*メッセージを操作履歴に追加する*/ memset((void *)udata10,0,sizeof(udata10)); Ev_KEY = 2; Ev_STAT = udata.i; /* 操作ログ書込許可判断 */ kcxobj_event_opelog_perm_ird( objid, &perm ); if( perm >= 1 ){ kcxobj_ope_log_10uwt( objid, Ev_KEY, Ev_STAT, udata10 ); /*操作履歴*/ } }else{ /*送信エラー -> LOG */ memset((void *)udata10,0,sizeof(udata10)); Ev_KEY = 3; Ev_STAT = udata.i; kcxobj_alm_log_10uwt( objid, Ev_KEY, Ev_STAT, udata10 ); /*警報履歴*/ } break; case KcxFLOAT: get_data_flag = 1; /* アナログ操作 */ status = netbox_ao_output_send( objid, udata.f ); if( status >= 1 ){ /*メッセージを操作履歴に追加する*/ memset((void *)udata10,0,sizeof(udata10)); Ev_KEY = 1; Ev_STAT = 1; udata10[0].f = udata.f; /* 操作ログ書込許可判断 */ kcxobj_event_opelog_perm_ird( objid, &perm ); if( perm >= 1 ){ kcxobj_ope_log_10uwt( objid, Ev_KEY, Ev_STAT, udata10 ); /*操作履歴*/ } }else{ /*送信エラー -> LOG */ memset((void *)udata10,0,sizeof(udata10)); Ev_KEY = 2; Ev_STAT = 1; udata10[0].f = udata.f; kcxobj_alm_log_10uwt( objid, Ev_KEY, Ev_STAT, udata10 ); /*警報履歴*/ } break; default: get_data_flag = 0; break; } if( get_data_flag == 0 ) break; } /*通信WAIT*/ if( raspionly_flag == 1 ){ kcxtim_tsleep( 30000 ); /*AtRsOnly = 30msec */ }else{ kcxtim_tsleep( 100000 ); /*AtLAN = 100msec */ } } } prgmesg( no, text ) int no; /* 1(上段),2(下段) */ char text[]; { int line; char msg[1024]; no--; if( no == 1 ) line = 1; else line = 0; sprintf( msg, "%s", text ); kcxprg_debug_msg_cwt( line, msg ); } alarm_di_judge_and_event_act() { int j,nxs,objid,dis; int *objid_di; if( gvm.almjudge_objid_full_or_connect == 0 ){ /* 通信ポイント判断 */ for(nxs=0;nxs 0 ){ kcxobj_alm_perm_chgstat_iwt( objid, 0, 0 ); kcxobj_alm_perm_ird( objid, &alm_perm ); if( alm_perm <= 0 ){ kcxobj_alm_stat_ird( objid, &alm_onoff ); if( alm_onoff >= 1 ){ /*解除*/ if( KCXDEBUG == 1 ) printf("%d sw-alm-off2\n", objid ); event_log_and_email_send( DIOtp,ALMtp,objid,(0),NULLi,NULLf ); } kcxobj_alm_stat_iwt( objid, (0) ); } /* 警報許可変更操作が有った場合非警報にリセット */ kcxobj_alm_lastlevel_iwt( objid, 0,0 ); } /* ポイントが警報点か否か */ kcxobj_dio_almornot_point_atbut_ird( objid, &k ); if( k <= 0 ) event_type = NRMtp; /*非警報点(実行は警報許可を応用)*/ else event_type = ALMtp; /*警報点定義 */ if( event_type == ALMtp ){ /* デジタル警報許可判断 */ kcxobj_alm_perm_ird( objid, &alm_perm ); if( alm_perm <= 0 ){ kcxobj_alm_stat_iwt( objid, (0) ); return 0; } }else{ /* 操作ログ書込許可判断 */ kcxobj_event_opelog_perm_ird( objid, &opelog_perm ); if( opelog_perm <= 0 ) return 0; } kcxobj_stat_ird( objid, &dival ); event = kcxobj_stat_di_event_get( objid, dival, &alm_onoff ); if( event == 0 ) return 0; if( alm_onoff != KcxAlm_UNDEF ){ switch(alm_onoff){ case KcxAlm_OFF: /*解除*/ if( KCXDEBUG == 1 ) printf("%d sw-alm-off\n", objid ); kcxobj_alm_stat_iwt( objid, (0) ); event_log_and_email_send( DIOtp,event_type,objid,(0),NULLi,NULLf ); break; case KcxAlm_ON: /*発生*/ if( KCXDEBUG == 1 ) printf("%d sw-alm-on\n", objid ); if( event_type == ALMtp ){ kcxobj_alm_stat_iwt( objid, (1) ); } event_log_and_email_send( DIOtp,event_type,objid,(1),NULLi,NULLf ); if( event_type == ALMtp ){ if( svm.bz_objids > 0 ){ /*ポイントの警報制御コード取得*/ kcxobj_control_code_ird( objid, NULLi, &code ); if( code > 0 ){ for(i=0;i= 0 ){ kcxobj_stat_iwt( svm.bzbtn_objid, (1) ); /*Bzボタン状態ON*/ svm.bz_on_send_flag = 1; } } } } break; default: break; } } return 1; } alarm_ai_judge_and_event_act() { int j,nxs,objid,ais; int *objid_ai; if( gvm.almjudge_objid_full_or_connect == 0 ){ /* 通信ポイント判断 */ for(nxs=0;nxs 0 ){ kcxobj_alm_perm_chgstat_iwt( objid, 0, 0 ); kcxobj_alm_stat_ird( objid, &alm_crnt_level ); switch(alm_crnt_level){ case KcxAlm_H3: case KcxAlm_H2: case KcxAlm_H1: kcxobj_alm_ai_limit_frd(objid,(alm_crnt_level),&enable,&perm,&f0,&f1,&f2); if(( perm <= 0 )&&( enable >= 1 )){ kcxobj_stat_frd( objid, &aifval ); if( KCXDEBUG == 1 ){ switch(alm_crnt_level){ case KcxAlm_H3: printf("%d = H3 ON\n", objid ); break; case KcxAlm_H2: printf("%d = H2 ON\n", objid ); break; case KcxAlm_H1: printf("%d = H1 ON\n", objid ); break; case KcxAlm_L1: printf("%d = L1 ON\n", objid ); break; case KcxAlm_L2: printf("%d = L2 ON\n", objid ); break; case KcxAlm_L3: printf("%d = L3 ON\n", objid ); break; default: printf("%d = ?? ON\n", objid ); break; } } kcxobj_alm_stat_iwt( objid, (0) ); event_log_and_email_send( AIOtp,ALMtp,objid,(0),alm_crnt_level,aifval ); } break; case KcxAlm_L3: case KcxAlm_L2: case KcxAlm_L1: kcxobj_alm_ai_limit_frd(objid,(alm_crnt_level),&enable,&perm,&f0,&f1,&f2); if(( perm <= 0 )&&( enable >= 1 )){ kcxobj_stat_frd( objid, &aifval ); if( KCXDEBUG == 1 ){ switch(alm_crnt_level){ case KcxAlm_H3: printf("%d = H3 OFF\n", objid ); break; case KcxAlm_H2: printf("%d = H2 OFF\n", objid ); break; case KcxAlm_H1: printf("%d = H1 OFF\n", objid ); break; case KcxAlm_L1: printf("%d = L1 OFF\n", objid ); break; case KcxAlm_L2: printf("%d = L2 OFF\n", objid ); break; case KcxAlm_L3: printf("%d = L3 OFF\n", objid ); break; default: printf("%d = ?? OFF\n", objid ); break; } } kcxobj_alm_stat_iwt( objid, (0) ); event_log_and_email_send( AIOtp,ALMtp,objid,(0),alm_crnt_level,aifval ); } break; default: kcxobj_alm_stat_iwt( objid, (0) ); break; } /* 警報許可変更操作が有った場合非警報にリセット */ kcxobj_alm_lastlevel_iwt( objid, 0,0 ); } /* アナログ警報(大元)許可判断 */ kcxobj_alm_perm_ird( objid, &alm_perm ); if( alm_perm <= 0 ) return 0; kcxobj_stat_frd( objid, &aifval ); event = kcxobj_alm_ai_event_get( objid, aifval, &alm_off_level, &alm_on_level ); if( event == 0 ) return 0; if( alm_off_level != KcxAlm_UNDEF ){ /*解除*/ switch(alm_off_level){ case KcxAlm_H3: case KcxAlm_H2: case KcxAlm_H1: kcxobj_alm_ai_limit_frd(objid,(alm_off_level),&enable,&perm,&f0,&f1,&f2); break; case KcxAlm_L3: case KcxAlm_L2: case KcxAlm_L1: default: kcxobj_alm_ai_limit_frd(objid,(alm_off_level),&enable,&perm,&f0,&f1,&f2); break; } kcxobj_alm_stat_iwt( objid, (0) ); if(( perm >= 1 )&&( enable >= 1 )){ if( KCXDEBUG == 1 ){ switch(alm_off_level){ case KcxAlm_H3: printf("%d = H3 OFF\n", objid ); break; case KcxAlm_H2: printf("%d = H2 OFF\n", objid ); break; case KcxAlm_H1: printf("%d = H1 OFF\n", objid ); break; case KcxAlm_L1: printf("%d = L1 OFF\n", objid ); break; case KcxAlm_L2: printf("%d = L2 OFF\n", objid ); break; case KcxAlm_L3: printf("%d = L3 OFF\n", objid ); break; default: printf("%d = ?? OFF\n", objid ); break; } } event_log_and_email_send( AIOtp,ALMtp,objid,(0),alm_off_level,aifval ); } } if( alm_on_level != KcxAlm_UNDEF ){ /*発生*/ switch(alm_on_level){ case KcxAlm_H3: case KcxAlm_H2: case KcxAlm_H1: kcxobj_alm_ai_limit_frd(objid,(alm_on_level),&enable,&perm,&f0,&f1,&f2); break; case KcxAlm_L3: case KcxAlm_L2: case KcxAlm_L1: default: kcxobj_alm_ai_limit_frd(objid,(alm_on_level),&enable,&perm,&f0,&f1,&f2); break; } if(( perm >= 1 )&&( enable >= 1 )){ if( KCXDEBUG == 1 ){ switch(alm_on_level){ case KcxAlm_H3: printf("%d = H3 ON\n", objid ); break; case KcxAlm_H2: printf("%d = H2 ON\n", objid ); break; case KcxAlm_H1: printf("%d = H1 ON\n", objid ); break; case KcxAlm_L1: printf("%d = L1 ON\n", objid ); break; case KcxAlm_L2: printf("%d = L2 ON\n", objid ); break; case KcxAlm_L3: printf("%d = L3 ON\n", objid ); break; default: printf("%d = ?? ON\n", objid ); break; } } kcxobj_alm_stat_iwt( objid, (alm_on_level) ); event_log_and_email_send( AIOtp,ALMtp,objid,(1),alm_on_level,aifval ); if( svm.bz_objids > 0 ){ /*ポイントの警報制御コード取得*/ kcxobj_control_code_ird( objid, (alm_on_level), &code ); if( code > 0 ){ for(i=0;i= 0 ){ kcxobj_stat_iwt( svm.bzbtn_objid, (1) ); /*Bzボタン状態ON*/ svm.bz_on_send_flag = 1; } } } } } return 1; } machine_hello_connect_check_or_board_active_check() { int i,len,sndlen; int nxs,success; char fid[64]; char ans[64]; char modelname[64]; char text[BUFSIZ]; char sndbuff[BUFSIZ]; char rcvbuff[BUFSIZ]; for(nxs=0;nxs 0 ){ rcvbuff[len] = (char)0; prgmesg(2,rcvbuff); switch( gvm.io[nxs].co.x.type ){ case ModelBK1682Atp: sscanf( rcvbuff, "%s%s%s", fid, ans, modelname ); if( strcmp( modelname, "BK1682A" ) == 0 ){ success = 1; } break; case ModelAK0822Atp: sscanf( rcvbuff, "%s%s%s", fid, ans, modelname ); if( strcmp( modelname, "AK0822A" ) == 0 ){ success = 1; } break; case ModelAK0620Atp: sscanf( rcvbuff, "%s%s%s", fid, ans, modelname ); if( strcmp( modelname, "AK0620A" ) == 0 ){ success = 1; } break; case ModelGK0580Atp: sscanf( rcvbuff, "%s%s%s", fid, ans, modelname ); if( strcmp( modelname, "GK0580A" ) == 0 ){ success = 1; } break; case ModelTK0040Atp: sscanf( rcvbuff, "%s%s%s", fid, ans, modelname ); if( strcmp( modelname, "TK0040A" ) == 0 ){ success = 1; } break; case ModelIOB30RTAtp: sscanf( rcvbuff, "%s%s", fid, modelname ); if( strcmp( modelname, "IOB30RTA" ) == 0 ){ success = 1; } break; default: break; } } if( success == 0 ){ sprintf(text,"エラー終了: 装置番号 %d IPアドレス %s 装置との試験接続失敗", 1 + nxs, gvm.io[nxs].co.x.ipaddress ); prgmesg(1,text); if( len > 0 ){ sprintf(text,"装置応答文 = [%s] (装置の型が悪い(不一致)かもしれません)", rcvbuff ); }else{ sprintf(text,"装置応答無し" ); } prgmesg(2,text); exit(0); } break; case ModelRASPBERRYtp: break; default: break; }/*switch(type)*/ }/*for(nsx)*/ } netbox_dicntlog_testset_init() { int nxs,code; for(nxs=0;nxs= (2) ){ gvm.io[nxs].bk.log_enable = 1; }else{ _netbox_logconfig_testset( nxs ); code = netbox_cntlogenable_check( nxs ); if( code >= (2) ){ gvm.io[nxs].bk.log_enable = 1; } } break; case ModelAK0620Atp: code = netbox_cntlogenable_check( nxs ); if( code >= (2) ){ gvm.io[nxs].ak2.log_enable = 1; }else{ _netbox_logconfig_testset( nxs ); code = netbox_cntlogenable_check( nxs ); if( code >= (2) ){ gvm.io[nxs].ak2.log_enable = 1; } } break; case ModelGK0580Atp: code = netbox_cntlogenable_check( nxs ); if( code >= (2) ){ gvm.io[nxs].gk.log_enable = 1; }else{ _netbox_logconfig_testset( nxs ); code = netbox_cntlogenable_check( nxs ); if( code >= (2) ){ gvm.io[nxs].gk.log_enable = 1; } } break; case ModelTK0040Atp: code = netbox_cntlogenable_check( nxs ); if( code >= (2) ){ gvm.io[nxs].tk.log_enable = 1; }else{ _netbox_logconfig_testset( nxs ); code = netbox_cntlogenable_check( nxs ); if( code >= (2) ){ gvm.io[nxs].tk.log_enable = 1; } } break; default: break; } } } iob30rta_analog_rate_set( mesgmode ) int mesgmode; { int i,nxs,try,len,sndlen; int Ev_KEY,Ev_STAT; char fid[64]; char cmd[64]; char text[BUFSIZ]; char sndbuff[BUFSIZ]; char rcvbuff[BUFSIZ]; char *cdata28; KcxIntFlt_t udata10[10]; for(nxs=0;nxs 0 ){ rcvbuff[len] = (char)0; sscanf( rcvbuff, "%s%s", fid, cmd ); if( strcmp( cmd, "RANGE" ) == 0 ) return 1; return 1; } sleep(1); } if( mesgmode == 1 ){ sprintf(text,"No. %d のIOB30RTA アナログレート設定に失敗しました", 1+nxs ); prgmesg(2,text); } if(( mesgmode == 1 )||( mesgmode == 2 )){ memset((void *)udata10,0,sizeof(udata10)); cdata28 = (char *)udata10; /* ログ構造体先頭アドレスを作業用charに設定 */ strcpy( text, "アナログレート設定" ); /* 半角27文字まで使用可能 */ text[(27)] = (char)0; strcpy( cdata28, text ); Ev_KEY = 20; Ev_STAT = 30; kcxobj_alm_log_10uwt( svm.sys_objid, Ev_KEY, Ev_STAT, udata10 ); /*警報履歴*/ sleep( 3 ); /* チェック時以外のエラーは長目表示 */ } return (-1); } } netbox_offline_set( nxs ) int nxs; { int i,err,objid; if( gvm.io[nxs].co.x.net_error_cos_flag == 0 ) return 0; err = gvm.io[nxs].co.x.net_error; switch( gvm.io[nxs].co.x.type ){ case ModelBK1682Atp: if( err == 0 ){ for(i=0;i 9999 ) seq = 1; sprintf( seqtext, "%04d", seq ); kcxobj_stat_ird( gvm.io[nxs].bk.objid_pi[ch-1], &idata ); sprintf( sndbuff, "%s di-cnt-set %d %d", seqtext, ch, idata ); sndlen = strlen(sndbuff); len = netbox_sync_com( nxs,sndbuff,sndlen,rcvbuff,sizeof(rcvbuff) ); if( len > 0 ){ rcvbuff[len] = (char)0; sscanf( rcvbuff, "%s", fid ); if( strcmp( fid, seqtext ) != 0 ) continue; sscanf( rcvbuff, "%s%s", fid, ans ); if( strcmp( ans, "DI-CNT-SET" ) == 0 ) break; } } } gvm.io[nxs].bk.log_enable = 0; gvm.io[nxs].bk.log_ttime = 0; break; case ModelAK0620Atp: for(ch=(1);ch<=(2);ch++){ for(try=0;try<(3);try++){ if( ++seq > 9999 ) seq = 1; sprintf( seqtext, "%04d", seq ); kcxobj_stat_ird( gvm.io[nxs].ak2.objid_pi[ch-1], &idata ); sprintf( sndbuff, "%s di-cnt-set %d %d", seqtext, ch, idata ); sndlen = strlen(sndbuff); len = netbox_sync_com( nxs,sndbuff,sndlen,rcvbuff,sizeof(rcvbuff) ); if( len > 0 ){ rcvbuff[len] = (char)0; sscanf( rcvbuff, "%s", fid ); if( strcmp( fid, seqtext ) != 0 ) continue; sscanf( rcvbuff, "%s%s", fid, ans ); if( strcmp( ans, "DI-CNT-SET" ) == 0 ) break; } } } gvm.io[nxs].ak2.log_enable = 0; gvm.io[nxs].ak2.log_ttime = 0; break; case ModelGK0580Atp: for(ch=(1);ch<=(8);ch++){ for(try=0;try<(3);try++){ if( ++seq > 9999 ) seq = 1; sprintf( seqtext, "%04d", seq ); kcxobj_stat_ird( gvm.io[nxs].gk.objid_pi[ch-1], &idata ); sprintf( sndbuff, "%s di-cnt-set %d %d", seqtext, ch, idata ); sndlen = strlen(sndbuff); len = netbox_sync_com( nxs,sndbuff,sndlen,rcvbuff,sizeof(rcvbuff) ); if( len > 0 ){ rcvbuff[len] = (char)0; sscanf( rcvbuff, "%s", fid ); if( strcmp( fid, seqtext ) != 0 ) continue; sscanf( rcvbuff, "%s%s", fid, ans ); if( strcmp( ans, "DI-CNT-SET" ) == 0 ) break; } } } gvm.io[nxs].gk.log_enable = 0; gvm.io[nxs].gk.log_ttime = 0; break; case ModelTK0040Atp: for(ch=(1);ch<=(6);ch++){ for(try=0;try<(3);try++){ if( ++seq > 9999 ) seq = 1; sprintf( seqtext, "%04d", seq ); kcxobj_stat_ird( gvm.io[nxs].tk.objid_pi[ch-1], &idata ); sprintf( sndbuff, "%s di-cnt-set %d %d", seqtext, ch, idata ); sndlen = strlen(sndbuff); len = netbox_sync_com( nxs,sndbuff,sndlen,rcvbuff,sizeof(rcvbuff) ); if( len > 0 ){ rcvbuff[len] = (char)0; sscanf( rcvbuff, "%s", fid ); if( strcmp( fid, seqtext ) != 0 ) continue; sscanf( rcvbuff, "%s%s", fid, ans ); if( strcmp( ans, "DI-CNT-SET" ) == 0 ) break; } } } gvm.io[nxs].tk.log_enable = 0; gvm.io[nxs].tk.log_ttime = 0; break; default: break; } } netbox_cntlogenable_check( nxs ) int nxs; { int try,len,sndlen; char fid[64],ans[64]; char enable[64],start[64],minu[64]; char seqtext[64]; char sndbuff[BUFSIZ]; char rcvbuff[BUFSIZ]; static int seq = 0; for(try=0;try<(3);try++){ if( ++seq > 9999 ) seq = 1; sprintf( seqtext, "%04d", seq ); sprintf( sndbuff, "%s _ioconfig-get log", seqtext ); sndlen = strlen(sndbuff); len = netbox_sync_com( nxs,sndbuff,sndlen,rcvbuff,sizeof(rcvbuff) ); if( len > 0 ){ rcvbuff[len] = (char)0; sscanf( rcvbuff, "%s", fid ); if( strcmp( fid, seqtext ) != 0 ) return 0; sscanf( rcvbuff, "%s%s%s%s%s", fid, ans, enable, start, minu ); if( strcmp( ans, "_IOCONFIG-GET" ) == 0 ){ if( strcmp( enable, "1" ) != 0 ) return 0; /*ログ機能停止*/ if( strcmp( start, "1" ) != 0 ) return 1; /*ログ開始最大でない*/ if( strcmp( minu, "1" ) != 0 ) return 2; /*ログ時間が1分でない*/ return 3; /* ログ機能ON:ログ開始最大:ログ時間1分 */ } } sleep(1); } return 0; } _netbox_logconfig_testset( nxs ) int nxs; { int try,len,sndlen; char fid[64],ans[64]; char enable[64],start[64],minu[64]; char seqtext[64]; char sndbuff[BUFSIZ]; char rcvbuff[BUFSIZ]; static int seq = 0; for(try=0;try<(3);try++){ if( ++seq > 9999 ) seq = 1; sprintf( seqtext, "%04d", seq ); sprintf( sndbuff, "%s _log-config-set 1 1 60 0", seqtext ); sndlen = strlen(sndbuff); len = netbox_sync_com( nxs,sndbuff,sndlen,rcvbuff,sizeof(rcvbuff) ); if( len > 0 ){ rcvbuff[len] = (char)0; sscanf( rcvbuff, "%s", fid ); if( strcmp( fid, seqtext ) != 0 ) return 0; sscanf( rcvbuff, "%s%s%s%s%s", fid, ans, enable, start, minu ); if( strcmp( ans, "_LOG-CONFIG-SET" ) == 0 ) break; } sleep(1); } return 0; } netbox_logtimeset_check( nxs ) int nxs; { int len,sndlen; char fid[64],ans[64]; char seqtext[64]; char sndbuff[BUFSIZ]; char rcvbuff[BUFSIZ]; time_t ttime; static int seq = 0; if( ++seq > 9999 ) seq = 1; sprintf( seqtext, "%04d", seq ); time( &ttime ); sprintf( sndbuff, "%s log-time-set -1 -1 %d -1 0", seqtext, ttime ); sndlen = strlen(sndbuff); len = netbox_sync_com( nxs,sndbuff,sndlen,rcvbuff,sizeof(rcvbuff) ); if( len > 0 ){ rcvbuff[len] = (char)0; sscanf( rcvbuff, "%s", fid ); if( strcmp( fid, seqtext ) != 0 ) return (-1); sscanf( rcvbuff, "%s%s", fid, ans ); if( strcmp( ans, "LOG-TIME-SET" ) == 0 ) return 0; } return (-1); } parameter_strtok( strings, words, maxwords, tokensep ) char strings[]; char *words[]; int maxwords; char tokensep[]; { int i,wordcnt; char *p; char tokensep2[64]; static int init = 0; static char cnull[8]; if( init == 0 ){ strcpy( cnull, "" ); init = 1; } strcpy( tokensep2, tokensep ); if( tokensep2[0] == (char)0 ){ strcpy( tokensep2, " \t\r\n,;" ); } for(i=0;i= 1440 ) || ( gvm.mailperm_time2 >= 1440 ) || ( gvm.mailperm_time1 == gvm.mailperm_time2 ) ){ sprintf(text,"記述ミス。[%s] の時間指定に間違いがあるようです (%d行目付近)", strbuff2,ys); prgmesg(1,text); exit(0); } } }else{ sprintf(text,"記述ミス。on か off どちらか一方を指定してください。(%d行目付近)",ys); prgmesg(1,text); exit(0); } } if( strcmp( gvm.keyword[ks], "bz" ) == 0 ){ n = parameter_strtok( gvm.keydata[ks], parawords, PARA_PARAWORDs, "" ); for(i=cnt2=0;i= NETBOXs ) gvm.monip_nxs = 0; } for(es=0;es= 21 )&&( abs(k) <= 28 )){ gvm.io[nxs].rt.analog_rate = k; /* ±21 〜 ±28 */ }else{ sprintf(text,"IOB30RTAアナログレート誤設定無視しました [%d] (%d行目付近)",k,ys); prgmesg(2,text); sleep(svm.msgsec); } break; default: break; } } break; case ModelRASPBERRYtp: kcxinit_raspberrypi(); /* No check ip and port */ break; default: break; } para_phase = 1; para_objids = 0; } for(ds=0;ds<(3);ds++){ if( gvm.io[nxs].co.x.type == ModelNULLtp ) break; sprintf(text,"%d.dat%d", 1+nxs, 1+ds ); if( strcmp( gvm.keyword[ks], text ) == 0 ){ /* 1.dat1, 1.dat2,,, */ wordcnt = parameter_strtok( gvm.keydata[ks], parawords, PARA_PARAWORDs, "" ); for(i=0;i= 0 )&&( para_objids <= 15 )){ if( objtype != KcxOBJtp_POINT_DI ){ sprintf(text,"OBJIDの型不一致。[%s] が DI 型でありません (%d行目付近)", para_objidname[para_objids],ys); prgmesg(1,text); exit(0); } } if(( para_objids >= 16 )&&( para_objids <= 31 )){ if( objtype != KcxOBJtp_POINT_PI ){ sprintf(text,"OBJIDの型不一致。[%s] が PI 型でありません (%d行目付近)", para_objidname[para_objids],ys); prgmesg(1,text); exit(0); } } if(( para_objids >= 32 )&&( para_objids <= 39 )){ if( objtype != KcxOBJtp_POINT_DO ){ sprintf(text,"OBJIDの型不一致。[%s] が DO 型でありません (%d行目付近)", para_objidname[para_objids],ys); prgmesg(1,text); exit(0); } } if(( para_objids >= 40 )&&( para_objids <= 41 )){ if( objtype != KcxOBJtp_POINT_DO ){ sprintf(text,"OBJIDの型不一致。[%s] が DO 型でありません (%d行目付近)", para_objidname[para_objids],ys); prgmesg(1,text); exit(0); } } break; case ModelAK0822Atp: if(( para_objids >= 0 )&&( para_objids <= 7 )){ if( objtype != KcxOBJtp_POINT_AI ){ sprintf(text,"OBJIDの型不一致。[%s] が AI 型でありません (%d行目付近)", para_objidname[para_objids],ys); prgmesg(1,text); exit(0); } } if(( para_objids >= 8 )&&( para_objids <= 9 )){ if( objtype != KcxOBJtp_POINT_AO ){ sprintf(text,"OBJIDの型不一致。[%s] が AO 型でありません (%d行目付近)", para_objidname[para_objids],ys); prgmesg(1,text); exit(0); } } if(( para_objids >= 10 )&&( para_objids <= 11 )){ if( objtype != KcxOBJtp_POINT_DO ){ sprintf(text,"OBJIDの型不一致。[%s] が DO 型でありません (%d行目付近)", para_objidname[para_objids],ys); prgmesg(1,text); exit(0); } } break; case ModelAK0620Atp: if(( para_objids >= 0 )&&( para_objids <= 1 )){ if( objtype != KcxOBJtp_POINT_DI ){ sprintf(text,"OBJIDの型不一致。[%s] が DI 型でありません (%d行目付近)", para_objidname[para_objids],ys); prgmesg(1,text); exit(0); } } if(( para_objids >= 2 )&&( para_objids <= 3 )){ if( objtype != KcxOBJtp_POINT_PI ){ sprintf(text,"OBJIDの型不一致。[%s] が PI 型でありません (%d行目付近)", para_objidname[para_objids],ys); prgmesg(1,text); exit(0); } } if(( para_objids >= 4 )&&( para_objids <= 5 )){ if( objtype != KcxOBJtp_POINT_DO ){ sprintf(text,"OBJIDの型不一致。[%s] が DO 型でありません (%d行目付近)", para_objidname[para_objids],ys); prgmesg(1,text); exit(0); } } if(( para_objids >= 6 )&&( para_objids <= 17 )){ if( objtype != KcxOBJtp_POINT_AI ){ sprintf(text,"OBJIDの型不一致。[%s] が AI 型でありません (%d行目付近)", para_objidname[para_objids],ys); prgmesg(1,text); exit(0); } } if(( para_objids >= 18 )&&( para_objids <= 19 )){ if( objtype != KcxOBJtp_POINT_AO ){ sprintf(text,"OBJIDの型不一致。[%s] が AO 型でありません (%d行目付近)", para_objidname[para_objids],ys); prgmesg(1,text); exit(0); } } break; case ModelGK0580Atp: if(( para_objids >= 0 )&&( para_objids <= 13 )){ if( objtype != KcxOBJtp_POINT_DI ){ sprintf(text,"OBJIDの型不一致。[%s] が DI 型でありません (%d行目付近)", para_objidname[para_objids],ys); prgmesg(1,text); exit(0); } } if(( para_objids >= 14 )&&( para_objids <= 27 )){ if( objtype != KcxOBJtp_POINT_PI ){ sprintf(text,"OBJIDの型不一致。[%s] が PI 型でありません (%d行目付近)", para_objidname[para_objids],ys); prgmesg(1,text); exit(0); } } if(( para_objids >= 28 )&&( para_objids <= 35 )){ if( objtype != KcxOBJtp_POINT_DO ){ sprintf(text,"OBJIDの型不一致。[%s] が DO 型でありません (%d行目付近)", para_objidname[para_objids],ys); prgmesg(1,text); exit(0); } } if(( para_objids >= 36 )&&( para_objids <= 43 )){ if( objtype != KcxOBJtp_POINT_AI ){ sprintf(text,"OBJIDの型不一致。[%s] が AI 型でありません (%d行目付近)", para_objidname[para_objids],ys); prgmesg(1,text); exit(0); } } if(( para_objids >= 44 )&&( para_objids <= 45 )){ if( objtype != KcxOBJtp_POINT_AO ){ sprintf(text,"OBJIDの型不一致。[%s] が AO 型でありません (%d行目付近)", para_objidname[para_objids],ys); prgmesg(1,text); exit(0); } } break; case ModelTK0040Atp: if(( para_objids >= 0 )&&( para_objids <= 5 )){ if( objtype != KcxOBJtp_POINT_DI ){ sprintf(text,"OBJIDの型不一致。[%s] が DI 型でありません (%d行目付近)", para_objidname[para_objids],ys); prgmesg(1,text); exit(0); } } if(( para_objids >= 6 )&&( para_objids <= 11 )){ if( objtype != KcxOBJtp_POINT_PI ){ sprintf(text,"OBJIDの型不一致。[%s] が PI 型でありません (%d行目付近)", para_objidname[para_objids],ys); prgmesg(1,text); exit(0); } } if(( para_objids >= 12 )&&( para_objids <= 15 )){ if( objtype != KcxOBJtp_POINT_DO ){ sprintf(text,"OBJIDの型不一致。[%s] が DO 型でありません (%d行目付近)", para_objidname[para_objids],ys); prgmesg(1,text); exit(0); } } if(( para_objids >= 16 )&&( para_objids <= 19 )){ if( objtype != KcxOBJtp_POINT_AI ){ sprintf(text,"OBJIDの型不一致。[%s] が AI 型でありません (%d行目付近)", para_objidname[para_objids],ys); prgmesg(1,text); exit(0); } } if(( para_objids >= 20 )&&( para_objids <= 22 )){ if( objtype != KcxOBJtp_POINT_AO ){ sprintf(text,"OBJIDの型不一致。[%s] が AO 型でありません (%d行目付近)", para_objidname[para_objids],ys); prgmesg(1,text); exit(0); } } break; case ModelIOB30RTAtp: if(( para_objids >= 0 )&&( para_objids <= 7 )){ if( objtype != KcxOBJtp_POINT_AI ){ sprintf(text,"OBJIDの型不一致。[%s] が AI 型でありません (%d行目付近)", para_objidname[para_objids],ys); prgmesg(1,text); exit(0); } } if(( para_objids >= 8 )&&( para_objids <= 11 )){ if( objtype != KcxOBJtp_POINT_DI ){ sprintf(text,"OBJIDの型不一致。[%s] が DI 型でありません (%d行目付近)", para_objidname[para_objids],ys); prgmesg(1,text); exit(0); } } if(( para_objids >= 12 )&&( para_objids <= 15 )){ if( objtype != KcxOBJtp_POINT_DO ){ sprintf(text,"OBJIDの型不一致。[%s] が DO 型でありません (%d行目付近)", para_objidname[para_objids],ys); prgmesg(1,text); exit(0); } } break; case ModelRASPBERRYtp: if(( para_objids >= 0 )&&( para_objids <= 3 )){ if( objtype != KcxOBJtp_POINT_DI ){ sprintf(text,"OBJIDの型不一致。[%s] が DI 型でありません (%d行目付近)", para_objidname[para_objids],ys); prgmesg(1,text); exit(0); } } if(( para_objids >= 4 )&&( para_objids <= 7 )){ if( objtype != KcxOBJtp_POINT_PI ){ sprintf(text,"OBJIDの型不一致。[%s] が PI 型でありません (%d行目付近)", para_objidname[para_objids],ys); prgmesg(1,text); exit(0); } } if(( para_objids >= 8 )&&( para_objids <= 13 )){ if( objtype != KcxOBJtp_POINT_DO ){ sprintf(text,"OBJIDの型不一致。[%s] が DO 型でありません (%d行目付近)", para_objidname[para_objids],ys); prgmesg(1,text); exit(0); } } if(( para_objids >= 14 )&&( para_objids <= 17 )){ if( objtype != KcxOBJtp_POINT_AI ){ sprintf(text,"OBJIDの型不一致。[%s] が AI 型でありません (%d行目付近)", para_objidname[para_objids],ys); prgmesg(1,text); exit(0); } } break; default: break; } gvm.io[nxs].co.x.objids++; } para_objids++; } if( ds == 2 ) para_phase = 2; } } if( para_phase == 2 ){ switch( gvm.io[nxs].co.x.type ){ case ModelBK1682Atp: k = BK1622A_DIs+BK1622A_PIs+BK1622A_DOs+BK1622A_DO2s; if( para_objids != k ){ sprintf(text,"登録すべきOBJIDの総数不一致。 %d 個のところ %d 個でした。(%d行目付近)", k,para_objids,ys); prgmesg(1,text); exit(0); } cnt = 0; for(i=0;i= 0 ) && ( gvm.io[nxs].rs1.objid_pi[i] >= 0 ) ){ strcpy( gvm.io[nxs].rs1.objidname_pi[i], para_objidname[cnt] ); idata = raspi_pi_datasave_rw( 0/*read*/, i, 0, para_objidname[cnt] ); kcxobj_stat_iwt( gvm.io[nxs].rs1.objid_pi[i], idata ); } cnt++; } for(i=0;i 9999 ) seq = 1; sprintf( sndbuff, "%04d mix", seq ); sndlen = strlen(sndbuff); len = netbox_sync_com( nxs,sndbuff,sndlen,rcvbuff,sizeof(rcvbuff) ); if( len > 0 ){ rcvbuff[len] = (char)0; if( gvm.monip_nxs == nxs ){ prgmesg(2,rcvbuff); } recvpacket( nxs, 0, rcvbuff ); } break; case ModelIOB30RTAtp: flag1 = 0; flag2 = 0; for(i=0;i= 0 ) flag1 = 1; } for(i=0;i= 0 ) flag1 = 1; } for(i=0;i= 0 ) flag2 = 1; } if(( flag1 == 1 )||( flag2 == 1 )){ if( ++seq > 9999 ) seq = 1; sprintf( sndbuff, "%04d hello", seq ); sndlen = strlen(sndbuff); len = netbox_sync_com( nxs,sndbuff,sndlen,rcvbuff,sizeof(rcvbuff) ); if( len > 0 ){ rcvbuff[len] = (char)0; /* if( gvm.monip_nxs == nxs ){ prgmesg(2,rcvbuff); } */ recvpacket( nxs, HLOtp, rcvbuff ); } } if( gvm.io[nxs].co.x.cpureset == 1 ){ flag1 = 0; flag2 = 0; } if( flag1 == 1 ){ if( ++seq > 9999 ) seq = 1; sprintf( sndbuff, "%04d bin", seq ); sndlen = strlen(sndbuff); len = netbox_sync_com( nxs,sndbuff,sndlen,rcvbuff,sizeof(rcvbuff) ); if( len > 0 ){ rcvbuff[len] = (char)0; if( gvm.monip_nxs == nxs ){ prgmesg(2,rcvbuff); } recvpacket( nxs, DIOtp, rcvbuff ); } } if( flag2 == 1 ){ if( ++seq > 9999 ) seq = 1; sprintf( sndbuff, "%04d ain", seq ); sndlen = strlen(sndbuff); len = netbox_sync_com( nxs,sndbuff,sndlen,rcvbuff,sizeof(rcvbuff) ); if( len > 0 ){ rcvbuff[len] = (char)0; if( gvm.monip_nxs == nxs ){ prgmesg(2,rcvbuff); } recvpacket( nxs, AIOtp, rcvbuff ); } } break; default: break; } } recvpacket( nxs, optiontype, rcvbuff ) int nxs; int optiontype; char rcvbuff[]; { int i,scalemode,idata; double fdata,fdata2,smfval,Af,Bf,Cf; double hi_fval,low_fval; time_t ttime; char fid [64]; /* フレームID */ char cmd [64]; /* コマンド */ char dis [64]; /* Din */ char dts [64]; /* Dtin */ char dits [64]; /* DinOrDtin */ char dc [16][64]; /* Dcin */ char dos [64]; /* Dout */ char do2s [64]; /* Dout2 */ char ai [12][64]; /* Ain */ char ao [ 2][64]; /* Aout */ char pwm [ 3][64]; /* Pwmout */ char msg1 [64]; /* Msg1 */ char ktime [64]; /* Time */ char etc1 [64]; char etc2 [64]; char chksum[64]; char cdata [512]; switch( gvm.io[nxs].co.x.type ){ case ModelBK1682Atp: /* 1 2 3 4 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 1 2 3 4 */ sscanf( rcvbuff, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", fid,cmd,dis,dts, dc[0],dc[1],dc[2],dc[3],dc[4],dc[5],dc[6],dc[7],dc[8], dc[9],dc[10],dc[11],dc[12],dc[13],dc[14],dc[15], dos,do2s,msg1,ktime ); ttime = (time_t)strtol( ktime, (char **)NULL, 10 ); if( ttime < gvm.io[nxs].co.x.cputtime ){ gvm.io[nxs].co.x.cpureset = 1; break; } gvm.io[nxs].co.x.cputtime = ttime; if( gvm.io[nxs].bk.di_rt0tm1 == 0 ) strcpy( dits, dis ); else strcpy( dits, dts ); for(i=0;i<(16);i++){ if( dits[i] == (char)'0' ){ kcxobj_stat_iwt( gvm.io[nxs].bk.objid_di[i], 0 ); }else if( dits[i] == (char)'1' ){ kcxobj_stat_iwt( gvm.io[nxs].bk.objid_di[i], 1 ); } } for(i=0;i<(16);i++){ idata = (int)strtol( dc[i], (char **)NULL, 10 ); kcxobj_stat_iwt ( gvm.io[nxs].bk.objid_pi[i], idata ); } for(i=0;i<(8);i++){ if( dos[i] == (char)'0' ){ kcxobj_stat_iwt( gvm.io[nxs].bk.objid_do[i], 0 ); }else if( dos[i] == (char)'1' ){ kcxobj_stat_iwt( gvm.io[nxs].bk.objid_do[i], 1 ); } } for(i=0;i<(2);i++){ if( do2s[i] == (char)'0' ){ kcxobj_stat_iwt( gvm.io[nxs].bk.objid_do2[i], 0 ); }else if( do2s[i] == (char)'1' ){ kcxobj_stat_iwt( gvm.io[nxs].bk.objid_do2[i], 1 ); } } break; case ModelAK0822Atp: /* 1 2 1 2 3 4 5 6 7 8 1 2 1 2 3 */ sscanf( rcvbuff, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", fid,cmd,ai[0],ai[1],ai[2],ai[3],ai[4],ai[5],ai[6],ai[7], ao[0],ao[1], do2s,msg1,ktime ); ttime = (time_t)strtol( ktime, (char **)NULL, 10 ); if( ttime < gvm.io[nxs].co.x.cputtime ){ gvm.io[nxs].co.x.cpureset = 1; break; } gvm.io[nxs].co.x.cputtime = ttime; for(i=0;i<(8);i++){ if( gvm.io[nxs].ak1.objid_ai[i] < 0 ) continue; kcxobj_atbut_ird( gvm.io[nxs].ak1.objid_ai[i], (6), &scalemode ); if( scalemode == 1 ){ kcxobj_atbut_frd( gvm.io[nxs].ak1.objid_ai[i], (1), &Af ); kcxobj_atbut_frd( gvm.io[nxs].ak1.objid_ai[i], (2), &Bf ); kcxobj_atbut_frd( gvm.io[nxs].ak1.objid_ai[i], (3), &Cf ); idata = (int)strtol( ai[i], (char **)NULL, 10 ); fdata2 = (double)idata / (double)4096; if( fabs((double)Af) < 0.00001 ) Af = 1.0; fdata = Af * ( fdata2 + Bf ) + Cf; }else{ kcxobj_scale2_frd( gvm.io[nxs].ak1.objid_ai[i], 1/*IFC*/, &hi_fval, &low_fval ); idata = (int)strtol( ai[i], (char **)NULL, 10 ); fdata = (double)idata / (double)4096 * ( hi_fval - low_fval ) + low_fval; } kcxobj_stat_fwt( gvm.io[nxs].ak1.objid_ai[i], fdata ); } for(i=0;i<(2);i++){ if( gvm.io[nxs].ak1.objid_ao[i] < 0 ) continue; kcxobj_atbut_ird( gvm.io[nxs].ak1.objid_ao[i], (6), &scalemode ); if( scalemode == 1 ){ kcxobj_atbut_frd( gvm.io[nxs].ak1.objid_ao[i], (1), &Af ); kcxobj_atbut_frd( gvm.io[nxs].ak1.objid_ao[i], (2), &Bf ); kcxobj_atbut_frd( gvm.io[nxs].ak1.objid_ao[i], (3), &Cf ); idata = (int)strtol( ao[i], (char **)NULL, 10 ); fdata2 = (double)idata / (double)256; if( fabs((double)Af) < 0.00001 ) Af = 1.0; fdata = Af * ( fdata2 + Bf ) + Cf; }else{ kcxobj_scale2_frd( gvm.io[nxs].ak1.objid_ao[i], 1/*IFC*/, &hi_fval, &low_fval ); idata = (int)strtol( ao[i], (char **)NULL, 10 ); fdata = (double)idata / (double)256 * ( hi_fval - low_fval ) + low_fval; } kcxobj_stat_fwt( gvm.io[nxs].ak1.objid_ao[i], fdata ); } for(i=0;i<(2);i++){ if( do2s[i] == (char)'0' ){ kcxobj_stat_iwt( gvm.io[nxs].ak1.objid_do2[i], 0 ); }else if( do2s[i] == (char)'1' ){ kcxobj_stat_iwt( gvm.io[nxs].ak1.objid_do2[i], 1 ); } } break; case ModelAK0620Atp: /* 1 2 3 4 1 2 1 1 2 3 4 5 6 7 8 9101112 1 2 1 2 */ sscanf( rcvbuff, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", fid,cmd,dis,dts,dc[0],dc[1],dos,ai[0],ai[1],ai[2],ai[3],ai[4], ai[5],ai[6],ai[7],ai[8],ai[9],ai[10],ai[11],ao[0],ao[1],msg1,ktime ); ttime = (time_t)strtol( ktime, (char **)NULL, 10 ); if( ttime < gvm.io[nxs].co.x.cputtime ){ gvm.io[nxs].co.x.cpureset = 1; break; } gvm.io[nxs].co.x.cputtime = ttime; if( gvm.io[nxs].ak2.di_rt0tm1 == 0 ) strcpy( dits, dis ); else strcpy( dits, dts ); for(i=0;i<(2);i++){ if( dits[i] == (char)'0' ){ kcxobj_stat_iwt( gvm.io[nxs].ak2.objid_di[i], 0 ); }else if( dits[i] == (char)'1' ){ kcxobj_stat_iwt( gvm.io[nxs].ak2.objid_di[i], 1 ); } } for(i=0;i<(2);i++){ idata = (int)strtol( dc[i], (char **)NULL, 10 ); kcxobj_stat_iwt( gvm.io[nxs].ak2.objid_pi[i], idata ); } for(i=0;i<(2);i++){ if( dos[i] == (char)'0' ){ kcxobj_stat_iwt( gvm.io[nxs].ak2.objid_do[i], 0 ); }else if( dos[i] == (char)'1' ){ kcxobj_stat_iwt( gvm.io[nxs].ak2.objid_do[i], 1 ); } } for(i=0;i<(12);i++){ if( gvm.io[nxs].ak2.objid_ai[i] < 0 ) continue; kcxobj_atbut_ird( gvm.io[nxs].ak2.objid_ai[i], (6), &scalemode ); if( scalemode == 1 ){ kcxobj_atbut_frd( gvm.io[nxs].ak2.objid_ai[i], (1), &Af ); kcxobj_atbut_frd( gvm.io[nxs].ak2.objid_ai[i], (2), &Bf ); kcxobj_atbut_frd( gvm.io[nxs].ak2.objid_ai[i], (3), &Cf ); idata = (int)strtol( ai[i], (char **)NULL, 10 ); fdata2 = (double)idata / (double)65536; if( fabs((double)Af) < 0.00001 ) Af = 1.0; fdata = Af * ( fdata2 + Bf ) + Cf; }else{ kcxobj_scale2_frd( gvm.io[nxs].ak2.objid_ai[i], 1/*IFC*/, &hi_fval, &low_fval ); idata = (int)strtol( ai[i], (char **)NULL, 10 ); fdata = (double)idata / (double)65536 * ( hi_fval - low_fval ) + low_fval; } kcxobj_stat_fwt( gvm.io[nxs].ak2.objid_ai[i], fdata ); } for(i=0;i<(2);i++){ if( gvm.io[nxs].ak2.objid_ao[i] < 0 ) continue; kcxobj_atbut_ird( gvm.io[nxs].ak2.objid_ao[i], (6), &scalemode ); if( scalemode == 1 ){ kcxobj_atbut_frd( gvm.io[nxs].ak2.objid_ao[i], (1), &Af ); kcxobj_atbut_frd( gvm.io[nxs].ak2.objid_ao[i], (2), &Bf ); kcxobj_atbut_frd( gvm.io[nxs].ak2.objid_ao[i], (3), &Cf ); idata = (int)strtol( ao[i], (char **)NULL, 10 ); fdata2 = (double)idata / (double)4096; if( fabs((double)Af) < 0.00001 ) Af = 1.0; fdata = Af * ( fdata2 + Bf ) + Cf; }else{ kcxobj_scale2_frd( gvm.io[nxs].ak2.objid_ao[i], 1/*IFC*/, &hi_fval, &low_fval ); idata = (int)strtol( ao[i], (char **)NULL, 10 ); fdata = (double)idata / (double)4096 * ( hi_fval - low_fval ) + low_fval; } kcxobj_stat_fwt( gvm.io[nxs].ak2.objid_ao[i], fdata ); } break; case ModelGK0580Atp: /* 1 2 3 4 1 2 3 4 5 6 7 8 91011121314 1 1 2 3 4 5 6 7 8 1 2 1 1 */ sscanf( rcvbuff, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", fid,cmd,dis,dts, dc[0],dc[1],dc[2],dc[3],dc[4],dc[5],dc[6],dc[7], dc[8],dc[9],dc[10],dc[11],dc[12],dc[13], dos,ai[0],ai[1],ai[2],ai[3],ai[4],ai[5],ai[6],ai[7], ao[0],ao[1],msg1,ktime ); ttime = (time_t)strtol( ktime, (char **)NULL, 10 ); if( ttime < gvm.io[nxs].co.x.cputtime ){ gvm.io[nxs].co.x.cpureset = 1; break; } gvm.io[nxs].co.x.cputtime = ttime; if( gvm.io[nxs].gk.di_rt0tm1 == 0 ) strcpy( dits, dis ); else strcpy( dits, dts ); for(i=0;i<(14);i++){ if( dits[i] == (char)'0' ){ kcxobj_stat_iwt( gvm.io[nxs].gk.objid_di[i], 0 ); }else if( dits[i] == (char)'1' ){ kcxobj_stat_iwt( gvm.io[nxs].gk.objid_di[i], 1 ); } } for(i=0;i<(14);i++){ idata = (int)strtol( dc[i], (char **)NULL, 10 ); kcxobj_stat_iwt( gvm.io[nxs].gk.objid_pi[i], idata ); } for(i=0;i<(8);i++){ if( dos[i] == (char)'0' ){ kcxobj_stat_iwt( gvm.io[nxs].gk.objid_do[i], 0 ); }else if( dos[i] == (char)'1' ){ kcxobj_stat_iwt( gvm.io[nxs].gk.objid_do[i], 1 ); } } for(i=0;i<(8);i++){ if( gvm.io[nxs].gk.objid_ai[i] < 0 ) continue; kcxobj_atbut_ird( gvm.io[nxs].gk.objid_ai[i], (6), &scalemode ); if( scalemode == 1 ){ kcxobj_atbut_frd( gvm.io[nxs].gk.objid_ai[i], (1), &Af ); kcxobj_atbut_frd( gvm.io[nxs].gk.objid_ai[i], (2), &Bf ); kcxobj_atbut_frd( gvm.io[nxs].gk.objid_ai[i], (3), &Cf ); idata = (int)strtol( ai[i], (char **)NULL, 10 ); fdata2 = (double)idata / (double)65536; if( fabs((double)Af) < 0.00001 ) Af = 1.0; fdata = Af * ( fdata2 + Bf ) + Cf; }else{ kcxobj_scale2_frd( gvm.io[nxs].gk.objid_ai[i], 1/*IFC*/, &hi_fval, &low_fval ); idata = (int)strtol( ai[i], (char **)NULL, 10 ); fdata = (double)idata / (double)65536 * ( hi_fval - low_fval ) + low_fval; } kcxobj_stat_fwt( gvm.io[nxs].gk.objid_ai[i], fdata ); } for(i=0;i<(2);i++){ if( gvm.io[nxs].gk.objid_ao[i] < 0 ) continue; kcxobj_atbut_ird( gvm.io[nxs].gk.objid_ao[i], (6), &scalemode ); if( scalemode == 1 ){ kcxobj_atbut_frd( gvm.io[nxs].gk.objid_ao[i], (1), &Af ); kcxobj_atbut_frd( gvm.io[nxs].gk.objid_ao[i], (2), &Bf ); kcxobj_atbut_frd( gvm.io[nxs].gk.objid_ao[i], (3), &Cf ); idata = (int)strtol( ao[i], (char **)NULL, 10 ); fdata2 = (double)idata / (double)255; if( fabs((double)Af) < 0.00001 ) Af = 1.0; fdata = Af * ( fdata2 + Bf ) + Cf; }else{ kcxobj_scale2_frd( gvm.io[nxs].gk.objid_ao[i], 1/*IFC*/, &hi_fval, &low_fval ); idata = (int)strtol( ao[i], (char **)NULL, 10 ); fdata = (double)idata / (double)255 * ( hi_fval - low_fval ) + low_fval; } kcxobj_stat_fwt( gvm.io[nxs].gk.objid_ao[i], fdata ); } break; case ModelTK0040Atp: /* 1 2 3 4 1 2 3 4 5 6 1 1 2 3 4 5 6 1 2 1 2 3 1 2 */ sscanf( rcvbuff, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", fid,cmd,dis,dts, dc[0],dc[1],dc[2],dc[3],dc[4],dc[5], dos, ai[0],ai[1],ai[2],ai[3],ao[0],ao[1],pwm[0],pwm[1],pwm[2],msg1,ktime ); ttime = (time_t)strtol( ktime, (char **)NULL, 10 ); if( ttime < gvm.io[nxs].co.x.cputtime ){ gvm.io[nxs].co.x.cpureset = 1; break; } gvm.io[nxs].co.x.cputtime = ttime; if( gvm.io[nxs].tk.di_rt0tm1 == 0 ) strcpy( dits, dis ); else strcpy( dits, dts ); for(i=0;i<(6);i++){ if( dits[i] == (char)'0' ){ kcxobj_stat_iwt( gvm.io[nxs].tk.objid_di[i], 0 ); }else if( dits[i] == (char)'1' ){ kcxobj_stat_iwt( gvm.io[nxs].tk.objid_di[i], 1 ); } } for(i=0;i<(6);i++){ idata = (int)strtol( dc[i], (char **)NULL, 10 ); kcxobj_stat_iwt( gvm.io[nxs].tk.objid_pi[i], idata ); } for(i=0;i<(4);i++){ if( dos[i] == (char)'0' ){ kcxobj_stat_iwt( gvm.io[nxs].tk.objid_do[i], 0 ); }else if( dos[i] == (char)'1' ){ kcxobj_stat_iwt( gvm.io[nxs].tk.objid_do[i], 1 ); } } for(i=0;i<(4);i++){ if( gvm.io[nxs].tk.objid_ai[i] < 0 ) continue; kcxobj_atbut_ird( gvm.io[nxs].tk.objid_ai[i], (6), &scalemode ); if( scalemode == 1 ){ kcxobj_atbut_frd( gvm.io[nxs].tk.objid_ai[i], (1), &Af ); kcxobj_atbut_frd( gvm.io[nxs].tk.objid_ai[i], (2), &Bf ); kcxobj_atbut_frd( gvm.io[nxs].tk.objid_ai[i], (3), &Cf ); idata = (int)strtol( ai[i], (char **)NULL, 10 ); fdata2 = (double)idata / (double)1023; if( fabs((double)Af) < 0.00001 ) Af = 1.0; fdata = Af * ( fdata2 + Bf ) + Cf; }else{ kcxobj_scale2_frd( gvm.io[nxs].tk.objid_ai[i], 1/*IFC*/, &hi_fval, &low_fval ); idata = (int)strtol( ai[i], (char **)NULL, 10 ); fdata = (double)idata / (double)1023 * ( hi_fval - low_fval ) + low_fval; } kcxobj_stat_fwt( gvm.io[nxs].tk.objid_ai[i], fdata ); } for(i=0;i<(2);i++){ if( gvm.io[nxs].tk.objid_ao[i] < 0 ) continue; kcxobj_atbut_ird( gvm.io[nxs].tk.objid_ao[i], (6), &scalemode ); if( scalemode == 1 ){ kcxobj_atbut_frd( gvm.io[nxs].tk.objid_ao[i], (1), &Af ); kcxobj_atbut_frd( gvm.io[nxs].tk.objid_ao[i], (2), &Bf ); kcxobj_atbut_frd( gvm.io[nxs].tk.objid_ao[i], (3), &Cf ); idata = (int)strtol( ao[i], (char **)NULL, 10 ); fdata2 = (double)idata / (double)256; if( fabs((double)Af) < 0.00001 ) Af = 1.0; fdata = Af * ( fdata2 + Bf ) + Cf; }else{ kcxobj_scale2_frd( gvm.io[nxs].tk.objid_ao[i], 1/*IFC*/, &hi_fval, &low_fval ); idata = (int)strtol( ao[i], (char **)NULL, 10 ); fdata = (double)idata / (double)256 * ( hi_fval - low_fval ) + low_fval; } kcxobj_stat_fwt( gvm.io[nxs].tk.objid_ao[i], fdata ); } /* Pwm1ch2chはAo1ch2ch連動、3chのみ計測値直書込*/ for(i=0;i<(3);i++){ if( gvm.io[nxs].tk.objid_ao[i] < 0 ) continue; if( i == (2) ){ fdata = (double)strtol( pwm[i], (char **)NULL, 10 ) * 0.01; /*(%表示)*/ kcxobj_stat_fwt( gvm.io[nxs].tk.objid_ao[i], fdata ); } } break; case ModelIOB30RTAtp: switch( optiontype ){ case HLOtp: sscanf( rcvbuff, "%s%s%s%s%s", fid,cmd,etc1,etc2,ktime ); if( strcmp( cmd, "IOB30RTA" ) != 0 ) break; ttime = (time_t)strtol( ktime, (char **)NULL, 10 ); if( ttime < gvm.io[nxs].co.x.cputtime ){ gvm.io[nxs].co.x.cpureset = 1; break; } gvm.io[nxs].co.x.cputtime = ttime; break; case DIOtp: sscanf( rcvbuff, "%s%s%s%s", fid,cmd,dis,dos ); if( strcmp( cmd, "BIN" ) != 0 ) break; for(i=0;i<(4);i++){ if( dis[i] == (char)'0' ){ kcxobj_stat_iwt( gvm.io[nxs].rt.objid_di[i], 0 ); }else if( dis[i] == (char)'1' ){ kcxobj_stat_iwt( gvm.io[nxs].rt.objid_di[i], 1 ); } } for(i=0;i<(4);i++){ if( dos[i] == (char)'0' ){ kcxobj_stat_iwt( gvm.io[nxs].rt.objid_do[i], 0 ); }else if( dos[i] == (char)'1' ){ kcxobj_stat_iwt( gvm.io[nxs].rt.objid_do[i], 1 ); } } break; case AIOtp: sscanf( rcvbuff, "%s%s%s%s%s%s%s%s%s%s", fid,cmd,ai[0],ai[1],ai[2],ai[3],ai[4],ai[5],ai[6],ai[7] ); if( strcmp( cmd, "AIN" ) != 0 ) break; for(i=0;i<(8);i++){ if( gvm.io[nxs].rt.objid_ai[i] < 0 ) continue; kcxobj_atbut_ird( gvm.io[nxs].rt.objid_ai[i], (6), &scalemode ); if( scalemode == 1 ){ kcxobj_atbut_frd( gvm.io[nxs].rt.objid_ai[i], (1), &Af ); kcxobj_atbut_frd( gvm.io[nxs].rt.objid_ai[i], (2), &Bf ); kcxobj_atbut_frd( gvm.io[nxs].rt.objid_ai[i], (3), &Cf ); idata = (int)strtol( ai[i], (char **)NULL, 10 ); if( gvm.io[nxs].rt.analog_rate < 0 ) idata += 32768; fdata2 = (double)idata / (double)65536; if( fabs((double)Af) < 0.00001 ) Af = 1.0; fdata = Af * ( fdata2 + Bf ) + Cf; }else{ kcxobj_scale2_frd( gvm.io[nxs].rt.objid_ai[i], 1/*IFC*/, &hi_fval, &low_fval ); idata = (int)strtol( ai[i], (char **)NULL, 10 ); if( gvm.io[nxs].rt.analog_rate < 0 ) idata += 32768; fdata = (double)idata / (double)65536 * ( hi_fval - low_fval ) + low_fval; } kcxobj_stat_fwt( gvm.io[nxs].rt.objid_ai[i], fdata ); } break; } break; default: break; } return 1; } void raspi_errorlog( char *text ) { int Ev_KEY,Ev_STAT; KcxIntFlt_t udata10[10]; kcxstr_text_to_udata10( 0,text,"",udata10 ); Ev_KEY = 312; Ev_STAT = 1; kcxobj_alm_log_10uwt( svm.sys_objid, Ev_KEY, Ev_STAT, udata10 ); } void init_raspi_gpio( int ch, int direction ) { int i,fd,N; char stext [128]; char stext2[128]; //1)ToEnableSet sprintf( stext, "%d", ch ); if((fd=open("/sys/class/gpio/unexport",O_WRONLY)) >= 0 ){ write(fd,stext,2); //port unenable close(fd); } for(i=0,N=100;i= 0) break; usleep((useconds_t)1000); system( "sudo chmod a+w /sys/class/gpio/export" ); } if( i == N ){ raspi_errorlog( "raspi gpio-export-open err." ); gvm.raspinit_error += 1; return; } write(fd,stext,2); //port enable close(fd); //2)DirectionSet sprintf( stext, "/sys/class/gpio/gpio%d/direction", ch ); for(i=0,N=100;i= 0) break; usleep((useconds_t)1000); sprintf( stext2, "sudo chmod a+w %s", stext ); system ( stext2 ); } if( i == N ){ raspi_errorlog( "raspi gpio-direct-open err." ); gvm.raspinit_error += 1; return; } switch(direction){ case KcxRASPI_PORT_IN: write(fd,"in",3); break; case KcxRASPI_PORT_OUT: write(fd,"out",4); break; } close(fd); } int read_raspi_gpio( int ch ) { int i,fd,N; char stext [128]; char stext2[128]; char cdata [4]; if( gvm.raspinit_error > 0 ){ usleep((useconds_t)1000); return 0; } sprintf( stext, "/sys/class/gpio/gpio%d/value", ch ); for(i=0,N=100;i= 0) break; usleep((useconds_t)1000); sprintf( stext2, "sudo chmod a+r %s", stext ); system ( stext2 ); } if( i == N ){ raspi_errorlog( "raspi gpio-value-open err." ); sleep(1); return 0; } read(fd,cdata,2); close(fd); if( cdata[0] == (char)'1' ) return 1; else return 0; } void write_raspi_gpio( int ch, int data ) { int i,fd,N; char stext [128]; char stext2[128]; if( gvm.raspinit_error > 0 ){ usleep((useconds_t)1000); return 0; } sprintf( stext, "/sys/class/gpio/gpio%d/value", ch ); for(i=0,N=100;i= 0) break; usleep((useconds_t)1000); sprintf( stext2, "sudo chmod a+w %s", stext ); system ( stext2 ); } if( i == N ){ raspi_errorlog( "raspi gpio-value-open err." ); sleep(1); return; } switch(data){ case 0: write(fd,"0",2); break; case 1: default: write(fd,"1",2); break; } close(fd); } raspberrypi_din( int ch ) { int k = 0; switch(ch){ case 1: k = read_raspi_gpio( KcxRASPORT_Di_1 ); break; case 2: k = read_raspi_gpio( KcxRASPORT_Di_2 ); break; case 3: k = read_raspi_gpio( KcxRASPORT_Di_3 ); break; case 4: k = read_raspi_gpio( KcxRASPORT_Di_4 ); break; default: break; } if( k == 0 ) return 1; else return 0; } raspberrypi_dout( int ch, int idata ) { void write_raspi_gpio(int ch,int data); switch(ch){ case 1: write_raspi_gpio( KcxRASPORT_Do_1, idata ); break; case 2: write_raspi_gpio( KcxRASPORT_Do_2, idata ); break; case 3: write_raspi_gpio( KcxRASPORT_Do_3, idata ); break; case 4: write_raspi_gpio( KcxRASPORT_Do_4, idata ); break; case 5: write_raspi_gpio( KcxRASPORT_Do_5, idata ); break; case 6: write_raspi_gpio( KcxRASPORT_Do_6, idata ); break; default: break; } } kcxadc_raspi_reset() { int i,cmd; write_raspi_gpio(KcxRASPORT_AD_cs, 1); write_raspi_gpio(KcxRASPORT_AD_sclk,0); /*1)ChipReset*/ usleep(5000); cmd = 0x00C8; /*ManualTable8*/ write_raspi_gpio(KcxRASPORT_AD_cs, 0); for(i=0;i<(8);i++){ write_raspi_gpio(KcxRASPORT_AD_din, (cmd & (0x80>>i))); write_raspi_gpio(KcxRASPORT_AD_sclk, 1); write_raspi_gpio(KcxRASPORT_AD_sclk, 0); } write_raspi_gpio(KcxRASPORT_AD_cs, 1); write_raspi_gpio(KcxRASPORT_AD_sclk,0); /*2)InternalClock(Mode2)*/ usleep(5000); cmd = 0x00A8; /*ManualTable8*/ write_raspi_gpio(KcxRASPORT_AD_cs, 0); for(i=0;i<(8);i++){ write_raspi_gpio(KcxRASPORT_AD_din, (cmd & (0x80>>i))); write_raspi_gpio(KcxRASPORT_AD_sclk, 1); write_raspi_gpio(KcxRASPORT_AD_sclk, 0); } write_raspi_gpio(KcxRASPORT_AD_cs, 1); write_raspi_gpio(KcxRASPORT_AD_sclk,0); } kcxadc_raspi_rangeset( int ch, int range ) { int i,_maximch,cmd,range_R210; switch( range ){ case 4: range_R210 = 0x07; break; /* +-12v */ case 3: range_R210 = 0x04; break; /* +- 6v */ case 2: range_R210 = 0x01; break; /* +- 3v */ case 1: range_R210 = 0x06; break; /* + 12v */ case 0: default: range_R210 = 0x03; break; /* + 6v */ } switch( ch ){ case 0: _maximch = 0; break; case 1: _maximch = 1; break; case 2: _maximch = 2; break; case 3: _maximch = 3; break; default: _maximch = 3; break; } cmd = ( _maximch << 4 ) | range_R210 | 0x80; write_raspi_gpio(KcxRASPORT_AD_cs, 0); for(i=0;i<(8);i++){ write_raspi_gpio(KcxRASPORT_AD_din, (cmd & (0x80>>i))); write_raspi_gpio(KcxRASPORT_AD_sclk, 1); write_raspi_gpio(KcxRASPORT_AD_sclk, 0); } write_raspi_gpio(KcxRASPORT_AD_cs, 1); write_raspi_gpio(KcxRASPORT_AD_sclk,0); } #define RasPiAdcSSTRBCNTs (100) #define RasPiAdvalAVRs (5) kcxadc_raspi_getdata( long ad_data[] ) { int i,j,ch,_maximch,cmd; int getval,add_data; int adc_error; long ldata; static long ad_val_statck[4][RasPiAdvalAVRs]; static int crntP = 0; static int init = 0; if( init == 0 ){ for(i=0;i<(4);i++){ for(j=0;j>i))); write_raspi_gpio(KcxRASPORT_AD_sclk, 1); write_raspi_gpio(KcxRASPORT_AD_sclk, 0); } write_raspi_gpio(KcxRASPORT_AD_cs, 1); for(i=0;i 0 ) break; usleep((useconds_t)1000); } if( i == RasPiAdcSSTRBCNTs ){ adc_error = 1; } write_raspi_gpio(KcxRASPORT_AD_cs, 0); getval = 0; for(i=0;i<(16);i++){ write_raspi_gpio(KcxRASPORT_AD_sclk, 1); if( read_raspi_gpio( KcxRASPORT_AD_dout ) > 0 ) add_data = 1; else add_data = 0; getval = (getval<<1) | add_data; write_raspi_gpio(KcxRASPORT_AD_sclk, 0); } write_raspi_gpio(KcxRASPORT_AD_cs, 1); write_raspi_gpio(KcxRASPORT_AD_din,0); ad_val_statck[ch][crntP] = getval; ldata = 0; for(i=0;i= RasPiAdvalAVRs ) crntP = 0; if( adc_error == 1 ){ kcxadc_raspi_init(); } } // chmod u+s a.out // chown root:root a.out shutdown_raspi_etccmd( int mode ) { int pid,err; char execv_program_fpfname[256]; char *execv_argv[8]; switch( mode ){ case 0: strcpy( execv_program_fpfname, "/usr/bin/sudo" ); execv_argv[0] = "sudo"; execv_argv[1] = "reboot"; execv_argv[2] = 0; break; case 1: strcpy( execv_program_fpfname, "/usr/bin/sudo" ); execv_argv[0] = "sudo"; execv_argv[1] = "shutdown"; execv_argv[2] = "-h"; execv_argv[3] = "now"; execv_argv[4] = 0; } if((pid=fork()) == 0){ err = execv( execv_program_fpfname, execv_argv ); } } kcxadc_raspi_init() { kcxadc_raspi_reset(); kcxadc_raspi_rangeset(0,0); kcxadc_raspi_rangeset(1,0); kcxadc_raspi_rangeset(2,0); kcxadc_raspi_rangeset(3,0); } kcxinit_raspberrypi() { int i; init_raspi_gpio( KcxRASPORT_Di_1, KcxRASPI_PORT_IN ); init_raspi_gpio( KcxRASPORT_Di_2, KcxRASPI_PORT_IN ); init_raspi_gpio( KcxRASPORT_Di_3, KcxRASPI_PORT_IN ); init_raspi_gpio( KcxRASPORT_Di_4, KcxRASPI_PORT_IN ); init_raspi_gpio( KcxRASPORT_Do_1, KcxRASPI_PORT_OUT ); init_raspi_gpio( KcxRASPORT_Do_2, KcxRASPI_PORT_OUT ); init_raspi_gpio( KcxRASPORT_Do_3, KcxRASPI_PORT_OUT ); init_raspi_gpio( KcxRASPORT_Do_4, KcxRASPI_PORT_OUT ); init_raspi_gpio( KcxRASPORT_Do_5, KcxRASPI_PORT_OUT ); init_raspi_gpio( KcxRASPORT_Do_6, KcxRASPI_PORT_OUT ); init_raspi_gpio( KcxRASPORT_AD_din, KcxRASPI_PORT_OUT ); init_raspi_gpio( KcxRASPORT_AD_cs, KcxRASPI_PORT_OUT ); init_raspi_gpio( KcxRASPORT_AD_sclk, KcxRASPI_PORT_OUT ); init_raspi_gpio( KcxRASPORT_AD_dout, KcxRASPI_PORT_IN ); init_raspi_gpio( KcxRASPORT_AD_sstrb, KcxRASPI_PORT_IN ); init_raspi_gpio( KcxRASPORT_AiCMP, KcxRASPI_PORT_IN ); init_raspi_gpio( KcxRASPORT_WdtPulse, KcxRASPI_PORT_OUT ); for(i=0;i<(6);i++){ raspberrypi_dout( 1 + i, 0 ); // all OFF } kcxadc_raspi_init(); } #define RasPiDataSaveIntvalSEC (60*60) /* 1 hour */ raspi_pi_datasave_rw( int mode /*read:0,write=1*/, int ch, int idata, char objidname[] ) { FILE *fdp; int i,wtflag,idata2; char filename[512]; char strbuff [512]; time_t ttime; static time_t save_ttime[RASPBERRYx_PIs]; static int init = 0; if( init == 0 ){ time( &ttime ); for(i=0;i= RasPiDataSaveIntvalSEC ){ wtflag = 1; } if( wtflag == 1 ){ if(( fdp = fopen( filename, "w" )) != NULL ){ sprintf( strbuff, "%d", idata ); fputs( strbuff, fdp ); fclose( fdp ); } save_ttime[ch] = ttime; } return 0; } } #define RasPiAiCOMPTIMEs (7) /*約2秒 at 300 msleep*/ raspberrypi_mix_input( int nxs, char statustext[] ) { int i,k,scalemode,idata,idata2; double fdata,fdata2,smfval,Af,Bf,Cf; double hi_fval,low_fval; char text[64]; int di_crnt[RASPBERRYx_DIs]; long ai_ldata[RASPBERRYx_AIs]; static int aicomptimep; static int aicomptime[RasPiAiCOMPTIMEs]; static int alt = 0; static int init = 0; if( init == 0 ){ aicomptimep = 0; for(i=0;i= RasPiAiCOMPTIMEs ) aicomptimep = 0; k = 1; for(i=0;i idata2 ) idata = 0; kcxobj_stat_iwt( gvm.io[nxs].rs1.objid_pi[i], idata ); raspi_pi_datasave_rw( 1/*write*/, i, idata, gvm.io[nxs].rs1.objidname_pi[i] ); } }else{ //nothing } gvm.io[nxs].rs1.last_di[i] = di_crnt[i]; kcxobj_stat_ird( gvm.io[nxs].rs1.objid_pi[i], &idata ); sprintf( text, " %d", idata ); strcat ( statustext, text ); } strcat( statustext, " " ); for(i=0;i<(4);i++){ if( gvm.io[nxs].rs1.objid_do[i] < 0 ){ strcat( statustext, "-" ); continue; } if( gvm.io[nxs].rs1.do_stat[i] == 0 ){ strcat( statustext, "0" ); }else{ strcat( statustext, "1" ); } } kcxadc_raspi_getdata( ai_ldata ); for(i=0;i<(4);i++){ if( gvm.io[nxs].rs1.objid_ai[i] < 0 ){ strcat( statustext, " -" ); continue; } strcat ( statustext, " " ); sprintf( text, "%d", ai_ldata[i] ); strcat ( statustext, text ); kcxobj_atbut_ird( gvm.io[nxs].rs1.objid_ai[i], (6), &scalemode ); if( scalemode == 1 ){ kcxobj_atbut_frd( gvm.io[nxs].rs1.objid_ai[i], (1), &Af ); kcxobj_atbut_frd( gvm.io[nxs].rs1.objid_ai[i], (2), &Bf ); kcxobj_atbut_frd( gvm.io[nxs].rs1.objid_ai[i], (3), &Cf ); idata = ai_ldata[i]; fdata2 = (double)idata / (double)65535; if( fabs((double)Af) < 0.00001 ) Af = 1.0; fdata = Af * ( fdata2 + Bf ) + Cf; }else{ kcxobj_scale2_frd( gvm.io[nxs].rs1.objid_ai[i], 1/*IFC*/, &hi_fval, &low_fval ); idata = ai_ldata[i]; fdata = (double)idata / (double)65535 * ( hi_fval - low_fval ) + low_fval; } kcxobj_stat_fwt( gvm.io[nxs].rs1.objid_ai[i], fdata ); } break; default: break; } return 1; } netbox_do_do2_output_send( objid, idata ) int objid; int idata; { int nxs,j,rtnlen,retrys; char doutcmd[BUFSIZ]; char sndbuff[BUFSIZ]; char rcvbuff[BUFSIZ]; char chksum [BUFSIZ]; static int seq = 0; if( ++seq > 9999 ) seq = 1; for(nxs=0;nxs 0) sprintf( sndbuff, "%04d dout 1-------", seq ); else sprintf( sndbuff, "%04d dout 0-------", seq ); break; case 1: if(idata > 0) sprintf( sndbuff, "%04d dout -1------", seq ); else sprintf( sndbuff, "%04d dout -0------", seq ); break; case 2: if(idata > 0) sprintf( sndbuff, "%04d dout --1-----", seq ); else sprintf( sndbuff, "%04d dout --0-----", seq ); break; case 3: if(idata > 0) sprintf( sndbuff, "%04d dout ---1----", seq ); else sprintf( sndbuff, "%04d dout ---0----", seq ); break; case 4: if(idata > 0) sprintf( sndbuff, "%04d dout ----1---", seq ); else sprintf( sndbuff, "%04d dout ----0---", seq ); break; case 5: if(idata > 0) sprintf( sndbuff, "%04d dout -----1--", seq ); else sprintf( sndbuff, "%04d dout -----0--", seq ); break; case 6: if(idata > 0) sprintf( sndbuff, "%04d dout ------1-", seq ); else sprintf( sndbuff, "%04d dout ------0-", seq ); break; case 7: if(idata > 0) sprintf( sndbuff, "%04d dout -------1", seq ); else sprintf( sndbuff, "%04d dout -------0", seq ); break; default: strcpy( sndbuff, "" ); break; } rtnlen = netbox_sync_com( nxs,sndbuff,strlen(sndbuff),rcvbuff,sizeof(rcvbuff) ); if( rtnlen > 0 ) return (1); else return (-1); } } for(j=0;j 0) sprintf( sndbuff, "%04d dout2 1-", seq ); else sprintf( sndbuff, "%04d dout2 0-", seq ); break; case 1: if(idata > 0) sprintf( sndbuff, "%04d dout2 -1", seq ); else sprintf( sndbuff, "%04d dout2 -0", seq ); break; default: strcpy( sndbuff, "" ); break; } rtnlen = netbox_sync_com( nxs,sndbuff,strlen(sndbuff),rcvbuff,sizeof(rcvbuff) ); if( rtnlen > 0 ) return (1); else return (-1); } } break; case ModelAK0822Atp: for(j=0;j 0) sprintf( sndbuff, "%04d dout2 1-", seq ); else sprintf( sndbuff, "%04d dout2 0-", seq ); break; case 1: if(idata > 0) sprintf( sndbuff, "%04d dout2 -1", seq ); else sprintf( sndbuff, "%04d dout2 -0", seq ); break; default: strcpy( sndbuff, "" ); break; } rtnlen = netbox_sync_com( nxs,sndbuff,strlen(sndbuff),rcvbuff,sizeof(rcvbuff) ); if( rtnlen > 0 ) return (1); else return (-1); } } break; case ModelAK0620Atp: for(j=0;j 0) sprintf( sndbuff, "%04d dout 1-", seq ); else sprintf( sndbuff, "%04d dout 0-", seq ); break; case 1: if(idata > 0) sprintf( sndbuff, "%04d dout -1", seq ); else sprintf( sndbuff, "%04d dout -0", seq ); break; default: strcpy( sndbuff, "" ); break; } rtnlen = netbox_sync_com( nxs,sndbuff,strlen(sndbuff),rcvbuff,sizeof(rcvbuff) ); if( rtnlen > 0 ) return (1); else return (-1); } } break; case ModelGK0580Atp: for(j=0;j 0) sprintf( sndbuff, "%04d dout 1-------", seq ); else sprintf( sndbuff, "%04d dout 0-------", seq ); break; case 1: if(idata > 0) sprintf( sndbuff, "%04d dout -1------", seq ); else sprintf( sndbuff, "%04d dout -0------", seq ); break; case 2: if(idata > 0) sprintf( sndbuff, "%04d dout --1-----", seq ); else sprintf( sndbuff, "%04d dout --0-----", seq ); break; case 3: if(idata > 0) sprintf( sndbuff, "%04d dout ---1----", seq ); else sprintf( sndbuff, "%04d dout ---0----", seq ); break; case 4: if(idata > 0) sprintf( sndbuff, "%04d dout ----1---", seq ); else sprintf( sndbuff, "%04d dout ----0---", seq ); break; case 5: if(idata > 0) sprintf( sndbuff, "%04d dout -----1--", seq ); else sprintf( sndbuff, "%04d dout -----0--", seq ); break; case 6: if(idata > 0) sprintf( sndbuff, "%04d dout ------1-", seq ); else sprintf( sndbuff, "%04d dout ------0-", seq ); break; case 7: if(idata > 0) sprintf( sndbuff, "%04d dout -------1", seq ); else sprintf( sndbuff, "%04d dout -------0", seq ); break; default: strcpy( sndbuff, "" ); break; } rtnlen = netbox_sync_com( nxs,sndbuff,strlen(sndbuff),rcvbuff,sizeof(rcvbuff) ); if( rtnlen > 0 ) return (1); else return (-1); } } break; case ModelTK0040Atp: for(j=0;j 0) sprintf( sndbuff, "%04d dout 1---", seq ); else sprintf( sndbuff, "%04d dout 0---", seq ); break; case 1: if(idata > 0) sprintf( sndbuff, "%04d dout -1--", seq ); else sprintf( sndbuff, "%04d dout -0--", seq ); break; case 2: if(idata > 0) sprintf( sndbuff, "%04d dout --1-", seq ); else sprintf( sndbuff, "%04d dout --0-", seq ); break; case 3: if(idata > 0) sprintf( sndbuff, "%04d dout ---1", seq ); else sprintf( sndbuff, "%04d dout ---0", seq ); break; default: strcpy( sndbuff, "" ); break; } rtnlen = netbox_sync_com( nxs,sndbuff,strlen(sndbuff),rcvbuff,sizeof(rcvbuff) ); if( rtnlen > 0 ) return (1); else return (-1); } } break; case ModelIOB30RTAtp: for(j=0;j 0) sprintf( sndbuff, "%04d bout 1---", seq ); else sprintf( sndbuff, "%04d bout 0---", seq ); break; case 1: if(idata > 0) sprintf( sndbuff, "%04d bout -1--", seq ); else sprintf( sndbuff, "%04d bout -0--", seq ); break; case 2: if(idata > 0) sprintf( sndbuff, "%04d bout --1-", seq ); else sprintf( sndbuff, "%04d bout --0-", seq ); break; case 3: if(idata > 0) sprintf( sndbuff, "%04d bout ---1", seq ); else sprintf( sndbuff, "%04d bout ---0", seq ); break; default: strcpy( sndbuff, "" ); break; } rtnlen = netbox_sync_com( nxs,sndbuff,strlen(sndbuff),rcvbuff,sizeof(rcvbuff) ); if( rtnlen > 0 ) return (1); else return (-1); } } break; case ModelRASPBERRYtp: for(j=0;j 9999 ) seq = 1; for(nxs=0;nxs shi_fval ) fdata = shi_fval; if( fdata < slow_fval ) fdata = slow_fval; daval = (int)( 256.0 * (( fdata - ilow_fval ) / ( ihi_fval - ilow_fval ))); if( daval <= 0 ) daval = 0; if( daval >= 255 ) daval = 255; switch( gvm.io[nxs].ak1.ch_ao[j] ){ case 0: sprintf( sndbuff, "%04d aout %d -1", seq, daval ); break; case 1: sprintf( sndbuff, "%04d aout -1 %d", seq, daval ); break; default: strcpy( sndbuff, "" ); break; } rtnlen = netbox_sync_com( nxs,sndbuff,strlen(sndbuff),rcvbuff,sizeof(rcvbuff) ); if( rtnlen > 0 ) return (1); else return (-1); } } for(j=0;j shi_fval ) fdata = shi_fval; if( fdata < slow_fval ) fdata = slow_fval; daval = (int)( 4096.0 * (( fdata - ilow_fval ) / ( ihi_fval - ilow_fval ))); if( daval <= 0 ) daval = 0; if( daval >= 4095 ) daval = 4095; switch( gvm.io[nxs].ak2.ch_ao[j] ){ case 0: sprintf( sndbuff, "%04d aout %d -1", seq, daval ); break; case 1: sprintf( sndbuff, "%04d aout -1 %d", seq, daval ); break; default: strcpy( sndbuff, "" ); break; } rtnlen = netbox_sync_com( nxs,sndbuff,strlen(sndbuff),rcvbuff,sizeof(rcvbuff) ); if( rtnlen > 0 ) return (1); else return (-1); } } for(j=0;j shi_fval ) fdata = shi_fval; if( fdata < slow_fval ) fdata = slow_fval; daval = (int)( 256.0 * (( fdata - ilow_fval ) / ( ihi_fval - ilow_fval ))); if( daval <= 0 ) daval = 0; if( daval >= 255 ) daval = 255; switch( gvm.io[nxs].gk.ch_ao[j] ){ case 0: sprintf( sndbuff, "%04d aout %d -1", seq, daval ); break; case 1: sprintf( sndbuff, "%04d aout -1 %d", seq, daval ); break; default: strcpy( sndbuff, "" ); break; } rtnlen = netbox_sync_com( nxs,sndbuff,strlen(sndbuff),rcvbuff,sizeof(rcvbuff) ); if( rtnlen > 0 ) return (1); else return (-1); } } for(j=0;j shi_fval ) fdata = shi_fval; if( fdata < slow_fval ) fdata = slow_fval; daval = (int)( 256.0 * (( fdata - ilow_fval ) / ( ihi_fval - ilow_fval ))); if( daval <= 0 ) daval = 0; if( daval >= 255 ) daval = 255; switch( gvm.io[nxs].tk.ch_ao[j] ){ case 0: sprintf( sndbuff, "%04d aout %d -1", seq, daval ); break; case 1: sprintf( sndbuff, "%04d aout -1 %d", seq, daval ); break; case 2: default: /* 実在せず(TK0040AのAO出力数は2までです) */ sndbuff[0] = (char)0; break; } if( sndbuff[0] != (char)0 ){ rtnlen = netbox_sync_com( nxs,sndbuff,strlen(sndbuff),rcvbuff,sizeof(rcvbuff) ); if( rtnlen <= 0 ) return (-1); } /* AO→PWM同時出力(ここから) */ if( ++seq > 9999 ) seq = 1; pwmval = (int)( 10000.0 * (( fdata - ilow_fval ) / ( ihi_fval - ilow_fval ))); if( pwmval <= 0 ) daval = 0; if( pwmval >= 10000 ) daval = 10000; switch( gvm.io[nxs].tk.ch_ao[j] ){ case 0: sprintf( sndbuff, "%04d pwmout %d -1 -1", seq, pwmval ); break; case 1: sprintf( sndbuff, "%04d pwmout -1 %d -1", seq, pwmval ); break; case 2: sprintf( sndbuff, "%04d pwmout -1 -1 %d", seq, pwmval ); break; default: strcpy( sndbuff, "" ); break; } rtnlen = netbox_sync_com( nxs,sndbuff,strlen(sndbuff),rcvbuff,sizeof(rcvbuff) ); /* AO→PWM同時出力(ここ迄) */ if( rtnlen > 0 ) return (1); else return (-1); } } }/*for(i)*/ return 0; } karacrixbox_com( sockid,sndaddr,rcvaddr,sndbuff,sndlen,rcvbuff,rcvlen,timeoutsec ) int sockid; struct sockaddr *sndaddr; struct sockaddr *rcvaddr; char sndbuff[]; int sndlen; char rcvbuff[]; int rcvlen; int timeoutsec; { int i,len,fds,addrlen; fd_set fdset; struct timeval tm; fds = 1 + sockid; for(i=0;i<1000;i++){ FD_ZERO( &fdset ); FD_SET ( sockid, &fdset ); tm.tv_sec = (0); tm.tv_usec = (0); if( select( fds,&fdset,(fd_set *)NULL,(fd_set *)NULL,&tm ) <= 0 ){ break; } addrlen = sizeof(struct sockaddr); recvfrom( sockid,(void *)rcvbuff,rcvlen,0,rcvaddr,&addrlen ); } FD_ZERO( &fdset ); FD_SET ( sockid, &fdset ); tm.tv_sec = (1); tm.tv_usec = (0); if( select( fds,(fd_set *)NULL,&fdset,(fd_set *)NULL,&tm ) <= 0 ){ /*perror("sendto-select");*/ return 0; /*失敗終了*/ } addrlen = sizeof(struct sockaddr); sendto( sockid,(void *)sndbuff,sndlen,0,sndaddr,addrlen ); FD_ZERO( &fdset ); FD_SET ( sockid, &fdset ); tm.tv_sec = timeoutsec; tm.tv_usec = (0); if( select( fds,&fdset,(fd_set *)NULL,(fd_set *)NULL,&tm ) <= 0 ){ /*perror("recvform-select");*/ return 0; /*失敗終了*/ } addrlen = sizeof(struct sockaddr); if(( len = recvfrom( sockid,(void *)rcvbuff,rcvlen,0,rcvaddr,&addrlen )) < 0 ){ /*perror("recvfrom");*/ exit(1); /*異常終了*/ } return len; /*正常終了*/ } netbox_sync_com( nxs, sndbuff, sndlen, rcvbuff, rcvlen ) int nxs; char sndbuff[]; /* 送信データバッファ */ int sndlen; /* 送信データ長 */ char rcvbuff[]; /* 受信データバッファ */ int rcvlen; /* 受信データバッファ長 */ { time_t ttime; int len,retry,retrys,error; int tout_sec, tout_usec; char snd_frameidname[BUFSIZ]; char rcv_frameidname[BUFSIZ]; int Ev_KEY; int Ev_STAT; KcxIntFlt_t udata10[10]; retrys = LAN_COMMANDRETRYs; tout_sec = LAN_RCVTOUTSECs; tout_usec = LAN_RCVTOUTUSECs; if( gvm.io[nxs].co.x.net_error > 0 ) retrys = (1); /*エラー中に付き1回*/ if( gvm.io[nxs].co.x.net_error_ttime > 0 ){ time( &ttime ); if( ( ttime - gvm.io[nxs].co.x.net_error_ttime ) > LAN_ERRORRETRYSECs ){ /* 実行 */ tout_sec = LAN_RCVTOUTSEC_ERR; tout_usec = LAN_RCVTOUTUSEC_ERR; }else{ return 0; } } sscanf( sndbuff, "%s", snd_frameidname ); for( retry = 0; retry < retrys; retry ++ ){ rcv_frameidname[0] = (char)0; rcvbuff [0] = (char)0; len = karacrixbox_com( svm.sockid,&gvm.io[nxs].co.x.sndaddr,&svm.rcvaddr, sndbuff,sndlen,rcvbuff,rcvlen,tout_sec ); if( len <= 0 ){ kcxtim_tsleep( 50000 ); continue; } rcvbuff[len] = (char)0; sscanf( rcvbuff, "%s", rcv_frameidname ); /* 送受信フレームIDの確認 */ if( strcmp( snd_frameidname, rcv_frameidname ) == 0 ){ /* 正常受信データ長 */ if( gvm.io[nxs].co.x.run == 0 ){ /* 通信開始 */ kcxstr_text_to_udata10( 0, gvm.io[nxs].co.x.ipaddress, "", udata10 ); Ev_KEY = 100; Ev_STAT = 1; kcxobj_ope_log_10uwt( svm.sys_objid, Ev_KEY, Ev_STAT, udata10 ); gvm.io[nxs].co.x.run = (1); } error = gvm.io[nxs].co.x.net_error; if( error != 0 ){ /* 通信復帰 */ kcxstr_text_to_udata10( 0, gvm.io[nxs].co.x.ipaddress, "", udata10 ); Ev_KEY = 101; Ev_STAT = 2; kcxobj_alm_log_10uwt( svm.sys_objid, Ev_KEY, Ev_STAT, udata10 ); gvm.io[nxs].co.x.net_error_cos_flag ++; } gvm.io[nxs].co.x.net_error_ttime = 0; gvm.io[nxs].co.x.net_error = 0; return len; /*正常終了*/ }else{ kcxtim_tsleep( 10000 ); continue; } }/*for(retry)*/ error = gvm.io[nxs].co.x.net_error; if( error == 0 ){ /* エラーによる通信不通発生 */ kcxstr_text_to_udata10( 0, gvm.io[nxs].co.x.ipaddress, "", udata10 ); Ev_KEY = 101; Ev_STAT = 1; kcxobj_alm_log_10uwt( svm.sys_objid, Ev_KEY, Ev_STAT, udata10 ); gvm.io[nxs].co.x.net_error_cos_flag ++; } time( &ttime ); gvm.io[nxs].co.x.net_error_ttime = ttime; gvm.io[nxs].co.x.net_error = 1; return (0); /*失敗終了*/ } event_log_and_email_send( di_or_ai,nrm_or_alm,objid,onoff_event,ai_alm_level,aifval ) int di_or_ai; /* DIOtp,AIOtp */ int nrm_or_alm; /* NRMtp(DIO),ALMtp(DIO&AIO) */ int objid; int onoff_event; /* 0:OFF.or.AlmOFF, 1:ON.or.AlmON */ int ai_alm_level; double aifval; { int i,j,enable,perm,lock,level; int no,noa,unitcode,mins,flag; int point_objevkey_enable; int email_perm,sndflag; int Ev_KEY=0,Ev_STAT=0; double fdata,fhval,flval; char format [BUFSIZ]; char unitname [BUFSIZ]; char levelname [BUFSIZ]; char objidname [BUFSIZ]; char objtagname[BUFSIZ]; char objname [BUFSIZ]; KcxIntFlt_t udata10[10]; KcxObjCtlSX objdata; struct tm jikan; char text [BUFSIZ]; char text2[BUFSIZ]; char mailaddr[BUFSIZ]; char emailtitle[BUFSIZ]; int mtextbuffs; if( svm.idle > 0 ) return 0; point_objevkey_enable = (1); /*ポイント属性(履歴書式キー)有効*/ point_objevkey_enable = (0); /*本プログラム・ハードコード有効*/ mtextbuffs = (0); switch( di_or_ai ){ case DIOtp: memset((void *)udata10,0,sizeof(udata10)); if( nrm_or_alm == NRMtp ){ kcxobj_event_opelog_level_ird( objid, &level ); /*接点状態変化を操作履歴に追加する*/ switch( onoff_event ){ case 1: /*ON*/ switch( level ){ case 3: Ev_KEY = 13; Ev_STAT = 1; break; case 2: Ev_KEY = 12; Ev_STAT = 1; break; case 1: Ev_KEY = 11; Ev_STAT = 1; break; case 0: Ev_KEY = 10; Ev_STAT = 1; break; default: Ev_KEY = (-1); break; } break; case 0: /*OFF*/ default: switch( level ){ case 3: Ev_KEY = 13; Ev_STAT = 0; break; case 2: Ev_KEY = 12; Ev_STAT = 0; break; case 1: Ev_KEY = 11; Ev_STAT = 0; break; case 0: Ev_KEY = 10; Ev_STAT = 0; break; default: Ev_KEY = (-1); break; } break; } if( Ev_KEY >= 0 ){ kcxobj_ope_log_10uwt( objid, Ev_KEY, Ev_STAT, udata10 ); } return 0; /*通常ポイント時はこれで終り*/ }else{ /*接点ONのメッセージを警報履歴に追加する*/ kcxobj_alm_level_ird( objid, &level ); switch( onoff_event ){ case 1: /*ON*/ switch( level ){ case 3: Ev_KEY = 53; Ev_STAT = 1; break; case 2: Ev_KEY = 52; Ev_STAT = 1; break; case 1: Ev_KEY = 51; Ev_STAT = 1; break; case 0: Ev_KEY = 50; Ev_STAT = 1; break; default: Ev_KEY = (-1); break; } break; case 0: /*OFF*/ default: switch( level ){ case 3: Ev_KEY = 53; Ev_STAT = 0; break; case 2: Ev_KEY = 52; Ev_STAT = 0; break; case 1: Ev_KEY = 51; Ev_STAT = 0; break; case 0: Ev_KEY = 50; Ev_STAT = 0; break; default: Ev_KEY = (-1); break; } break; } if( point_objevkey_enable == 1 ){ /*ポイント属性(履歴書式キー)有効時:Ev_KEY値入換,Ev_STAT値維持*/ kcxobj_event_log_key_get( objid, -1, &Ev_KEY ); } if( Ev_KEY >= 0 ){ kcxobj_alm_log_10uwt( objid, Ev_KEY, Ev_STAT, udata10 ); } } kcxobj_event_email_perm_get( objid, (0), &email_perm ); /* メール許可を見る */ if( email_perm == 0 ) return 0; break; case AIOtp: /*アナログ入力警報のメッセージを警報履歴に追加する*/ memset((void *)udata10,0,sizeof(udata10)); switch( onoff_event ){ case 1: switch( ai_alm_level ){ case KcxAlm_H3: Ev_KEY = 33; Ev_STAT = 1; break; case KcxAlm_H2: Ev_KEY = 32; Ev_STAT = 1; break; case KcxAlm_H1: Ev_KEY = 31; Ev_STAT = 1; break; case KcxAlm_L3: Ev_KEY = 23; Ev_STAT = 1; break; case KcxAlm_L2: Ev_KEY = 22; Ev_STAT = 1; break; case KcxAlm_L1: default: Ev_KEY = 21; Ev_STAT = 1; break; } break; case 0: switch( ai_alm_level ){ case KcxAlm_H3: Ev_KEY = 33; Ev_STAT = 0; break; case KcxAlm_H2: Ev_KEY = 32; Ev_STAT = 0; break; case KcxAlm_H1: Ev_KEY = 31; Ev_STAT = 0; break; case KcxAlm_L3: Ev_KEY = 23; Ev_STAT = 0; break; case KcxAlm_L2: Ev_KEY = 22; Ev_STAT = 0; break; case KcxAlm_L1: default: Ev_KEY = 21; Ev_STAT = 0; break; } break; } if( point_objevkey_enable == 1 ){ /*ポイント属性(履歴書式キー)有効時:Ev_KEY値入換,Ev_STAT値維持*/ kcxobj_event_log_key_get( objid, ai_alm_level, &Ev_KEY ); } kcxobj_alm_ai_limit_frd( objid,(ai_alm_level),&enable,&perm,&fdata,&fhval,&flval ); udata10[0].f = aifval; udata10[1].f = flval; udata10[2].f = fhval; kcxobj_alm_log_10uwt( objid, Ev_KEY, Ev_STAT, udata10 ); kcxobj_event_email_perm_get( objid, ai_alm_level, &email_perm ); /* レベル別のメール許可を見る */ if( email_perm == 0 ) return 0; break; } /* メール送信許可(パラメータ) */ if( gvm.mailperm == 0 ) return 0; kcxtim_whattime( &jikan ); flag = 0; if( gvm.mailperm_time1 != 0 ) flag = 1; /*メール送信許可時間指定有り*/ if( gvm.mailperm_time2 != 0 ) flag = 1; /*メール送信許可時間指定有り*/ if( flag == 1 ){ mins = 60 * jikan.tm_hour + jikan.tm_min; perm = 0; if( gvm.mailperm_time2 > gvm.mailperm_time1 ){ if(( mins >= gvm.mailperm_time1 ) && ( mins <= gvm.mailperm_time2 ) ){ perm = 1; } }else{ if(( mins >= gvm.mailperm_time1 ) || ( mins <= gvm.mailperm_time2 ) ){ perm = 1; } } if( perm == 0 ){ return 0; } } /* メール送信許可(オブジェクト個々) */ switch( di_or_ai ){ case DIOtp: kcxobj_event_email_perm_get( objid, NULLi, &perm ); if( perm <= 0 ) return 0; break; case AIOtp: kcxobj_event_email_perm_get( objid, (ai_alm_level), &perm ); if( perm <= 0 ) return 0; break; } /* このプログラムでは、ロック(携帯等で動的設定可能)時メールを出さない */ kcxobj_lock_ird( objid, &lock ); /*kcxobj_lock_perm_ird()より変更:2012.10*/ if( lock >= 1 ) return 0; /* メールタイトル */ strcpy( emailtitle, "警報メールです" ); /* メール本文開始 */ /*共通メール装置名(パラメータ)追加*/ if( gvm.mailmessage0[0] != (char)0 ){ sprintf( text, "装置 = %s", gvm.mailmessage0 ); strcpy( svm.mtextbuff[mtextbuffs++], text ); } sprintf( text, "時間 = %d/%2d %02d:%02d:%02d", jikan.tm_mon,jikan.tm_mday,jikan.tm_hour,jikan.tm_min,jikan.tm_sec ); strcpy ( svm.mtextbuff[mtextbuffs++], text ); kcxobj_objidtagnames_get( objid, objidname, objtagname, objname ); sprintf( text, "OBJID= %s", objidname ); strcpy ( svm.mtextbuff[mtextbuffs++], text ); sprintf( text, "TAG = %s", objtagname ); strcpy ( svm.mtextbuff[mtextbuffs++], text ); sprintf( text, "名称 = %s", objname ); strcpy ( svm.mtextbuff[mtextbuffs++], text ); switch( di_or_ai ){ case DIOtp: kcxobj_alm_level_ird( objid, &level ); switch( level ){ case 3: strcpy( levelname, "[H]" ); break; case 2: strcpy( levelname, "[M]" ); break; case 1: strcpy( levelname, "[L]" ); break; default: strcpy( levelname, "" ); break; } if( onoff_event == 1 ){ sprintf( text, "警報 = 発生 %s", levelname ); }else{ sprintf( text, "警報 = 解除 %s", levelname ); } strcpy( svm.mtextbuff[mtextbuffs++], text ); break; case AIOtp: kcxobj_analog_format_get( objid, format ); if( format[0] == (char)0 ) strcpy( format, "%f" ); kcxobj_unit_query( objid, &unitcode, unitname ); if( unitname[0] == (char)0 ) strcpy( unitname, "-" ); switch( ai_alm_level ){ case KcxAlm_H3: case KcxAlm_L3: strcpy( levelname, "[H]" ); break; case KcxAlm_H2: case KcxAlm_L2: strcpy( levelname, "[M]" ); break; case KcxAlm_H1: case KcxAlm_L1: default: strcpy( levelname, "[L]" ); break; } if( onoff_event == 1 ){ switch( ai_alm_level ){ case KcxAlm_H3: case KcxAlm_H2: case KcxAlm_H1: sprintf( text, format, aifval ); sscanf ( text, "%s", text2 ); sprintf( text, "警報 = 上限%s/発生 ( %s %s )", levelname,text2,unitname ); break; case KcxAlm_L3: case KcxAlm_L2: case KcxAlm_L1: default: sprintf( text, format, aifval ); sscanf ( text, "%s", text2 ); sprintf( text, "警報 = 下限%s/発生 ( %s %s )", levelname,text2,unitname ); break; } }else{ switch( ai_alm_level ){ case KcxAlm_H3: case KcxAlm_H2: case KcxAlm_H1: sprintf( text, format, aifval ); sscanf ( text, "%s", text2 ); sprintf( text, "警報 = 上限%s/解除 ( %s %s )", levelname,text2,unitname ); break; case KcxAlm_L3: case KcxAlm_L2: case KcxAlm_L1: default: sprintf( text, format, aifval ); sscanf ( text, "%s", text2 ); sprintf( text, "警報 = 下限%s/解除 ( %s %s )", levelname,text2,unitname ); break; } } strcpy( svm.mtextbuff[mtextbuffs++], text ); break; } /*ユーザの補足文(文字属性1)追加*/ kcxobj_atbut_crd( objid, (1), text2 ); if( text2[0] != (char)0 ){ sprintf( text, "伝文 = %s", text2 ); strcpy( svm.mtextbuff[mtextbuffs++], text ); } /*共通メール添付文(パラメータ)追加*/ if( gvm.mailmessage9[0] != (char)0 ){ sprintf( text, "%s", gvm.mailmessage9 ); strcpy( svm.mtextbuff[mtextbuffs++], text ); } /*メール送信(注意:アドレスに間違いがあると複数リトライし多くの時間を無駄に消費)*/ for(i=0;i<(3);i++){ sndflag = 0; switch( EMAILADDRGETTYPE ){ case 0: /*間接タイプ*/ switch( i ){ case 0: case 1: case 2: kcxobj_atbut_ird( objid, (1+i), &no ); /*整数属性1-3の仕様*/ if( no <= 0 ) continue; if( no > PARA_EMAILTOADDRs ) continue; /* no[1-5] -> noa[0-4] */ noa = no - 1; if( gvm.mailaddress[noa][0] == (char)0 ) continue; kcxsnd_email_texts ( gvm.mailaddress[noa],"","", emailtitle, svm.mtextbuff, mtextbuffs ); sprintf( text, "mail(%d)= %s", no, gvm.mailaddress[noa] ); sndflag = 1; break; default: break; } break; case 1: /*直接タイプ*/ switch( i ){ case 0: /*文字属性1*/ case 1: /*文字属性2*/ kcxobj_atbut_crd( objid, (1+i), text2 ); sscanf( text2, "%s", mailaddr ); if( mailaddr[0] == (char)'#' ) strcpy( mailaddr, "" ); if( mailaddr[0] == (char)0 ) continue; kcxsnd_email_texts( mailaddr,"","", emailtitle, svm.mtextbuff, mtextbuffs ); sprintf( text, "mail(%d)= %s", 1+i, mailaddr ); sndflag = 1; break; default: /*文字属性3*/ break; } break; } if( sndflag == 1 ){ kcxstr_text_to_udata10( 0, text, "", udata10 ); Ev_KEY = 200; Ev_STAT = 1; kcxobj_ope_log_10uwt( svm.sys_objid, Ev_KEY, Ev_STAT, udata10 ); } } } /* FILE_END */ /*KCX-PARA OK #!v3.0 KaracrixBuilder. #<< 制御プログラム 変数 >> # no(i),"key(c)","data(c)",web(i),keitai(i),"prefix(c)","suffix(c)" # 0,"runmode","on",0,0,"起動時の接続試験モード","on(試験),off(即本通信)" 1,"prgopt","",0,0,"プログラムオプション","プログラム機能の付加設定" 2,"mailperm","on",1,1,"メール送信許可","on,off [時刻(hh:mm-hh:mm)]" 3,"1.email","#abc@nippon.xx",1,0,"メールアドレス ( 1 )","先頭が#の場合パス(以下同様)" 4,"2.email","",1,0,"メールアドレス ( 2 )","" 5,"3.email","",1,0,"メールアドレス ( 3 )","" 6,"4.email","",1,0,"メールアドレス ( 4 )","" 7,"5.email","",1,0,"メールアドレス ( 5 )","" 8,"mmsg0","KARACRIX",1,0,"メール装置名(共通)","メール本文先頭部に追加" 9,"mmsg9","http://xx.xx.xx.xx/",1,0,"メール添付文(共通)","メール本文最後部に追加" 10,"bz", "#do001 #do002",1,0,"警報ブザーポイントID","DO型ポイントID" 11,"monip","",1,0,"通信応答表示装置番号","装置番号 1〜 (未指定時先頭機器)" 12,"etc1","",1,0,"","" 13,"1.ip","#RS1",1,0,"接続装置 KBRS31A","型,IP,ポート,[オプション]" 14,"1.dat1","di001 di002 di003 di004 pi001 pi002 pi003 pi004",1,0,"装置 A 割付ポイントID","ポイントID,," 15,"1.dat2","do001 do002 do003 do004 do005 do006",1,0," + 割付ポイントID","ポイントID,," 16,"1.dat3","ai001 ai002 ai003 ai004 ",1,0," + 割付ポイントID","ポイントID,," 17,"2.ip","#TK 192.168.0.200 20000",1,0,"接続装置 TK0040A","型,IP,ポート,[オプション]" 18,"2.dat1","di001 di002 di003 di004 di005 di006 pi001 pi002 pi003 pi004 pi005 pi006",1,0,"装置 1 割付ポイントID","ポイントID,," 19,"2.dat2","do001 do002 do003 do004",1,0," + 割付ポイントID","ポイントID,," 20,"2.dat3","ai001 ai002 ai003 ai004 ao001 - -",1,0," + 割付ポイントID","ポイントID,," 21,"3.ip","",1,0,"接続装置 3","型,IP,ポート,[オプション]" 22,"3.dat1","",1,0,"装置 3 割付ポイントID","ポイントID,," 23,"3.dat2","",1,0," + 割付ポイントID","ポイントID,," 24,"3.dat3","",1,0," + 割付ポイントID","ポイントID,," 25,"4.ip","",1,0,"接続装置 4","型,IP,ポート,[オプション]" 26,"4.dat1","",1,0,"装置 4 割付ポイントID","ポイントID,," 27,"4.dat2","",1,0," + 割付ポイントID","ポイントID,," 28,"4.dat3","",1,0," + 割付ポイントID","ポイントID,," 29,"5.ip","",1,0,"接続装置 5","型,IP,ポート,[オプション]" 30,"5.dat1","",1,0,"装置 5 割付ポイントID","ポイントID,," 31,"5.dat2","",1,0," + 割付ポイントID","ポイントID,," 32,"5.dat3","",1,0," + 割付ポイントID","ポイントID,," 33,"6.ip","",1,0,"接続装置 6","型,IP,ポート,[オプション]" 34,"6.dat1","",1,0,"装置 6 割付ポイントID","ポイントID,," 35,"6.dat2","",1,0," + 割付ポイントID","ポイントID,," 36,"6.dat3","",1,0," + 割付ポイントID","ポイントID,," 37,"7.ip","",1,0,"接続装置 7","型,IP,ポート,[オプション]" 38,"7.dat1","",1,0,"装置 7 割付ポイントID","ポイントID,," 39,"7.dat2","",1,0," + 割付ポイントID","ポイントID,," 40,"7.dat3","",1,0," + 割付ポイントID","ポイントID,," 41,"8.ip","",1,0,"接続装置 8","型,IP,ポート,[オプション]" 42,"8.dat1","",1,0,"装置 8 割付ポイントID","ポイントID,," 43,"8.dat2","",1,0," + 割付ポイントID","ポイントID,," 44,"8.dat3","",1,0," + 割付ポイントID","ポイントID,," 45,"9.ip","",1,0,"接続装置 9","型,IP,ポート,[オプション]" 46,"9.dat1","",1,0,"装置 9 割付ポイントID","ポイントID,," 47,"9.dat2","",1,0," + 割付ポイントID","ポイントID,," 48,"9.dat3","",1,0," + 割付ポイントID","ポイントID,," 49,"10.ip","",1,0,"接続装置 10","型,IP,ポート,[オプション]" 50,"10.dat1","",1,0,"装置 10 割付ポイントID","ポイントID,," 51,"10.dat2","",1,0," + 割付ポイントID","ポイントID,," 52,"10.dat3","",1,0," + 割付ポイントID","ポイントID,," 53,"11.ip","",1,0,"接続装置 11","型,IP,ポート,[オプション]" 54,"11.dat1","",1,0,"装置 11 割付ポイントID","ポイントID,," 55,"11.dat2","",1,0," + 割付ポイントID","ポイントID,," 56,"11.dat3","",1,0," + 割付ポイントID","ポイントID,," 57,"12.ip","",1,0,"接続装置 12","型,IP,ポート,[オプション]" 58,"12.dat1","",1,0,"装置 12 割付ポイントID","ポイントID,," 59,"12.dat2","",1,0," + 割付ポイントID","ポイントID,," 60,"12.dat3","",1,0," + 割付ポイントID","ポイントID,," 61,"13.ip","",1,0,"接続装置 13","型,IP,ポート,[オプション]" 62,"13.dat1","",1,0,"装置 13 割付ポイントID","ポイントID,," 63,"13.dat2","",1,0," + 割付ポイントID","ポイントID,," 64,"13.dat3","",1,0," + 割付ポイントID","ポイントID,," 65,"14.ip","",1,0,"接続装置 14","型,IP,ポート,[オプション]" 66,"14.dat1","",1,0,"装置 14 割付ポイントID","ポイントID,," 67,"14.dat2","",1,0," + 割付ポイントID","ポイントID,," 68,"14.dat3","",1,0," + 割付ポイントID","ポイントID,," 69,"15.ip","",1,0,"接続装置 15","型,IP,ポート,[オプション]" 70,"15.dat1","",1,0,"装置 15 割付ポイントID","ポイントID,," 71,"15.dat2","",1,0," + 割付ポイントID","ポイントID,," 72,"15.dat3","",1,0," + 割付ポイントID","ポイントID,," 73,"16.ip","",1,0,"接続装置 16","型,IP,ポート,[オプション]" 74,"16.dat1","",1,0,"装置 16 割付ポイントID","ポイントID,," 75,"16.dat2","",1,0," + 割付ポイントID","ポイントID,," 76,"16.dat3","",1,0," + 割付ポイントID","ポイントID,," 77,"17.ip","",1,0,"接続装置 17","型,IP,ポート,[オプション]" 78,"17.dat1","",1,0,"装置 17 割付ポイントID","ポイントID,," 79,"17.dat2","",1,0," + 割付ポイントID","ポイントID,," 80,"17.dat3","",1,0," + 割付ポイントID","ポイントID,," 81,"18.ip","",1,0,"接続装置 18","型,IP,ポート,[オプション]" 82,"18.dat1","",1,0,"装置 18 割付ポイントID","ポイントID,," 83,"18.dat2","",1,0," + 割付ポイントID","ポイントID,," 84,"18.dat3","",1,0," + 割付ポイントID","ポイントID,," 85,"19.ip","",1,0,"接続装置 19","型,IP,ポート,[オプション]" 86,"19.dat1","",1,0,"装置 19 割付ポイントID","ポイントID,," 87,"19.dat2","",1,0," + 割付ポイントID","ポイントID,," 88,"19.dat3","",1,0," + 割付ポイントID","ポイントID,," 89,"20.ip","",1,0,"接続装置 20","型,IP,ポート,[オプション]" 90,"20.dat1","",1,0,"装置 20 割付ポイントID","ポイントID,," 91,"20.dat2","",1,0," + 割付ポイントID","ポイントID,," 92,"20.dat3","",1,0," + 割付ポイントID","ポイントID,," # KCX-PARA*/