当前位置: 首页>>代码示例>>C#>>正文


C# IMessage.WriteString方法代码示例

本文整理汇总了C#中IMessage.WriteString方法的典型用法代码示例。如果您正苦于以下问题:C# IMessage.WriteString方法的具体用法?C# IMessage.WriteString怎么用?C# IMessage.WriteString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMessage的用法示例。


在下文中一共展示了IMessage.WriteString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: send_to_instrument

        //send to instrument by visacom
        private string send_to_instrument(string fullcmd,string address,string cmd, IMessage ioDmm,int delay = 0)
        {
            WriteTraceText(fullcmd);
            //IVisaSession basesession = null;
            //IMessage talksession = null;

            string strRd = "";
            string instrumentAddress = address;
            //lock
            //this.WriteTraceText("\n");
            lock (_lock_Instrument)
            {

                    ioDmm.Clear();
                    ioDmm.WriteString(cmd);

                    if (delay != 0 && delay > 500)
                        Thread.Sleep(delay);
                    else
                        Thread.Sleep(500);
                    if (cmd.Contains("?"))
                    {
                        for (int i = 0; i < 5; i++)
                        {

                            try
                            {

                                strRd = ioDmm.ReadString(4069);
                                break;
                            }
                            catch (Exception exp)
                            {
                                ioDmm.Clear();
                                if (i != 9)
                                {
                                    Thread.Sleep(200);
                                    continue;

                                }
                                else
                                {
                                    WriteErrorText("write/read to instrumen by visacom error: " + exp.Message);
                                    throw new Exception(exp.Message);
                                }

                            }

                        }

                    }

            }
            strRd = strRd.TrimEnd('\n');
            return strRd;
        }
开发者ID:mahabara,项目名称:RTT,代码行数:57,代码来源:MainForm.cs

示例2: SaCapturebyVisacom

        //in visacom mode
        private void SaCapturebyVisacom(IMessage sesnCapture,string name = "",int delay = 5000)
        {
            StringBuilder filename = new StringBuilder();
            if (name != "")
            {
                filename.Append(name).Append(@".png");
            }
            else
            {
                filename.Append(DateTime.Now.ToString("yyyy-MM-dd_HH_mm_ss")).Append(@".png");
            }
            string cmd = "MMEM:STOR:SCR \"D:\\rttscr.png\"";//;*OPC?
            sesnCapture.WriteString(cmd);
            sesnCapture.WriteString("MMEM:DATA? \"D:\\rttscr.png\"");

            //this.sa_sesn.WriteString("CALCulate:DATA?");

            byte[] readbuf;

            readbuf = sesnCapture.Read(1000000);
            //WriteDebugText(Encoding.ASCII.GetString(readbuf));
            //if(delay>5000)
            //    Thread.Sleep(delay);
            //else
            //    Thread.Sleep(5000);
            sesnCapture.WriteString("MMEM:DEL \"D:\\rttscr.png\"");
            sesnCapture.WriteString("*CLS");

            byte[] size = { readbuf[1] };

            byte[] newbuf = readbuf.Skip(2+ int.Parse(Encoding.ASCII.GetString(size))).Take(readbuf.Length-9).ToArray();

            File.WriteAllBytes(_snapPath + filename.ToString(), newbuf);
        }
开发者ID:mahabara,项目名称:RTT,代码行数:35,代码来源:MainForm.cs


注:本文中的IMessage.WriteString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。