Ejemplo n.º 1
0
 private void button_read_ushort_Click(object sender, EventArgs e)
 {
     // 读取ushort变量
     if (textBox1.Text == "1")
     {
         DemoUtils.ReadResultRender(siemensPPI.ReadUInt16(textBox3.Text), textBox3.Text, textBox4);
     }
     else
     {
         DemoUtils.ReadResultRender(siemensPPI.ReadUInt16(textBox3.Text, ushort.Parse(textBox1.Text)), textBox3.Text, textBox4);
     }
 }
Ejemplo n.º 2
0
        private void Test2( )
        {
            byte   m100_byte   = siemensPPI.ReadByte("M100").Content;
            short  m100_short  = siemensPPI.ReadInt16("M100").Content;
            ushort m100_ushort = siemensPPI.ReadUInt16("M100").Content;
            int    m100_int    = siemensPPI.ReadInt32("M100").Content;
            uint   m100_uint   = siemensPPI.ReadUInt32("M100").Content;
            float  m100_float  = siemensPPI.ReadFloat("M100").Content;
            double m100_double = siemensPPI.ReadDouble("M100").Content;
            string m100_string = siemensPPI.ReadString("M100", 10).Content;

            HslCommunication.Core.IByteTransform ByteTransform = new HslCommunication.Core.ReverseBytesTransform( );
        }
Ejemplo n.º 3
0
 private void button_read_ushort_Click(object sender, EventArgs e)
 {
     // 读取ushort变量
     DemoUtils.ReadResultRender(siemensPPI.ReadUInt16(textBox3.Text), textBox3.Text, textBox4);
 }
Ejemplo n.º 4
0
        public override IEnumerable <IOTData> GetData()
        {
            List <IOTData> iOTs = new List <IOTData>();

            foreach (SiemensMPIResult result in DriveConfig.Results)
            {
                try
                {
                    string sResult;
                    switch (result.DataType.ToUpper())
                    {
                    case "BOOL":
                        sResult = siemensPPI.ReadBool(result.DB).Content.ToString();
                        break;

                    case "STRING":
                        sResult = siemensPPI.ReadString(result.DB, Convert.ToUInt16(result.Len)).Content;
                        break;

                    case "INT":
                        sResult = siemensPPI.ReadInt32(result.DB).Content.ToString();
                        break;

                    case "FLOAT":
                        sResult = siemensPPI.ReadFloat(result.DB).Content.ToString(result.Format);
                        break;

                    case "DOUBLE":
                        sResult = siemensPPI.ReadDouble(result.DB).Content.ToString(result.Format);
                        break;

                    case "BYTE":
                        sResult = siemensPPI.ReadByte(result.DB).Content.ToString();
                        break;

                    case "SHORT":
                        sResult = siemensPPI.ReadInt16(result.DB).Content.ToString();
                        break;

                    case "USHORT":
                        sResult = siemensPPI.ReadUInt16(result.DB).Content.ToString();
                        break;

                    case "UINT":
                        sResult = siemensPPI.ReadUInt32(result.DB).Content.ToString();
                        break;

                    case "LONG":
                        sResult = siemensPPI.ReadInt64(result.DB).Content.ToString();
                        break;

                    case "ULONG":
                        sResult = siemensPPI.ReadUInt64(result.DB).Content.ToString();
                        break;

                    default:
                        sResult = siemensPPI.ReadString(result.DB, 1).Content;
                        break;
                    }
                    iOTs.Add(new IOTData
                    {
                        DataCode  = result.Address,
                        DataValue = sResult,
                        DataName  = result.Name,
                        DriveCode = DriveConfig.DriveCode,
                        DriveType = DriveConfig.DriveType,
                        GTime     = DateTime.Now,
                        Unit      = result.Unit
                    });
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
            return(iOTs);
        }