Beispiel #1
0
        private void button6_Click(object sender, EventArgs e)
        {
            //从最历史的时间开始
            ushort a = Convert.ToUInt16(textBox3.Text), b = Convert.ToUInt16(textBox4.Text);//b-a<=9

            Fanuc.ODBAHIS5 odbahis5 = new Focas1.ODBAHIS5();
            int            all      = b - a + 1;
            ushort         length   = (ushort)((all) * 516 + 4);

            int ret = Fanuc.cnc_rdalmhistry5(Fanuc.h, a, b, length, odbahis5);

            if (ret == Fanuc.EW_OK)
            {
                ushort sno = odbahis5.s_no;
                ushort eno = odbahis5.e_no;

                Fanuc.ALM_HIS5 almhis5 = new Focas1.ALM_HIS5();
                almhis5 = odbahis5.alm_his;

                string time    = "";
                string message = "";
                string almno   = "";
                string almgrp  = "";

                listBox1.Items.Clear();
                listBox1.Items.Add("时间               |错误码         |消息");
                for (int i = 1; i < all + 1; i++)
                {
                    time = "";
                    object datao = Help.getfield(almhis5, "data" + i);
                    time   += Help.getfield(datao, "year").ToString().PadLeft(4, '0');
                    time   += "/";
                    time   += Help.getfield(datao, "month").ToString().PadLeft(2, '0');
                    time   += "/";
                    time   += Help.getfield(datao, "day").ToString().PadLeft(2, '0');
                    time   += " ";
                    time   += Help.getfield(datao, "hour").ToString().PadLeft(2, '0');
                    time   += ":";
                    time   += Help.getfield(datao, "minute").ToString().PadLeft(2, '0');
                    time   += ":";
                    time   += Help.getfield(datao, "second").ToString().PadLeft(2, '0');
                    message = Help.getfield(datao, "alm_msg").ToString();
                    almgrp  = Fanuc.getalmgrp(Convert.ToInt16(Help.getfield(datao, "alm_grp")));
                    almno   = Help.getfield(datao, "alm_no").ToString().PadLeft(4, '0');
                    string temp = almgrp + almno;
                    listBox1.Items.Add(time + "|" + temp.PadRight(15, ' ') + "|" + message);
                }
            }
            else
            {
                MessageBox.Show(ret + "");
            }
        }