operator.fun 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. {REDUND_OK} FUNCTION SIZEOF : UDINT (*determines the size of a variable in bytes*)
  2. VAR_INPUT
  3. in :ANY; (*input value*)
  4. END_VAR
  5. END_FUNCTION
  6. {REDUND_OK} FUNCTION ADR : UDINT (*determines the address of a data point*)
  7. VAR_INPUT
  8. in :ANY; (*input value*)
  9. END_VAR
  10. END_FUNCTION
  11. {REDUND_OK} FUNCTION ADRINST : UDINT (*determines the address of a fub instance*)
  12. END_FUNCTION
  13. {REDUND_OK} FUNCTION SHR : ANY (*shifts bitwise to the right*)
  14. VAR_INPUT
  15. IN :ANY; (*input value*)
  16. N :SINT; (*number of bits to be shifted*)
  17. END_VAR
  18. END_FUNCTION
  19. {REDUND_OK} FUNCTION ROR : ANY (*rotates bitwise to the right*)
  20. VAR_INPUT
  21. IN :ANY; (*input value*)
  22. N :SINT; (*number of bits to be rotated*)
  23. END_VAR
  24. END_FUNCTION
  25. {REDUND_OK} FUNCTION ROL : ANY (*rotates bitwise to the left*)
  26. VAR_INPUT
  27. IN :ANY; (*input value*)
  28. N :SINT; (*number of bits to be rotated*)
  29. END_VAR
  30. END_FUNCTION
  31. {REDUND_OK} FUNCTION SHL : ANY (*shifts bitwise to the left*)
  32. VAR_INPUT
  33. IN :ANY; (*input value*)
  34. N :SINT; (*number of bits to be shifted*)
  35. END_VAR
  36. END_FUNCTION
  37. {REDUND_OK} FUNCTION AND : ANY (*makes a bitwise AND relation for 2 or more variables*)
  38. VAR_INPUT
  39. INx :ANY; (*input value*)
  40. END_VAR
  41. END_FUNCTION
  42. {REDUND_OK} FUNCTION XOR : ANY (*makes a bitwise XOR relation for 2 or more variables*)
  43. VAR_INPUT
  44. INx :ANY; (*input values*)
  45. END_VAR
  46. END_FUNCTION
  47. {REDUND_OK} FUNCTION OR : ANY (*makes a bitwise OR relation for 2 or more variables*)
  48. VAR_INPUT
  49. INx :ANY; (*input values*)
  50. END_VAR
  51. END_FUNCTION
  52. {REDUND_OK} FUNCTION NOT : ANY (*makes a bitwise inversion of variables*)
  53. VAR_INPUT
  54. IN :ANY; (*input value*)
  55. END_VAR
  56. END_FUNCTION
  57. {REDUND_OK} FUNCTION ADD : ANY (*adds 2 or more variables*)
  58. VAR_INPUT
  59. INx :ANY; (*input values*)
  60. END_VAR
  61. END_FUNCTION
  62. {REDUND_OK} FUNCTION MUL : ANY_NUM (*multiplies 2 or more variables*)
  63. VAR_INPUT
  64. INx :ANY_NUM; (*input values*)
  65. END_VAR
  66. END_FUNCTION
  67. {REDUND_OK} FUNCTION SUB : ANY (*subtracts one or more variables from another variable*)
  68. VAR_INPUT
  69. IN1 :ANY; (*value 1*)
  70. IN2 :ANY; (*value 2*)
  71. END_VAR
  72. END_FUNCTION
  73. {REDUND_OK} FUNCTION DIV : ANY_NUM (*divides a variable by one or more variables*)
  74. VAR_INPUT
  75. IN1 :ANY_NUM; (*dividend*)
  76. IN2 :ANY_NUM; (*divisor*)
  77. END_VAR
  78. END_FUNCTION
  79. {REDUND_OK} FUNCTION MOD : ANY_INT (*makes a remainder when dividing a variable by another variable*)
  80. VAR_INPUT
  81. IN1 :ANY_INT; (*dividend*)
  82. IN2 :ANY_INT; (*divisor*)
  83. END_VAR
  84. END_FUNCTION
  85. {REDUND_OK} FUNCTION MOVE : ANY (*copies the contents of the input variables to the corresponding output variables*)
  86. VAR_INPUT
  87. IN :ANY; (*input variable*)
  88. END_VAR
  89. END_FUNCTION
  90. {REDUND_OK} FUNCTION MAX : ANY (*determines the maximum value of two or more values*)
  91. VAR_INPUT
  92. IN1 :ANY; (*input value 1*)
  93. IN2 :ANY; (*input value 2*)
  94. END_VAR
  95. END_FUNCTION
  96. {REDUND_OK} FUNCTION MIN : ANY (*determines the lowest value of two or more values*)
  97. VAR_INPUT
  98. IN1 :ANY; (*input value 1*)
  99. IN2 :ANY; (*input value 2*)
  100. END_VAR
  101. END_FUNCTION
  102. {REDUND_OK} FUNCTION LIMIT : ANY (*limits a value to within maximum and minimum boundaries*)
  103. VAR_INPUT
  104. MN :ANY; (*minimum value*)
  105. IN :ANY; (*input value*)
  106. MX :ANY; (*maximum value*)
  107. END_VAR
  108. END_FUNCTION
  109. {REDUND_OK} FUNCTION SEL : ANY (*selects one value from two values*)
  110. VAR_INPUT
  111. G :BOOL; (*selection variable*)
  112. IN0 :ANY; (*input value for FALSE*)
  113. IN1 :ANY; (*input value for TRUE*)
  114. END_VAR
  115. END_FUNCTION
  116. {REDUND_OK} FUNCTION MUX : ANY (*selects a value from several values*)
  117. VAR_INPUT
  118. K :SINT; (*selection variable*)
  119. INx :ANY; (*input values*)
  120. END_VAR
  121. END_FUNCTION
  122. {REDUND_OK} FUNCTION GE : BOOL (*checks if the input values are in decreasing order*)
  123. VAR_INPUT
  124. IN1 :ANY; (*comparison value 1*)
  125. IN2 :ANY; (*comparison value 2*)
  126. END_VAR
  127. END_FUNCTION
  128. {REDUND_OK} FUNCTION EQ : BOOL (*compares two or more values whether they are equal*)
  129. VAR_INPUT
  130. IN1 :ANY; (*comparison value 1*)
  131. IN2 :ANY; (*comparison value 2*)
  132. END_VAR
  133. END_FUNCTION
  134. {REDUND_OK} FUNCTION GT : BOOL (*checks if the input values are in decreasing order*)
  135. VAR_INPUT
  136. IN1 :ANY; (*comparison value 1*)
  137. IN2 :ANY; (*comparison value 2*)
  138. END_VAR
  139. END_FUNCTION
  140. {REDUND_OK} FUNCTION LE : BOOL (*checks if the input values are in increasing order*)
  141. VAR_INPUT
  142. IN1 :ANY; (*comparison value 1*)
  143. IN2 :ANY; (*comparison value 2*)
  144. END_VAR
  145. END_FUNCTION
  146. {REDUND_OK} FUNCTION LT : BOOL (*checks if the input values are in increasing order*)
  147. VAR_INPUT
  148. IN1 :ANY; (*comparison value 1*)
  149. IN2 :ANY; (*comparison value 2*)
  150. END_VAR
  151. END_FUNCTION
  152. {REDUND_OK} FUNCTION NE : BOOL (*compares two values whether they are not equal*)
  153. VAR_INPUT
  154. IN1 :ANY; (*comparison value 1*)
  155. IN2 :ANY; (*comparison value 2*)
  156. END_VAR
  157. END_FUNCTION
  158. {REDUND_OK} FUNCTION ABS : ANY_NUM (*returns the absolute value of a number*)
  159. VAR_INPUT
  160. IN :ANY_NUM; (*input value*)
  161. END_VAR
  162. END_FUNCTION
  163. {REDUND_OK} FUNCTION SQRT : ANY_REAL (*returns the square root of a number*)
  164. VAR_INPUT
  165. IN :ANY_REAL; (*input value*)
  166. END_VAR
  167. END_FUNCTION
  168. {REDUND_OK} FUNCTION LN : ANY_REAL (*returns the result of a natural logarithm*)
  169. VAR_INPUT
  170. IN :ANY_REAL; (*input value*)
  171. END_VAR
  172. END_FUNCTION
  173. {REDUND_OK} FUNCTION LOG : ANY_REAL (*returns the result of a base 10 logarithm*)
  174. VAR_INPUT
  175. IN :ANY_REAL; (*input value*)
  176. END_VAR
  177. END_FUNCTION
  178. {REDUND_OK} FUNCTION EXP : ANY_REAL (*returns the result of a natural exponential function*)
  179. VAR_INPUT
  180. IN :ANY_REAL; (*input value*)
  181. END_VAR
  182. END_FUNCTION
  183. {REDUND_OK} FUNCTION SIN : ANY_REAL (*returns the sine of a number (calculated in radian)*)
  184. VAR_INPUT
  185. IN :ANY_REAL; (*input value in radian*)
  186. END_VAR
  187. END_FUNCTION
  188. {REDUND_OK} FUNCTION COS : ANY_REAL (*returns the cosine of a number (calculated in radian)*)
  189. VAR_INPUT
  190. IN :ANY_REAL; (*input value in radian*)
  191. END_VAR
  192. END_FUNCTION
  193. {REDUND_OK} FUNCTION TAN : ANY_REAL (*returns the tangent of a number (calculated in radian)*)
  194. VAR_INPUT
  195. IN :ANY_REAL; (*input value in radian*)
  196. END_VAR
  197. END_FUNCTION
  198. {REDUND_OK} FUNCTION ASIN : ANY_REAL (*returns the arc sine (inverse function of sine) of a number (calculated in radian)*)
  199. VAR_INPUT
  200. IN :ANY_REAL; (*input value*)
  201. END_VAR
  202. END_FUNCTION
  203. {REDUND_OK} FUNCTION ACOS : ANY_REAL (*returns the arc cosine (inverse function of cosine) of a number (calculated in radian)*)
  204. VAR_INPUT
  205. IN :ANY_REAL; (*input value*)
  206. END_VAR
  207. END_FUNCTION
  208. {REDUND_OK} FUNCTION ATAN : ANY_REAL (*returns the arc tangent (inverse function of tangent) of a number (calculated in radian)*)
  209. VAR_INPUT
  210. IN :ANY_REAL; (*input value*)
  211. END_VAR
  212. END_FUNCTION
  213. {REDUND_OK} FUNCTION EXPT : REAL (*raises one variable to the power of another*)
  214. VAR_INPUT
  215. IN1 :REAL; (*base*)
  216. IN2 :ANY_NUM; (*exponent*)
  217. END_VAR
  218. END_FUNCTION
  219. {REDUND_OK} FUNCTION TRUNC : INT (*converts from type REAL to type INT (number is always rounded down)*)
  220. VAR_INPUT
  221. IN :ANY_REAL; (*input value*)
  222. END_VAR
  223. END_FUNCTION