/// <summary> /// 急停3 /// </summary> /// <param name="siemensTcpNet"></param> /// <returns></returns> public bool WriteStopCommand(SiemensS7Net_New siemensTcpNet) { InitDbRun(); int writeData = 3; if (stopFlag) { writeData = 0; if (siemensTcpNet.Write(dbRun["启动"], writeData).IsSuccess) { stopFlag = false; return(true); } } else { if (siemensTcpNet.Write(dbRun["启动"], writeData).IsSuccess) { stopFlag = true; return(true); } } return(false); }
/// <summary> /// 运行指令1:运行,延时500ms置0 /// </summary> /// <param name="siemensTcpNe"></param> /// <returns></returns> public bool WriteRunCommand(SiemensS7Net_New siemensTcpNet) { InitDbRun(); int writeData = 1; //string Info = "运行成功"; //if (siemensTcpNet.Write("DB100.64", writeData).IsSuccess) if (siemensTcpNet.Write(dbRun["运行指令"], writeData).IsSuccess) { Thread.Sleep(1000); writeData = 0; ////if (siemensTcpNet.Write("DB100.64", writeData).IsSuccess) if (siemensTcpNet.Write(dbRun["运行指令"], writeData).IsSuccess) { //LogNet.WriteDebug(Info); return(true); } //this.toolStripStatusLabelSwitch.Text = Info; } //else //{ // //this.toolStripStatusLabelSwitch.Text = "运行失败"; // return false; //} return(false); }
/// <summary> /// 启动指令2 /// </summary> /// <param name="siemensTcpNet"></param> /// <returns></returns> public bool WriteOpenCommand(SiemensS7Net_New siemensTcpNet) { //InitDbRun(); int writeData = 2; if (siemensTcpNet.Write(dbRun["启动"], writeData).IsSuccess) { Thread.Sleep(1000); if (WriteResetCommand(siemensTcpNet)) { LogNet.WriteInfo("启动成功"); return(true); } else { LogNet.WriteInfo("启动复位成功"); } } else { LogNet.WriteInfo("启动失败"); return(false); } return(false); }
/// <summary> /// 写入301指令:3:回原位 1:左 2:右 (针对货叉两侧货架均可操作的情况) /// </summary> /// <param name="siemensTcpNet"></param> /// <param name="commandNum"></param> /// <param name="commandType"></param> /// <param name="telescopic">伸缩</param> /// <returns></returns> public bool WriteThreeZeroOneCommand(SiemensS7Net_New siemensTcpNet, int commandNum, int commandType, int telescopic) { InitDbRun(); if ( siemensTcpNet.Write(dbRun["指令号"], commandNum).IsSuccess&& siemensTcpNet.Write(dbRun["指令类型"], commandType).IsSuccess&& siemensTcpNet.Write(dbRun["左"], telescopic).IsSuccess ) { Thread.Sleep(1000); if (WriteRunCommand(siemensTcpNet)) { return(true); } } return(false); }
/// <summary> /// 指令地址 /// </summary> //enum CommandAddress //{ // [EnumDescription("星期一")] // Monday, //} /// <summary> /// 写入101指令 /// </summary> /// <param name="commandNum">指令号</param> /// <param name="commandType">指令类型</param> /// <param name="x">大车位置</param> /// <param name="y">小车位置</param> /// <param name="z">起升位置</param> /// <returns></returns> public bool WriteOneZeroOneCommand(SiemensS7Net_New siemensTcpNet, int commandNum, int commandType, int x, int y, int z) { InitDbRun(); if ( siemensTcpNet.Write(dbRun["指令号"], commandNum).IsSuccess&& siemensTcpNet.Write(dbRun["指令类型"], commandType).IsSuccess&& siemensTcpNet.Write(dbRun["X1"], x).IsSuccess&& siemensTcpNet.Write(dbRun["Y1"], y).IsSuccess&& siemensTcpNet.Write(dbRun["Z1"], z).IsSuccess ) { Thread.Sleep(1000); if (WriteRunCommand(siemensTcpNet)) { return(true); } } return(false); }
/// <summary> /// 停止指令1 /// </summary> /// <param name="siemensTcpNet"></param> /// <returns></returns> public static bool WriteShutCommand(SiemensS7Net_New siemensTcpNet) { InitDbRun(); int writeData = 1; if (siemensTcpNet.Write(dbRun["启动"], writeData).IsSuccess) { return(true); } return(false); }
/// <summary> /// 停止指令1 /// </summary> /// <param name="siemensTcpNet"></param> /// <returns></returns> public bool WriteShutCommand(SiemensS7Net_New siemensTcpNet) { //InitDbRun(); int writeData = 1; if (siemensTcpNet.Write(dbRun["启动"], writeData).IsSuccess) { LogNet.WriteInfo("停止成功"); return(true); } else { LogNet.WriteInfo("停止失败"); return(false); } //return false; }
/// <summary> /// 写入102指令 /// </summary> /// <param name="siemensTcpNet"></param> /// <param name="commandNum"></param> /// <param name="commandType"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="z"></param> /// <param name="x1"></param> /// <param name="y1"></param> /// <param name="z1"></param> /// <returns></returns> public bool WriteOneZeroTwoCommand(SiemensS7Net_New siemensTcpNet, int commandNum, int commandType, int x, int y, int z, int x1, int y1, int z1) { InitDbRun(); if ( siemensTcpNet.Write(dbRun["指令号"], commandNum).IsSuccess&& siemensTcpNet.Write(dbRun["指令类型"], commandType).IsSuccess&& siemensTcpNet.Write(dbRun["X1"], x).IsSuccess&& siemensTcpNet.Write(dbRun["Y1"], y).IsSuccess&& siemensTcpNet.Write(dbRun["Z1"], z).IsSuccess&& siemensTcpNet.Write(dbRun["X2"], x1).IsSuccess&& siemensTcpNet.Write(dbRun["Y2"], y1).IsSuccess&& siemensTcpNet.Write(dbRun["Z2"], z1).IsSuccess ) { LogNet.WriteInfo(commandNum + " " + commandType + " " + x + " " + y + " " + z + " " + x1 + " " + y1 + " " + z1); Thread.Sleep(1000); if (WriteRunCommand(siemensTcpNet)) { return(true); } } return(false); }
public static bool WriteResetCommand(SiemensS7Net_New siemensTcpNet) { int writeData = 1, counter = 1; InitDbRun(); if (siemensTcpNet.Write(dbRun["复位"], writeData).IsSuccess) { Thread.Sleep(1000);//延时3s writeData = 0; if (siemensTcpNet.Write(dbRun["复位"], writeData).IsSuccess) { siemensTcpNet.Write(dbRun["复位"], writeData); siemensTcpNet.Write(dbRun["X2"], writeData); siemensTcpNet.Write(dbRun["Y2"], writeData); siemensTcpNet.Write(dbRun["Z2"], writeData); siemensTcpNet.Write(dbRun["X3"], writeData); siemensTcpNet.Write(dbRun["Y3"], writeData); siemensTcpNet.Write(dbRun["Z3"], writeData); siemensTcpNet.Write(dbRun["X4"], writeData); siemensTcpNet.Write(dbRun["Y4"], writeData); siemensTcpNet.Write(dbRun["Z4"], writeData); siemensTcpNet.Write(dbRun["取"], writeData); siemensTcpNet.Write(dbRun["左"], writeData); siemensTcpNet.Write(dbRun["运行指令"], writeData); } writeData = 101; if (siemensTcpNet.Write(dbRun["指令号"], counter).IsSuccess) { siemensTcpNet.Write(dbRun["指令类型"], writeData); OperateResult <byte[]> buffRead = siemensTcpNet.Read(dbRun["执行完成"], 36);//读取PLC反馈的数据 writeData = siemensTcpNet.ByteTransform.TransInt32(buffRead.Content, 4); siemensTcpNet.Write(dbRun["X1"], writeData); writeData = siemensTcpNet.ByteTransform.TransInt32(buffRead.Content, 8); siemensTcpNet.Write(dbRun["Y1"], writeData); writeData = siemensTcpNet.ByteTransform.TransInt32(buffRead.Content, 12); siemensTcpNet.Write(dbRun["Z1"], writeData); } } return(false); }
/// <summary> /// 写入1类指令 /// </summary> /// <param name="siemensTcpNet"></param> /// <param name="commandNum"></param> /// <param name="commandType"></param> /// <param name="listP">坐标集合</param> /// <returns></returns> public static bool WriteOneCommand(SiemensS7Net_New siemensTcpNet, int commandNum, List <P> listP, out int commandType) { InitDbRun(); if ( siemensTcpNet.Write(dbRun["指令号"], commandNum).IsSuccess ) { if (listP.Count == 1)//101 { commandType = 101; if ( siemensTcpNet.Write(dbRun["指令类型"], commandType).IsSuccess&& siemensTcpNet.Write(dbRun["X1"], listP[0].X).IsSuccess&& siemensTcpNet.Write(dbRun["Y1"], listP[0].Y).IsSuccess&& siemensTcpNet.Write(dbRun["Z1"], listP[0].Z).IsSuccess) { return(true); } } else if (listP.Count == 2)//102 { commandType = 102; if ( siemensTcpNet.Write(dbRun["指令类型"], commandType).IsSuccess&& siemensTcpNet.Write(dbRun["X1"], listP[0].X).IsSuccess&& siemensTcpNet.Write(dbRun["Y1"], listP[0].Y).IsSuccess&& siemensTcpNet.Write(dbRun["Z1"], listP[0].Z).IsSuccess&& siemensTcpNet.Write(dbRun["X2"], listP[1].X).IsSuccess&& siemensTcpNet.Write(dbRun["Y2"], listP[1].Y).IsSuccess&& siemensTcpNet.Write(dbRun["Z2"], listP[1].Z).IsSuccess ) { return(true); } } else if (listP.Count == 3)//103 { commandType = 103; if ( siemensTcpNet.Write(dbRun["指令类型"], commandType).IsSuccess&& siemensTcpNet.Write(dbRun["X1"], listP[0].X).IsSuccess&& siemensTcpNet.Write(dbRun["Y1"], listP[0].Y).IsSuccess&& siemensTcpNet.Write(dbRun["Z1"], listP[0].Z).IsSuccess&& siemensTcpNet.Write(dbRun["X2"], listP[1].X).IsSuccess&& siemensTcpNet.Write(dbRun["Y2"], listP[1].Y).IsSuccess&& siemensTcpNet.Write(dbRun["Z2"], listP[1].Z).IsSuccess&& siemensTcpNet.Write(dbRun["X3"], listP[2].X).IsSuccess&& siemensTcpNet.Write(dbRun["Y3"], listP[2].Y).IsSuccess&& siemensTcpNet.Write(dbRun["Z3"], listP[2].Z).IsSuccess ) { return(true); } } else if (listP.Count == 4)//104 { commandType = 104; if ( siemensTcpNet.Write(dbRun["指令类型"], commandType).IsSuccess&& siemensTcpNet.Write(dbRun["X1"], listP[0].X).IsSuccess&& siemensTcpNet.Write(dbRun["Y1"], listP[0].Y).IsSuccess&& siemensTcpNet.Write(dbRun["Z1"], listP[0].Z).IsSuccess&& siemensTcpNet.Write(dbRun["X2"], listP[1].X).IsSuccess&& siemensTcpNet.Write(dbRun["Y2"], listP[1].Y).IsSuccess&& siemensTcpNet.Write(dbRun["Z2"], listP[1].Z).IsSuccess&& siemensTcpNet.Write(dbRun["X3"], listP[2].X).IsSuccess&& siemensTcpNet.Write(dbRun["Y3"], listP[2].Y).IsSuccess&& siemensTcpNet.Write(dbRun["Z3"], listP[2].Z).IsSuccess&& siemensTcpNet.Write(dbRun["X4"], listP[3].X).IsSuccess&& siemensTcpNet.Write(dbRun["Y4"], listP[3].Y).IsSuccess&& siemensTcpNet.Write(dbRun["Z4"], listP[3].Z).IsSuccess ) { return(true); } } else { commandType = 101; return(false); } } commandType = 101; return(false); }
/// <summary> /// 写入104指令 /// </summary> /// <param name="siemensTcpNet"></param> /// <param name="commandNum"></param> /// <param name="commandType"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="z"></param> /// <param name="x1"></param> /// <param name="y1"></param> /// <param name="z1"></param> /// <param name="x2"></param> /// <param name="y2"></param> /// <param name="z2"></param> /// <param name="x3"></param> /// <param name="y3"></param> /// <param name="z3"></param> /// <returns></returns> public bool WriteOneZeroFourCommand(SiemensS7Net_New siemensTcpNet, int commandNum, int commandType, int x, int y, int z, int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3) { InitDbRun(); if ( siemensTcpNet.Write(dbRun["指令号"], commandNum).IsSuccess&& siemensTcpNet.Write(dbRun["指令类型"], commandType).IsSuccess&& siemensTcpNet.Write(dbRun["X1"], x).IsSuccess&& siemensTcpNet.Write(dbRun["Y1"], y).IsSuccess&& siemensTcpNet.Write(dbRun["Z1"], z).IsSuccess&& siemensTcpNet.Write(dbRun["X2"], x1).IsSuccess&& siemensTcpNet.Write(dbRun["Y2"], y1).IsSuccess&& siemensTcpNet.Write(dbRun["Z2"], z1).IsSuccess&& siemensTcpNet.Write(dbRun["X3"], x2).IsSuccess&& siemensTcpNet.Write(dbRun["Y3"], y2).IsSuccess&& siemensTcpNet.Write(dbRun["Z3"], z2).IsSuccess&& siemensTcpNet.Write(dbRun["X4"], x3).IsSuccess&& siemensTcpNet.Write(dbRun["Y4"], y3).IsSuccess&& siemensTcpNet.Write(dbRun["Z4"], z3).IsSuccess ) { Thread.Sleep(1000); if (WriteRunCommand(siemensTcpNet)) { return(true); } } return(false); }
public bool WriteResetCommand(SiemensS7Net_New siemensTcpNet) { int writeData = 1, counter = 1; //InitDbRun(); if (siemensTcpNet.Write(dbRun["复位"], writeData).IsSuccess) { Thread.Sleep(1000);//延时3s writeData = 0; if ( siemensTcpNet.Write(dbRun["复位"], writeData).IsSuccess && siemensTcpNet.Write(dbRun["X2"], writeData).IsSuccess && siemensTcpNet.Write(dbRun["Y2"], writeData).IsSuccess && siemensTcpNet.Write(dbRun["Z2"], writeData).IsSuccess && siemensTcpNet.Write(dbRun["X3"], writeData).IsSuccess && siemensTcpNet.Write(dbRun["Y3"], writeData).IsSuccess && siemensTcpNet.Write(dbRun["Z3"], writeData).IsSuccess && siemensTcpNet.Write(dbRun["X4"], writeData).IsSuccess && siemensTcpNet.Write(dbRun["Y4"], writeData).IsSuccess && siemensTcpNet.Write(dbRun["Z4"], writeData).IsSuccess && siemensTcpNet.Write(dbRun["取"], writeData).IsSuccess && siemensTcpNet.Write(dbRun["左"], writeData).IsSuccess && siemensTcpNet.Write(dbRun["运行指令"], writeData).IsSuccess ) { LogNet.WriteInfo("复位成功"); writeData = 101; if (siemensTcpNet.Write(dbRun["指令号"], counter).IsSuccess && siemensTcpNet.Write(dbRun["指令类型"], writeData).IsSuccess && siemensTcpNet.Write(dbRun["X1"], ReadX(siemensTcpNet)).IsSuccess && siemensTcpNet.Write(dbRun["Y1"], ReadY(siemensTcpNet)).IsSuccess && siemensTcpNet.Write(dbRun["Z1"], ReadZ(siemensTcpNet)).IsSuccess ) { LogNet.WriteInfo($"写入的当前位置:{counter},{writeData},{ReadX(siemensTcpNet)},{ReadY(siemensTcpNet)},{ReadZ(siemensTcpNet)}"); return(true); //siemensTcpNet.Write(dbRun["指令类型"], writeData); //OperateResult<byte[]> buffRead = siemensTcpNet.Read(dbRun["执行完成"], 36);//读取PLC反馈的数据 //writeData = siemensTcpNet.ByteTransform.TransInt32(buffRead.Content, 4); //siemensTcpNet.Write(dbRun["X1"], writeData); //siemensTcpNet.Write(dbRun["X1"], ReadX(siemensTcpNet)); //writeData = siemensTcpNet.ByteTransform.TransInt32(buffRead.Content, 8); //siemensTcpNet.Write(dbRun["Y1"], writeData); //siemensTcpNet.Write(dbRun["Y1"], ReadY(siemensTcpNet)); //writeData = siemensTcpNet.ByteTransform.TransInt32(buffRead.Content, 12); //siemensTcpNet.Write(dbRun["Z1"], writeData); //siemensTcpNet.Write(dbRun["Z1"], ReadZ(siemensTcpNet)); } else { LogNet.WriteInfo("写入当前位置失败"); return(false); } } } else { LogNet.WriteInfo("复位失败"); return(false); } return(false); }