如何仅在数组中选择结果 [英] How do I select results only in an array

查看:112
本文介绍了如何仅在数组中选择结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我尝试将pc连接到实验室设备。我可以从设备获取消息。但问题在于分割结果。



这里是我从设备收到的文字

< ; STX> 1 H | \ ^&安培; ||| H7600 ^ 1个|||||主机| RSUPL ^ BATCH | P | 1·; CR> P | 1 |||||||ù|||||| ^< CR&≠0 | 1 | mithat | 0 ^ 50010 ^ 010 ^^ S1 ^ SC | ^^^ 687 ^ \ ^^^ 685 ^ \ ^^^ 418 ^ \ ^^^ 717 ^ \ ^^^ 19 ^ \ ^^ ^ 698 ^ \ ^^^ 700 ^ \ ^^^ 690 ^ | R ||||||ñ|||| ||||||| 1 ||| 20160430020618 F< CR&以及c | 1 |我| < ETB> BE< CR>< LF>< STX> 2 ^ ^ ^ ^ | G< CR> R | 1 | ^^^ 687 / | 12.5 | U / l || N || F || bmserv ||| P1< CR&以及c | 1 | I | 0 | I< CR> R | 2 | ^^^ 685 / | 12.7 | U /升||ñ||˚F|| bmserv ||| P1< CR> ç| 1 | I | 0 | I< CR> R | 3 | ^^^ 418 / | 35.1 |毫克/分升||ñ||˚F|| bmserv ||| P1< CR&以及c | 1 | I | 0 | I< CR> R | 4 | ^^^< ETB> 4D< CR>< LF>< STX> 3717 / | 101.5 |毫克/分升||ñ||˚F|| bmserv ||| P1< CR&以及c | 1 | I | 0 | I< CR> R | 5 | ^^^ 19 / | 0.186 |毫克/分升||ñ||˚F|| bmserv ||| P1< CR&以及c | 1 | I | 0 | I< CR> R | 6 | ^^^ 698 / | 10.48 |毫克/分升||ħ||˚F|| bmserv ||| P1< CR&以及c | 1 | I | 0 | I< CR> [R | 7 | ^^^ 700 / | 4.0 |毫克/分升|| ||ñ||˚F||| bmserv P1< CR&以及c | 1 | I | 0 | I< CR> R | 8 | ^^^ 690 / | 0.67 |毫克/分升||大号||˚F|| bmserv ||< ETB> C1< CR>< LF>< STX→4 | P1< CR&以及c | 1 | I | 0 | I< ; CR> L | 1 | N< CR>< ETX> 44< CR>< LF>< EOT> 





我想得到名称(或ID)是mitat,结果从

< CR> R | 1 | ^^^ 687 / | 12.5 | U / l || N || F开始|| bmser v ||| P1< CR&以及c | 1 | I | 0 | I< CR> R | 2 | ^^^ 685 / | 12.7 | U /升||Ñ||˚F|| bmserv ||| P1< CR> ; c ^ | 1 | I | 0 | I< CR> R | 3 | ^^^ 418 / | 35.1 |毫克/分升||ñ||˚F|| bmserv ||| P1< CR&以及c | 1 | I | 0 | I< CR> R | 4 | ^^^< ETB> 4D< CR>< LF>< STX> 3717 / | 101.5 |毫克/分升||ñ||˚F|| bmserv ||| P1< ; CR&以及c | 1 | I | 0 | I< CR> R | 5 | ^^^ 19 / | 0.186 |毫克/分升||ñ||˚F|| bmserv ||| P1< CR&以及c | 1 | I | 0 | I< CR> R | 6 | ^^^ 698 / | 10.48 |毫克/分升||ħ||˚F|| bmserv ||| P1< CR&以及c | 1 | I | 0 | I< CR> ; R | 7 | ^^^ 700 / | 4.0 |毫克/分升||ñ||˚F|| bmserv ||| P1< CR&以及c | 1 | I | 0 | I< CR> R | 8 | ^^ ^ 690 / | 0.67 | mg / dl || L || F || bmserv ||< ETB> C1< CR> 







怎么才能得到这个?



谢谢。



我尝试了什么:



  private   void  button1_Click( object  sender,EventArgs e)
{
string [] gelen = tbMetin.Text.Spl它(' |');
string [] bolmeKriteri = new string [] { \\r};
string [] sonuclar;
string [] kalanlar;
if (gelen.Length > 11
{
if (gelen [ 10 ] == RSUPL ^ REAL
{
listBox.Items.Add(< span class =code-string> TekSonuçGeldi);
for int i = 11 ; i< gelen.length; i ++)>
{
sonuclar = gelen [i] .Split(bolmeKriteri,StringSplitOptions.None );
for int j = 0 ; j< sonuclar.length; j ++)>
{
listBox.Items.Add(sonuclar [j]);
}
}
} 其他 如果(gelen [ 10 ] == RSUPL ^ BATCH
{
listBox.Items.Add( TopluSonuçGeldi。) ;
for int i = 11 ; i < gelen.Length; i ++)
{
sonuclar = gelen [i] .Split(bolmeKriteri,StringSplitOptions.None) ;
for int j = 0 ; j < sonuclar.Length; j ++)
{
listBox.Items.Add(sonuclar [j]);
}
}
}
}
}

