public static void writeDT(string DTaddr1, string DTaddr2, double[] value) { var str = DTaddr1.Substring(0, 1); var text = DTaddr1.Substring(1, DTaddr1.Length - 1); var text2 = DTaddr2.Substring(1, DTaddr2.Length - 1); var num = (int)(Convert.ToInt16(text2) - Convert.ToInt16(text) + 1); text = text.PadLeft(5).Replace(" ", "0"); text2 = text2.PadLeft(5).Replace(" ", "0"); var str2 = str + text + text2; var text3 = ""; for (int i = 0; i < num; i++) { var text4 = ((int)(value[i] * 1000.0)).ToString(); text4 = Convert.ToInt32(text4).ToString("X4"); text4 = text4.Substring(2, 2) + text4.Substring(0, 2); text3 += text4; } var text5 = "%01#WD" + str2 + text3; text5 = text5 + PLC.bcc(text5) + "\r"; PLC.COMM.Write(text5); PLC.SetText("[PC->PLC]:" + text5); }
public static void read_RCS(string XYMaddr) { var str = XYMaddr.Substring(0, 1); var str2 = XYMaddr.Substring(1, XYMaddr.Length - 1).PadLeft(4).Replace(" ", "0"); var text = "%01#RCS" + str + str2; text = text + PLC.bcc(text) + "\r"; PLC.COMM.Write(text); PLC.SetText("[PC->PLC]:" + text); }
public static void setM(string XYMaddr, int value) { var str = XYMaddr.Substring(0, 1); var str2 = XYMaddr.Substring(1, XYMaddr.Length - 1).PadLeft(4).Replace(" ", "0"); var text = "%01#WCS" + str + str2 + value.ToString(); text = text + PLC.bcc(text) + "\r"; PLC.COMM.Write(text); PLC.SetText("[PC->PLC]:" + text); }
public static void readDT(string DTaddr1, string DTaddr2) { var str = DTaddr1.Substring(0, 1); var text = DTaddr1.Substring(1, DTaddr1.Length - 1); var text2 = DTaddr2.Substring(1, DTaddr2.Length - 1); Convert.ToInt16(text2); Convert.ToInt16(text); text = text.PadLeft(5).Replace(" ", "0"); text2 = text2.PadLeft(5).Replace(" ", "0"); var str2 = str + text + text2; var text3 = "%01#RD" + str2; text3 = text3 + PLC.bcc(text3) + "\r"; PLC.COMM.Write(text3); PLC.SetText("[PC->PLC]:" + text3); }