兔小喵一只
級別: 探索解密
|
用西門子SCL語言編程,一些計算過程需要自己編寫函數實現。遇到的問題是:一個函數的輸入值是另一個函數的輸出值,所以我想到用FC調用FC。 目前有三個函數,是FC48,FC4,FC49。在FB40里調用三個函數。 //下面是程序**********************************************紅色的變量是輸入輸出值 FUNCTION_BLOCK FB40 //谷電期蓄能總控制 VAR_OUTPUT RESULT_Q:INT; //輸出Q量 RESULT_W:INT; RESULT_Wt:INT; END_VAR BEGIN //調用FC48計算Q RESULT_Q:=FC48(Ai := "A" // IN: INT ,Hdesign_total := "Hdt" // IN: INT ,Wpower_real :="W0" // IN: INT ,Qdesign_total :="Q0" // OUT: INT ); // INT //調用FC4計算Wpower_real****************************************** RESULT_W:=FC4(Wpower_real_today :="W1" // IN: INT ,Toutdr_offpk_sta_tody :="T01" // IN: INT ,Toutdr_offpk_sta_yesdy := "T02" // IN: INT ,Wpower_real :="W0" // OUT: INT ); // INT //調用FC49計算Wpower_real_today************************************ RESULT_Wt:=FC49 (Theating_unit_11 := "Q2" // IN: REAL ,Theating_unit_12 := "Q3" // IN: REAL ,Theating_unit_21 := "Q4" // IN: REAL ,Theating_unit_22 := "Q5" // IN: REAL ,Theating_unit_31 := "Q6" // IN: REAL ,Theating_unit_32 := "Q7" // IN: REAL ,Qadd := "Qa" // IN: REAL ,A := "A" // IN: REAL ,Huser :="Hu" // IN: REAL ,Ttime_offpkend_11 := "Q11" // IN: REAL ,Ttime_offpkend_12 := "Q12" // IN: REAL ,Ttime_offpkend_21 := "Q21" // IN: REAL ,Ttime_offpkend_22 := "Q22" // IN: REAL ,Ttime_offpkend_31 := "Q31" // IN: REAL ,Ttime_offpkend_32 := "Q32" // IN: REAL ,Wpower_real_today := "W1" // OUT: REAL ); // REAL END_FUNCTION_BLOCK 編譯后的錯誤時invalid assignment。在調用FC48和FC4處有問題. 三個FC函數分別編譯都沒有問題。下面是三個函數: FUNCTION FC48 : INT VAR_INPUT Ai:INT; Hdesign_total:INT; Wpower_real:INT; END_VAR VAR_OUTPUT Qdesign_total:INT; END_VAR BEGIN FC48:=(Ai*Hdesign_total)*Wpower_real; Qdesign_total:=FC48; // Statement Section END_FUNCTION //**************************************************** FUNCTION FC4 : INT VAR_INPUT Wpower_real_today:INT; Toutdr_offpk_sta_tody:INT; Toutdr_offpk_sta_yesdy:INT; END_VAR VAR_OUTPUT Wpower_real:INT; END_VAR BEGIN //******************************************* FUNCTION FC49 : INT VAR_INPUT Theating_unit_11:INT; Theating_unit_12:INT; Theating_unit_21:INT; Theating_unit_22:INT; Theating_unit_31:INT; Theating_unit_32:INT; Qadd:INT; A:INT;//房間面積 Huser:INT; Ttime_offpkend_11:INT; Ttime_offpkend_12:INT; Ttime_offpkend_21:INT; Ttime_offpkend_22:INT; Ttime_offpkend_31:INT; Ttime_offpkend_32:INT; END_VAR VAR_OUTPUT Wpower_real_today:INT;//第二天預計供熱負荷 END_VAR BEGIN FC49:=(a*(Theating_unit_11+Theating_unit_12+Theating_unit_21+Theating_unit_22+Theating_unit_31+Theating_unit_32-Ttime_offpkend_11-Ttime_offpkend_12-Ttime_offpkend_21-Ttime_offpkend_22-Ttime_offpkend_31-Ttime_offpkend_32)+Qadd)/(A* Huser); Wpower_real_today:=FC49; END_FUNCTION |
---|---|
|