Exemplo n.º 1
0
 public override int WriteDeviceString(string sDevice, int iSize, string sData)
 {
     sData = sData.PadRight(iSize * 2, '\0');
     int[] iData = new int[iSize];
     for (int i = 0; i < iData.Length; i++)
     {
         iData[i] = MITSUBISHILink.ASCIIStringToInt(sData.Substring((i * 2), 2));
     }
     return(WriteDeviceBlock(sDevice, iSize, ref iData));
 }
Exemplo n.º 2
0
 //初始化检测PLC
 private void CheckPLC()
 {
     try
     {
         mweight = new MITSUBISHILink(1);
         mweight.Open();
         mweight.Close();
     }
     catch { MessageBox.Show("初始化三菱PLC串口失败。"); }
     try
     {
         serialPort1 = new SerialPort(PortName, BaudRate, Paritys, DataBits, StopBit);
         serialPort1.Open();
         serialPort1.ReceivedBytesThreshold = 11;
         serialPort1.DataReceived          += new System.IO.Ports.SerialDataReceivedEventHandler(spReceive_DataReceived);
     }
     catch { MessageBox.Show("启动条码扫描对象失败!"); }
 }
Exemplo n.º 3
0
        public override int ReadDeviceString(string sDevice, int iSize, out string sData)
        {
            int result = 0;

            sData = "";
            int[] iData = new int[iSize];
            if ((result = ReadDeviceBlock(sDevice, iSize, out iData)) != 0)
            {
                return(result);
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < iData.Length; i++)
                {
                    sb.Append(MITSUBISHILink.IntToASCIIString(iData[i]));
                }
                sData = sb.ToString();
            }
            return(result);
        }