解决方案

我的猜测你所展示的不是你收到的,而是预处理以显示不可打印的字符。

< cr>作为回车符。

< stx> 1H | \ ^& ||| H7600 ^ 1 ||||| host | RSUPL ^ BATCH | P | 1·; CR> 
P | 1 ||||||| U |||||| ^< cr>
O | 1 | mithat | 0 ^ 50010 ^ 010 ^^ S1 ^ SC | ^^^ 687 ^ \ ^^^ 685 ^ \ ^^^ 418 ^ \ ^^^ 717 ^ \ ^^^ 19 ^ \ ^^ ^ 698 ^ \ ^^^ 700 ^ \ ^^^ 690 ^ | R ||||||ñ|||| ||||||| 1 ||| 20160430020618 F< CR>
C | 1 | I | < etb> BE< cr>< lf>< stx> 2 ^ ^ ^ | G< cr>
R | 1 | ^^^ 687 / | 12.5 | U / l || N || F || bmserv ||| P1< cr>
C | 1 | I | 0 | I< cr>
R | 2 | ^^^ 685 / | 12.7 | U / l || N || F || bmserv ||| P1< cr>
C | 1 | I | 0 | I< cr>
R | 3 | ^^^ 418 / | 35.1 | mg / dl || N || F || bmserv ||| P1< cr>
C | 1 | I | 0 | I< cr>
R | 4 | ^^^< etb> 4D< cr>
< lf>< stx> 3717 / | 101.5 | mg / dl || N || F || bmserv ||| P1< cr>
C | 1 | I | 0 | I< cr>
R | 5 | ^^^ 19 / | 0.186 | mg / dl || N || F || bmserv ||| P1< cr>
C | 1 | I | 0 | I< cr>
R | 6 | ^^^ 698 / | 10.48 | mg / dl || H || F || bmserv ||| P1< cr>
C | 1 | I | 0 | I< cr>
R | 7 | ^^^ 700 / | 4.0 | mg / dl || N || F || bmserv ||| P1< cr>
C | 1 | I | 0 | I< cr>
R | 8 | ^^^ 690 / | 0.67 | mg / dl || L || F || bmserv ||< etb>
C1< cr>< lf>
< stx> 4 | P1< cr>
C | 1 | I | 0 | I< cr>
L | 1 | N< cr>
< etx> 44< cr>< lf>
< eot>





您必须检查接收数据的方式,当然还必须阅读文档。


hi all,

i try to connect pc to laboratory device. i can get message from the device. but the problem is splitting the results.

here is the text i received from the device

<STX>1H|\^&|||H7600^1|||||host|RSUPL^BATCH|P|1<CR>P|1|||||||U||||||^<CR>O|1|            mithat|0^50010^010^^S1^SC|^^^687^\^^^685^\^^^418^\^^^717^\^^^19^\^^^698^\^^^700^\^^^690^|R||||||N||||1|||||||20160430020618|||F<CR>C|1|I|                          <ETB>BE<CR><LF><STX>2    ^                         ^                    ^               ^          |G<CR>R|1|^^^687/|12.5|U/l||N||F||bmserv|||P1<CR>C|1|I|0|I<CR>R|2|^^^685/|12.7|U/l||N||F||bmserv|||P1<CR>C|1|I|0|I<CR>R|3|^^^418/|35.1|mg/dl||N||F||bmserv|||P1<CR>C|1|I|0|I<CR>R|4|^^^<ETB>4D<CR><LF><STX>3717/|101.5|mg/dl||N||F||bmserv|||P1<CR>C|1|I|0|I<CR>R|5|^^^19/|0.186|mg/dl||N||F||bmserv|||P1<CR>C|1|I|0|I<CR>R|6|^^^698/|10.48|mg/dl||H||F||bmserv|||P1<CR>C|1|I|0|I<CR>R|7|^^^700/|4.0|mg/dl||N||F||bmserv|||P1<CR>C|1|I|0|I<CR>R|8|^^^690/|0.67|mg/dl||L||F||bmserv||<ETB>C1<CR><LF><STX>4|P1<CR>C|1|I|0|I<CR>L|1|N<CR><ETX>44<CR><LF><EOT>



