在好例子网,分享、交流、成长!
您当前所在位置:首页C# 开发实例C#网络编程 → Prodave6联接程序源码

Prodave6联接程序源码

C#网络编程

下载此实例
  • 开发语言:C#
  • 实例大小:0.46M
  • 下载次数:13
  • 浏览次数:170
  • 发布时间:2019-10-13
  • 实例类别:C#网络编程
  • 发 布 人:lucksimba
  • 文件格式:.rar
  • 所需积分:5
 相关标签: 程序

实例介绍

【实例简介】

【实例截图】

from clipboard


【核心代码】

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Prodave6_CS;
using System.Runtime.InteropServices;



namespace ProDave6Test
{
    class Test
    {

        static void Main(string[] args)
        {
           
            //以下测试LoadConnection_ex6
            short ConNr= 63; // First connection;(0 ... 63);(max. 64 connections).
            string AccessPoint = "S7ONLINE"; // Default access point——S7ONLINE                  
            Prodave6_CS.Prodave6.CON_TABLE_TYPE ConTable ;// Connection table
            int ConTableLen = System.Runtime.InteropServices.Marshal.SizeOf(typeof(Prodave6_CS.Prodave6.CON_TABLE_TYPE)) ;// Length of the connection table
            int RetValue;
            ConTable.Adr=new byte[]{192,168,1,200,0,0};
            ConTable.AdrType = 2; // Type of address: MPI/PB (1), IP (2), MAC (3)
            ConTable.SlotNr = 2; // 插槽号
            ConTable.RackNr = 0; // 机架号  
            RetValue = Prodave6.LoadConnection_ex6(ConNr, AccessPoint, ConTableLen,ref ConTable);

            //以下测试SetActiveConnection_ex6
            UInt16 UConNr = (UInt16)ConNr;
            RetValue = Prodave6.SetActiveConnection_ex6(UConNr);

            //以下测试db_write_ex6
            UInt16 BlkNr = 4;//data block号
            Prodave6.DatType DType = Prodave6.DatType.BYTE;//要读取的数据类型
            UInt16 StartNr = 0;//起始地址号
            UInt32 pAmount = 20;//需要读取类型的数量
            UInt32 BufLen = 20;//缓冲区长度(字节为单位)
            //参数:data block号、要写入的数据类型、起始地址号、需要写入类型的数量、缓冲区长度(字节为单位)、缓冲区
            byte[] pWriteBuffer = new byte[20];
            for (int i = 0; i < pWriteBuffer.Length; i  )
                pWriteBuffer[i] = (byte)(i 1);
                RetValue = Prodave6.db_write_ex6(BlkNr, DType, StartNr, ref pAmount, BufLen, pWriteBuffer);
            //以下测试db_read_ex6
            //参数:data block号、要读取的数据类型、起始地址号、需要读取类型的数量、缓冲区长度(字节为单位)、
            //缓冲区、缓冲区数据交互的长度
            byte[] pReadBuffer = new byte[20];
            UInt32 pDatLen = 0;
            RetValue = Prodave6.db_read_ex6(BlkNr, DType, StartNr, ref pAmount, BufLen, pReadBuffer, ref  pDatLen);

            //以下测试field_read_ex6(测试DB区)
            //参数:data block号、要读取的数据类型、起始地址号、需要读取类型的数量、缓冲区长度(字节为单位)、
            //缓冲区、缓冲区数据交互的长度
            Prodave6.FieldType FType = Prodave6.FieldType.D;
            for (int i = 0; i < pWriteBuffer.Length; i  )
                pWriteBuffer[i] = (byte)(i);
            RetValue = Prodave6.field_write_ex6(FType, BlkNr, StartNr, pAmount, BufLen, pWriteBuffer);

            //以下测试field_read_ex6(测试DB区)
            //参数:data block号、要读取的数据类型、起始地址号、需要读取类型的数量、缓冲区长度(字节为单位)、
            //缓冲区、缓冲区数据交互的长度
            byte[] pReadBuffer2 = new byte[20];
            RetValue = Prodave6.field_read_ex6(FType, BlkNr, StartNr, pAmount, BufLen,pReadBuffer2, ref pDatLen);


            //以下测试field_read_ex6(测试M区)
            //参数:data block号、要读取的数据类型、起始地址号、需要读取类型的数量、缓冲区长度(字节为单位)、
            //缓冲区、缓冲区数据交互的长度
            Prodave6.FieldType FTypeM = Prodave6.FieldType.M;
            byte []pWriteBufferM = {2};
            RetValue = Prodave6.field_write_ex6(FTypeM, 0, 100, 1, 1, pWriteBufferM);

            //以下测试field_read_ex6(测试M区)
            //参数:data block号、要读取的数据类型、起始地址号、需要读取类型的数量、缓冲区长度(字节为单位)、
            //缓冲区、缓冲区数据交互的长度
            byte[] pReadBufferM2 = new byte[1];
            RetValue = Prodave6.field_read_ex6(FTypeM, 0, 100, 1, 1, pReadBufferM2, ref pDatLen);
            
            //以下测试mb_setbit_ex6
            UInt16 MbNr = 100;//mb block号
            UInt16 BitNr = 0;//位号
            byte Value = 1;//0、1
            RetValue = Prodave6.mb_setbit_ex6(MbNr,BitNr, Value);

            //以下测试mb_bittset_ex6(测试DB区)
            int pValue = 0;
            RetValue = Prodave6.mb_bittest_ex6(MbNr, BitNr, ref pValue);


            //以下测试GetLoadedConnections_ex6
            BufLen = 64;
            int[] pBufferI = new int[64];
            Prodave6.GetLoadedConnections_ex6(BufLen, pBufferI);
            
            //以下测试UnloadConnection_ex6
            RetValue = Prodave6.UnloadConnection_ex6(UConNr);
            
            //以下测试GetErrorMessage_ex6
            int ErrorNr = 0x7040; // Block boundary exceeded, correct the number
            StringBuilder Buffer = new StringBuilder(300); // Transfer buffer for error text
            BufLen = (UInt32)Buffer.Capacity; // Buffer length     
            RetValue = Prodave6.GetErrorMessage_ex6(ErrorNr, BufLen, Buffer);

            //以下测试float_2_gp_ex6
            float ieee = 1.2F;
            UInt32 gp=0;
            float pieee=0;
            RetValue = Prodave6.float_2_gp_ex6(ieee, ref gp);
            RetValue = Prodave6.gp_2_float_ex6(gp,ref pieee);

            //以下测试gp_2_float_ex6
            RetValue = Prodave6.testbit_ex6(7, 0);
            RetValue = Prodave6.testbit_ex6(7, 1);
            RetValue = Prodave6.testbit_ex6(7, 2);
            RetValue = Prodave6.testbit_ex6(7, 3);
            RetValue = Prodave6.testbit_ex6(7, 4);
            RetValue = Prodave6.testbit_ex6(7, 5);
            RetValue = Prodave6.testbit_ex6(7, 6);
            RetValue = Prodave6.testbit_ex6(7, 7);

            //以下测试byte_2_bool_ex6
            int [] boolValue=new int[8];
            Prodave6.byte_2_bool_ex6(255, boolValue);

            //以下测试bool_2_byte_ex6
            byte  byteValue;
            byteValue=Prodave6.bool_2_byte_ex6(boolValue);

            //以下测试kf_2_integer_ex6和kf_2_long_ex6
            UInt16 u16=25600;UInt16 u16_;
            u16_=Prodave6.kf_2_integer_ex6(u16);
            UInt32 u32 = 1677721600; UInt32 u32_;
            u32_=Prodave6.kf_2_long_ex6(u32);

            //以下测试swab_buffer_ex6(byte[] pBuffer, UInt32 Amount)
            byte[] pBuffer=new byte[11];
            UInt32 Amount=(UInt32)pBuffer.Length;
            for (int i = 0; i < Amount; i  )
                pBuffer[i] = (byte)(i 1);
            Prodave6.swab_buffer_ex6(pBuffer, 6);

            //以下测试copy_buffer_ex6
            byte[] pSourceBuffer={1,2,3,4,5,6,7,8,9,10};
            byte[] pTargetBuffer=new byte[10];
            Prodave6.copy_buffer_ex6( pTargetBuffer,  pSourceBuffer,8);

            //以下测试ushort_2_bcd_ex6
            UInt16[] pwValues = { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 };
            Prodave6.ushort_2_bcd_ex6(pwValues, 10, 0, 0);

            //以下测试bcd_2_ushort_ex6
            Prodave6.bcd_2_ushort_ex6(pwValues, 10, 0, 0);

            UInt32[] pdwValues = { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 };
            //以下测试ulong_2_bcd_ex6
            Prodave6.ulong_2_bcd_ex6(pdwValues,8, 0, 0);

            //以下测试bcd_2_ulong_ex6
            Prodave6.bcd_2_ulong_ex6(pdwValues, 8, 0, 0);

            //以下测试自定义辅助函数
            byte[] test_bytes = { 1, 2 };
            byte[] test_bytes2 = { 1, 2,3,4 };
            UInt16[] test_words={1,2};
            UInt16 word = Prodave6.bytes_2_word(test_bytes[0], test_bytes[1]);
            UInt32 dword = Prodave6.bytes_2_dword(test_bytes2[0], test_bytes2[1], test_bytes2[2], test_bytes2[3]);
            UInt32 dword2 = Prodave6.words_2_dword(test_words[0], test_words[1]);

            byte[] return_bytes = Prodave6.word_2_bytes(word);
            byte[] return_bytes2 = Prodave6.dword_2_bytes(dword);
            ushort[] return_words = Prodave6.dword_2_words(dword2);
        }
    }
}

