Research Article

A Low-Cost Online Data Acquisition and Processing System for Industrial Pollutants’ Monitoring

Algorithm 2

Process received data.
\documentclass[11pt]{article}
\usepackage{CJK}
\usepackage[top=2cm, bottom=2cm, left=2cm, right=2cm]{geometry}
\usepackage{algorithm}
\usepackage{algorithmicx}
\usepackage{algpseudocode}
\usepackage{amsmath}
\usepackage{indentfirst}
\floatname{algorithm}{Algorithm}
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}
\begin{document}
\begin{CJK∗}{UTF8}{gkai}
 \renewcommand{\thealgorithm}{2}
 \begin{algorithm}
  \caption{Process Received Data}
  \begin{algorithmic}[1] %每行显示行号
   \Require $enumber:$analyzer number ,$buf:$byte array containing received data
   \State $factors \gets$ get factors by analyzer number
   \State $length \gets buf[2]/2 $
   If {$length \neq factors.Length$}
   \State $return$
   \EndIf
   \State $index \gets 3 $
   \For{$i=0$ to $length$}
    \State $tempbuf \gets$ new byte[2]
    \State $tempbuf \gets$ copy buf from index to index+2
    \State $val \gets $ bytes array to unit16
    \State $[rangeH,rangeL] \gets$ get range of current factor
    \State $temp \gets (rangeH - rangeL) ∗ val / 65535 +rangeL;$
    \State Update the dictionary used to store collected data
   \EndFor
  \end{algorithmic}
  \end{algorithm}
 \end{CJK∗}
\end{document}