I want to get the name ( or ID) which is mitat and results begin from

<CR>R|1|^^^687/|12.5|U/l||N||F||bmserv|||P1<CR>C|1|I|0|I<CR>R|2|^^^685/|12.7|U/l||N||F||bmserv|||P1<CR>C|1|I|0|I<CR>R|3|^^^418/|35.1|mg/dl||N||F||bmserv|||P1<CR>C|1|I|0|I<CR>R|4|^^^<ETB>4D<CR><LF><STX>3717/|101.5|mg/dl||N||F||bmserv|||P1<CR>C|1|I|0|I<CR>R|5|^^^19/|0.186|mg/dl||N||F||bmserv|||P1<CR>C|1|I|0|I<CR>R|6|^^^698/|10.48|mg/dl||H||F||bmserv|||P1<CR>C|1|I|0|I<CR>R|7|^^^700/|4.0|mg/dl||N||F||bmserv|||P1<CR>C|1|I|0|I<CR>R|8|^^^690/|0.67|mg/dl||L||F||bmserv||<ETB>C1<CR>




how can i get this?

Thank you.

What I have tried:

private void button1_Click(object sender, EventArgs e)
        {
            string[] gelen = tbMetin.Text.Split('|');
            string[] bolmeKriteri = new string[] { "\\r" };
            string[] sonuclar;
            string[] kalanlar;
            if (gelen.Length > 11)
            {
                if(gelen[10]== "RSUPL^REAL")
                {
                    listBox.Items.Add("Tek Sonuç Geldi");
                    for(int i=11;i<gelen.length;i++)>
                    {
                        sonuclar = gelen[i].Split(bolmeKriteri, StringSplitOptions.None);
                        for (int j=0;j<sonuclar.length;j++)>
                        {
                            listBox.Items.Add(sonuclar[j]);
                        }
                    }
                }else if(gelen[10]== "RSUPL^BATCH")
                {
                    listBox.Items.Add("Toplu Sonuç Geldi.");
                    for (int i = 11; i < gelen.Length; i++)
                    {
                        sonuclar = gelen[i].Split(bolmeKriteri, StringSplitOptions.None);
                        for (int j = 0; j < sonuclar.Length; j++)
                        {
                            listBox.Items.Add(sonuclar[j]);
                        }
                    }
                }
            }
        }

解决方案

My guess is that what you show is not what you received and that it is preprocessed to show non printable chars.
<cr> being the Carriage Return.

<stx>1H|\^&|||H7600^1|||||host|RSUPL^BATCH|P|1<cr>
P|1|||||||U||||||^<cr>
O|1|            mithat|0^50010^010^^S1^SC|^^^687^\^^^685^\^^^418^\^^^717^\^^^19^\^^^698^\^^^700^\^^^690^|R||||||N||||1|||||||20160430020618|||F<cr>
C|1|I|                          <etb>BE<cr><lf><stx>2    ^                         ^                    ^               ^          |G<cr>
R|1|^^^687/|12.5|U/l||N||F||bmserv|||P1<cr>
C|1|I|0|I<cr>
R|2|^^^685/|12.7|U/l||N||F||bmserv|||P1<cr>
C|1|I|0|I<cr>
R|3|^^^418/|35.1|mg/dl||N||F||bmserv|||P1<cr>
C|1|I|0|I<cr>
R|4|^^^<etb>4D<cr>
<lf><stx>3717/|101.5|mg/dl||N||F||bmserv|||P1<cr>
C|1|I|0|I<cr>
R|5|^^^19/|0.186|mg/dl||N||F||bmserv|||P1<cr>
C|1|I|0|I<cr>
R|6|^^^698/|10.48|mg/dl||H||F||bmserv|||P1<cr>
C|1|I|0|I<cr>
R|7|^^^700/|4.0|mg/dl||N||F||bmserv|||P1<cr>
C|1|I|0|I<cr>
R|8|^^^690/|0.67|mg/dl||L||F||bmserv||<etb>
C1<cr><lf>
<stx>4|P1<cr>
C|1|I|0|I<cr>
L|1|N<cr>
<etx>44<cr><lf>
<eot>



You have to check how you receive the data, and certainly have to read the documentation.


这篇关于如何仅在数组中选择结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