tx198835
級別: 略有小成
|
圖片:
有做過上位機的朋友嗎,請教SQL批量獲取M0 256點 D0 256點,該如何做,關鍵是刷新時間問題 下面我是剛寫的思路往各位大神指正: /// <summary> /// Act控件初始化 /// </summary> public Form1() { InitializeComponent(); axActUtlType1.ActLogicalStationNumber = 10; axActUtlType1.ActPassword = ""; } // 按鈕獲取值 private void button1_Click(object sender, EventArgs e) { textBox1.Clear(); short[] M_Memory = new short[16]; axActUtlType1.Open(); axActUtlType1.ReadDeviceBlock2("m0", 256, out M_Memory[0]); for (int i = 0; i < 256; i++) { if (Mitsubishi.Mitsubishi_M_Memory(M_Memory) == true) { textBox1.AppendText("M" + i + "= 1 "); } else { textBox1.AppendText("M" + i + "= 0 "); } } } /// <summary> /// mx compoment讀取的值轉換成 /// </summary> /// <param name="M_Ararry">要轉換的byte數組</param> /// <returns>B00L數組</returns> public static bool[] Mitsubishi_M_Memory(short[] M_Memory) { int a = 0; bool[] b = new bool[256]; for (int j = 0; j < M_Memory.Length; j++) { for (int i = 0; i < 16; i++) { if ((0x01 & M_Memory[j] >> i) == 1) { b[a] = true; a++; } else { b[a] = false; a++; } } } return b; } [ 此帖被tx198835在2019-09-13 04:23重新編輯 ] |
---|---|
|