Esempio n. 1
0
        /// <summary>
        /// 建立连接
        /// </summary>
        /// <returns></returns>
        private bool SetConnect()
        {
            //两个连接
            bool res1 = (S7_COM_FUN.Set_Connection(Cp_descr, ConnName, ref Cref, ref Orderid) == 0);

            Thread.Sleep(100);
            res1 &= (S7_COM_FUN.Set_Connection(Cp_descr, ConnName2, ref Cref2, ref Orderid2) == 0);
            return(res1);
        }
Esempio n. 2
0
 /// <summary>
 /// 写float信号
 /// </summary>
 /// <param name="address"></param>
 /// <param name="value"></param>
 /// <returns></returns>
 private bool Write(string address, float value)
 {
     if (!local_PLC_ERR)
     {
         return(S7_COM_FUN.Write_Req(cp_descr, cref, orderid, address, value) == 0);
     }
     Console.WriteLine("导轨Local_PLC_ERR故障,请排除故障并复位." + startAddress.ToString());
     return(false);
 }
Esempio n. 3
0
 /// <summary>
 /// 接收PLC数据
 /// </summary>
 /// <returns></returns>
 public void Receive()
 {
     while (true)
     {
         Thread.Sleep(3);
         int resw = S7_COM_FUN.Receive(Cp_descr, Cref, Orderid, ref ReadPara, Value_store);
         Thread.Sleep(3);
         while (!S7_COM_FUN.IsWriting)
         {
             Read_CNF = S7_COM_FUN.Receive(Cp_descr, Cref2, Orderid2, ref ReadPara, Value_store);
         }
     }
 }
Esempio n. 4
0
 /// <summary>
 /// 写bool信号
 /// </summary>
 /// <param name="address"></param>
 /// <param name="value"></param>
 /// <returns></returns>
 private bool write(string address, bool value)
 {
     return(S7_COM_FUN.Write_Req(cp_descr, cref, orderid, address, value) == 0);
 }
Esempio n. 5
0
 /// <summary>
 /// 发起读请求
 /// </summary>
 /// <returns></returns>
 public bool RequestRead()
 {
     return(S7_COM_FUN.s7_read_req(Cp_descr, Cref2, Orderid2, ref ReadPara) == 0);
 }
Esempio n. 6
0
 /// <summary>
 /// 初始化读参数,起始地址 字节
 /// </summary>
 private void InitialReadPara()
 {
     S7_COM_FUN.R_Struct_Inital(ref ReadPara, IniReadPara);//读取数据块1,V200开始150个字节
 }
Esempio n. 7
0
 /// <summary>
 /// s7初始化
 /// </summary>
 /// <returns></returns>
 private bool S7Initial()
 {
     return(S7_COM_FUN.Initial(i, ref Cp_descr) == 0);
 }
Esempio n. 8
0
 /// <summary>
 /// 写通讯成功标志位--以PLC验证通讯是否成功
 /// </summary>
 public bool SetComOK()
 {
     return(S7_COM_FUN.Write_Req(cp_descr, PLCsys.Cref2, PLCsys.Orderid2, PC_Communication_OK_Address, true) == 0);
 }