Beispiel #1
0
        public void WriteDData(PlcSimple pc, ushort[] value)
        {
            // List<ushort> valueShort = new List<ushort>();
            //for(int i=0;i<90;i++)
            //valueShort.Add((ushort)value);
            // for (int i = 0; i < 10; i++)
            // {
            //master.WriteSingleRegister((ushort)(pc.Address, ushort value);
            master.WriteMultipleRegisters((byte)SlaveId, (ushort)(pc.Address), value);
            // }

            //master.WriteSingleRegisterAsync((ushort)pc.Address, (ushort)90);
        }
Beispiel #2
0
        public bool SetMultipleDArea(int Addr, int count, int[] value, string Area)
        {
            if (Status == 0)
            {
                ushort[] uvalue;

                uvalue = Array.ConvertAll <int, ushort>(value, s => (ushort)s);
                try
                {
                    master.WriteMultipleRegisters((byte)Constant.DefaultUnitId,
                                                  (ushort)XJPLCPackCmdAndDataUnpack.AreaGetFromStr(Addr, Area), uvalue);

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