Beispiel #1
0
 void ReadMData()
 {
     if (status < 1)
     {
         if (pMLst != null && pMLst.Count > 0)
         {
             bool[] inputs = master.ReadCoils((ushort)pMLst[0].Address, (ushort)pDLst.Count);
             if (inputs != null && inputs.Count() == pDLst.Count)
             {
                 for (int i = 0; i < pMLst.Count; i++)
                 {
                     pMLst[i].ShowValue = inputs[i].ToString();
                 }
             }
         }
     }
 }
Beispiel #2
0
        bool getMValueFromLst(List <XJPlcInfo> mPlst)
        {
            try
            {
                bool[] inputBools = master.ReadCoils((byte)Constant.DefaultUnitId, (ushort)mPlst[0].AbsAddr, (ushort)mPlst.Count);

                if (inputBools != null && inputBools.Count() == mPlst.Count)
                {
                    ErrorConnCount = 0;

                    for (int i = 0; i < mPlst.Count; i++)
                    {
                        if (IsRePackCmdReadDMDataOut)
                        {
                            return(true);
                        }

                        if (mPlst[i].Row >= dataForm.Rows.Count)
                        {
                            continue;
                        }

                        if (mPlst[i].ByteValue != null && mPlst[i].ByteValue.Count() > 0)
                        {
                            mPlst[i].ByteValue[0] = Constant.tcpMValue;
                            mPlst[i].PlcValue     = (inputBools[i] == true) ? 1 : 0;
                        }
                        else
                        {
                            return(false);
                        }

                        if (!dataForm.Rows[mPlst[i].Row]["value"].ToString().Equals(mPlst[i].PlcValue.ToString()) &&
                            !mPlst[i].IsInEdit)
                        {
                            string m10addr = mPlst[i].RelAddr.ToString();
                            if (mPlst[i].IntArea > Constant.HM_ID)
                            {
                                m10addr = ConstantMethod.GetXYAddr10To8(mPlst[i].RelAddr).ToString();
                            }

                            if (dataForm.Rows[mPlst[i].Row]["addr"].ToString().Contains(m10addr)
                                &&
                                dataForm.Rows[mPlst[i].Row]["addr"].ToString().Contains(mPlst[i].StrArea)
                                )
                            {
                                dataForm.Rows[mPlst[i].Row]["value"] = mPlst[i].PlcValue.ToString();
                            }
                        }
                    }

                    return(true);
                }

                return(false);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }