Example #1
0
        /// <summary>
        /// 등록된 어드레스의 값을 가지고 온다.(등록 값 타입으로 가지고 온다.)
        /// </summary>
        /// <param name="Address"></param>
        /// <returns></returns>
        public AddressValue GetValue(string Address)
        {
            try
            {
                if (ConnctionStatus != enStatus.OK)
                {
                    throw new Exception("PLC와 연결이 끊어 졌습니다.");
                }

                DataRow[] row = this.dtAddress.Select("Address = '" + Address + "'");

                if (row.Length > 0)
                {
                    AddressValue rtn = new AddressValue();

                    rtn.Value     = row[0]["Value"];
                    rtn.ValueType = (enPLCValueType)row[0]["ValueType"];

                    return(rtn);
                }
                else
                {
                    throw new Exception("확인(등록) 되어 있지 PLC Address입니다.[" + Address + "]");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
        /// <summary>
        /// 등록된 어드레스의 값을 요청한 타입으로 가지고 온다.
        /// </summary>
        /// <param name="Address">요청 주소</param>
        /// <param name="valuetype">요청 값 타임</param>
        /// <returns></returns>
        public AddressValue GetValue(string Address, enPLCValueType valuetype)
        {
            try
            {
                if (ConnctionStatus != enStatus.OK)
                {
                    throw new Exception("PLC와 연결이 끊어 졌습니다.");
                }

                DataRow[] row = this.dtAddress.Select("Address = '" + Address + "'");

                if (row.Length > 0)
                {
                    AddressValue rtn = new AddressValue();

                    switch (valuetype)
                    {
                    case enPLCValueType.HEX:
                        rtn.Value = row[0]["Value(HEX)"];
                        break;

                    case enPLCValueType.STRING:
                        rtn.Value = row[0]["Value(STRING)"];
                        break;

                    default:
                        rtn.Value = row[0]["Value(INT)"];
                        break;
                    }

                    rtn.ValueType = valuetype;

                    return(rtn);
                }
                else
                {
                    throw new Exception("확인(등록) 되어 있지 PLC Address입니다.[" + Address + "]");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }