示例#1
0
        /// <summary>
        /// Word Scan Method
        /// </summary>
        /// <param name="address"></param>
        /// <param name="scanproperty"></param>
        private void MelsecNetScanWord(string address, CScanControlProperties scanproperty)
        {
            string sGetValue = string.Empty;

            if (scanproperty.ScanLength == 0)
            {
                object value = ReadValiable(address);
                sGetValue = value.ToString();
                //Smart Device에서 결과값을 Hex값으로 반환되어 다시 Dec형태로 반환하여 계산

                if (sGetValue != "-1")
                {
                    sGetValue = CDataConvert.HexToDec(sGetValue);
                }
            }
            else
            {
                object value = ReadValiable(address);
                sGetValue = value.ToString();
            }

            if (scanproperty.Value != sGetValue)
            {
                scanproperty.PreviousValue = scanproperty.Value;
                scanproperty.Value         = sGetValue;

                if (scanproperty.PreviousValue == null)
                {
                    scanproperty.PreviousValue = "";
                }

                CLogManager.Instance.Log(new CMelsecLogFormat(Catagory.Info, scanproperty, scanproperty.PreviousValue, sGetValue));

                if (_mainEMPCore != null)
                {
                    foreach (CControlAttribute attribute in _mainEMPCore.CONTROLATTRIBUTES.Values)
                    {
                        if (scanproperty.ScanControlName == attribute.ControlName)
                        {
                            if (scanproperty.ScanAttribute == attribute.Attribute)
                            {
                                attribute.WordEvent(scanproperty.PreviousValue, sGetValue);
                            }
                        }
                    }
                }
                else if (_mainMainCore != null)
                {
                    foreach (CControlAttribute attribute in _mainMainCore.CONTROLATTRIBUTES.Values)
                    {
                        if (scanproperty.ScanControlName == attribute.ControlName)
                        {
                            if (scanproperty.ScanAttribute == attribute.Attribute)
                            {
                                attribute.WordEvent(scanproperty.PreviousValue, sGetValue);
                            }
                        }
                    }
                }
            }
        }