コード例 #1
0
ファイル: Utility.cs プロジェクト: robinson/DataLink
        internal static object GetS7Value(Tag tagItem, byte[] buffer)
        {
            object returnValue;

            if (tagItem.DataType == "Bit")
            {
                returnValue = S7.GetBitAt(buffer, tagItem.Position, 0);
            }
            else if (tagItem.DataType == "Word")
            {
                returnValue = S7.GetWordAt(buffer, 0);
            }
            else if (tagItem.DataType == "Short")
            {
                returnValue = S7.GetShortAt(buffer, 0);
            }
            else if (tagItem.DataType == "DWord")
            {
                returnValue = S7.GetDWordAt(buffer, 0);
            }
            else if (tagItem.DataType == "DInt")
            {
                returnValue = S7.GetDIntAt(buffer, 0);
            }
            else if (tagItem.DataType == "Float")
            {
                returnValue = S7.GetFloatAt(buffer, 0);
            }
            else if (tagItem.DataType == "String")
            {
                returnValue = S7.GetStringAt(buffer, 0, buffer.Length);
            }
            else if (tagItem.DataType == "PrintableString")
            {
                returnValue = S7.GetPrintableStringAt(buffer, 0, buffer.Length);
            }
            else if (tagItem.DataType == "Date")
            {
                returnValue = S7.GetDateAt(buffer, 0);
            }
            else
            {
                returnValue = S7.GetStringAt(buffer, 0, buffer.Length);
            }
            return(returnValue);
        }