【文档目录】

Contents
1 Introduction 1-1
2 Installation 2-1
2.1 Automation License Manager........................................................................2-1
2.1.1 User Rights through the Automation License Manager ....................................2-1
2.1.2 Installing the Automation License Manager......................................................2-3
2.1.3 Guidelines for Handling License Keys ..............................................................2-4
2.2 Installing PRODAVE MPI/IE V6.0 ...................................................................2-5
2.2.1 Installation Procedure .......................................................................................2-6
2.2.2 Setting the PG/PC Interface..............................................................................2-8
2.3 Uninstalling PRODAVE MPI/IE V6.0 ............................................................2-10
2.3.1 Uninstalling PRODAVE MPI/IE V6.0...............................................................2-10
3 New Functions as of PRODAVE MPI/IE V6.0 3-1
3.1 Basic Functions ..............................................................................................3-4
3.1.1 LoadConnection_ex6 ........................................................................................3-4
3.1.2 UnloadConnection_ex6.....................................................................................3-7
3.1.3 SetActiveConnection_ex6.................................................................................3-8
3.1.4 SetPassword_ex6 .............................................................................................3-9
3.1.5 UnSetPassword_ex6.......................................................................................3-10
3.1.6 as_info_ex6.....................................................................................................3-11
3.1.7 as_zustand_ex6 ..............................................................................................3-13
3.1.8 db_buch_ex6...................................................................................................3-15
3.1.9 db_read_ex6 ...................................................................................................3-17
3.1.10 db_write_ex6...................................................................................................3-19
3.1.11 bst_read_diag_ex6..........................................................................................3-21
3.1.12 bst_read_stat_ex6...........................................................................................3-23
3.1.13 bst_read_ex6 ..................................................................................................3-25
3.1.14 read_diag_buf_ex6 .........................................................................................3-29
3.1.15 field_read_ex6.................................................................................................3-31
3.1.16 field_write_ex6 ................................................................................................3-33
3.1.17 mb_setbit_ex6.................................................................................................3-35
3.1.18 mb_bittest_ex6................................................................................................3-37
Contents
PRODAVE MPI/IE V6.0
viii A5E00388168-01
3.2 Functions for Data Transfer to S7-200........................................................3-39
3.2.1 as200_as_info_ex6.........................................................................................3-39
3.2.2 as200_as_zustand_ex6 ..................................................................................3-41
3.2.3 as200_field_read_ex6.....................................................................................3-43
3.2.4 as200_field_write_ex6 ....................................................................................3-45
3.2.5 as200_mb_setbit_ex6 .....................................................................................3-47
3.2.6 as200_mb_bittest_ex6....................................................................................3-49
3.3 Convenience Functions................................................................................3-51
3.3.1 GetErrorMessage_ex6 ....................................................................................3-51
3.3.2 kg_2_float_ex6................................................................................................3-55
3.3.3 float_2_kg_ex6................................................................................................3-56
3.3.4 gp_2_float_ex6................................................................................................3-57
3.3.5 float_2_gp_ex6................................................................................................3-58
3.3.6 testbit_ex6.......................................................................................................3-59
3.3.7 byte_2_bool_ex6.............................................................................................3-60
3.3.8 bool_2_byte_ex6.............................................................................................3-62
3.3.9 kf_2_integer_ex6, kf_2_long_ex6 ...................................................................3-64
3.3.10 swab_buffer_ex6.............................................................................................3-66
3.3.11 copy_buffer_ex6..............................................................................................3-67
3.3.12 ushort_2_bcd_ex6, ulong_2_bcd_ex6............................................................3-68
3.3.13 bcd_2_ushort_ex6, bcd_2_ulong_ex6............................................................3-70
3.3.14 GetLoadedConnections_ex6...........................................................................3-72
3.4 TeleService Functions..................................................................................3-73
3.4.1 ts_dial_ex6 ......................................................................................................3-73
3.4.2 ts_hang_up_dial_ex6......................................................................................3-75
3.4.3 ts_set_ringindicator_ex6 .................................................................................3-76
3.4.4 ts_read_info_ex6.............................................................................................3-78
3.4.5 ts_hang_up_ring_ex6......................................................................................3-79
3.4.6 ts_get_modem_name_ex6..............................................................................3-80

标签: 程序

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警