public void TestAt()
        {
            List <byte> dense = new List <byte> {
                1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1
            };
            Sdr sut = new Sdr(new int[] { 2, 8 });

            sut.SetDense(dense);

            byte element0 = sut.At(new List <int> {
                0, 0
            });
            byte element1 = sut.At(new List <int> {
                1, 0
            });
            byte element2 = sut.At(new List <int> {
                0, 1
            });
            byte element3 = sut.At(new List <int> {
                1, 1
            });
            byte element14 = sut.At(new List <int> {
                0, 7
            });
            byte element15 = sut.At(new List <int> {
                1, 7
            });

            Assert.AreEqual(dense[0], element0);
            Assert.AreEqual(dense[1], element1);
            Assert.AreEqual(dense[2], element2);
            Assert.AreEqual(dense[3], element3);
            Assert.AreEqual(dense[14], element14);
            Assert.AreEqual(dense[15], element15);
        }
Beispiel #2
0
        /// <summary>
        /// Send a HTTP GET request to an API endpoint that returns an SDR as a result.
        /// </summary>
        /// <param name="requestUrl"></param>
        /// <returns>A <see cref="Task"> object containing an SDR of the output as result.</returns>
        private static async Task <Sdr> GetSdrAsync(string requestUrl)
        {
            string responseString = await GetResponseStringAsync(requestUrl);

            Sdr sdr = CreateSdrFromResponse(responseString);

            return(sdr);
        }
Beispiel #3
0
        private void Form2_Load(object sender, EventArgs e)
        {
            //设置为允许跨线程调用空间
            Control.CheckForIllegalCrossThreadCalls = false;

            DataSet ds;

            ds = MyMeans.GetDataSet("Select*from daifaml");
            dataGridView1.DataSource = ds.Tables[0];
            MyMeans.Close();
            ds = MyMeans.GetDataSet("Select*from fasongml");
            dataGridView2.DataSource = ds.Tables[0];
            MyMeans.Close();
            ds = MyMeans.GetDataSet("Select*from yifaml");
            dataGridView3.DataSource = ds.Tables[0];
            MyMeans.Close();
            ds = MyMeans.GetDataSet("Select*from shoulinglb");
            dataGridView4.DataSource = ds.Tables[0];
            MyMeans.Close();

            MyMeans.linq = new linqtosqlClassDataContext(MyMeans.Constr);
            var result = from items in MyMeans.linq.mlmoban
                         select new
            {
                Number  = items.模板编号,
                LeiXing = items.命令类型,
                NeiRong = items.命令内容,
            };

            foreach (var item in result)
            {
                comboBox1.Items.Add(item.LeiXing);
            }
            SqlDataReader Sdr;

            MyMeans.SQLstr = "select*from changyongch";
            Sdr            = MyMeans.GgtDataReader(MyMeans.SQLstr);
            while (Sdr.Read())
            {
                listBox1.Items.Add(Sdr[0]);
            }

            try //连接服务器,若连接成功,通信状态显示为“通信正常”;
            {
                socket.Connect(IPP);
                string SendStr = "行调系统";
                byte[] Bs      = Encoding.UTF8.GetBytes(SendStr);
                socket.Send(Bs, Bs.Length, 0);
                label7.Text             = "通信正常";
                jieshouMsg              = new Thread(new ThreadStart(RecMsg));
                jieshouMsg.IsBackground = true;
                jieshouMsg.Start();
            }
            catch
            {
            }
            textBox4.Text = Form1.Uers_Now;
        }
Beispiel #4
0
        private void button6_Click(object sender, EventArgs e)
        {
            Number_ML = 6000;
            SqlDataReader Sdr;

            MyMeans.SQLstr = "select*from daifaml";
            Sdr            = MyMeans.GgtDataReader(MyMeans.SQLstr);
            while (Sdr.Read())
            {
                if (int.Parse(Sdr[0].ToString().Trim()) > Number_ML)
                {
                    Number_ML = int.Parse(Sdr[0].ToString());
                }
            }
            MyMeans.SQLstr = "select*from fasongml";
            Sdr            = MyMeans.GgtDataReader(MyMeans.SQLstr);
            while (Sdr.Read())
            {
                if (int.Parse(Sdr[0].ToString().Trim()) > Number_ML)
                {
                    Number_ML = int.Parse(Sdr[0].ToString());
                }
            }
            MyMeans.SQLstr = "select*from yifaml";
            Sdr            = MyMeans.GgtDataReader(MyMeans.SQLstr);
            while (Sdr.Read())
            {
                if (int.Parse(Sdr[0].ToString().Trim()) > Number_ML)
                {
                    Number_ML = int.Parse(Sdr[0].ToString());
                }
            }
            Number_ML++;
            textBox2.Text = Number_ML.ToString();

            textBox4.Text = Form1.Uers_Now;
            textBox5.Text = "调度台";
            //加载模板内容
            MyMeans.linq = new linqtosqlClassDataContext(MyMeans.Constr);    //创建LINQ连接对象
            String StrLeiXing = comboBox1.Text;                              //获取选中的命令模板
            //根据选中的命令模板获取其详细信息
            var result = from items in MyMeans.linq.mlmoban
                         where items.命令类型 == StrLeiXing
                         select new
            {
                Number  = items.模板编号,
                命令类型    = items.命令类型,
                NeiRong = items.命令内容
            };

            //在命令内容正文控件中显示选中命令模板的命令内容
            foreach (var item in result)
            {
                richTextBox1.Text = item.NeiRong.ToString();
            }
        }
Beispiel #5
0
        public void TestSdr()
        {
            var sdr = new Sdr
            {
                HeadNumber = 1,
            };

            TestRoundTripEquality(sdr);
            sdr.ExtraId = "Professor Snape";
            TestRoundTripEquality(sdr);
        }
        public void TestTwoDimensionalSparse()
        {
            List <int> sparse = new List <int> {
                1, 6, 8, 63
            };
            Sdr sut = new Sdr(new int[] { 8, 8 });

            sut.SetSparse(sparse);

            List <int> result = sut.GetSparse();

            Assert.AreEqual(sparse, result);
        }
        public void TestOneDimensionalSparseFromDense()
        {
            List <byte> dense = new List <byte> {
                1, 1, 0, 0, 0, 0, 0, 0
            };
            List <int> expected = new List <int> {
                0, 1
            };
            Sdr sut = new Sdr(new int[] { 8 });

            sut.SetDense(dense);

            List <int> result = sut.GetSparse();

            Assert.AreEqual(expected, result);
        }
        public void TestTwoDimensionalDenseFromSparse()
        {
            List <byte> expected = new List <byte> {
                1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1
            };
            List <int> sparse = new List <int> {
                0, 1, 14, 15
            };
            Sdr sut = new Sdr(new int[] { 8, 2 });

            sut.SetSparse(sparse);

            List <byte> result = sut.GetDense();

            Assert.AreEqual(expected, result);
        }
Beispiel #9
0
        private void WriteSdr(int numberOfSites, LotInfo lotInfo)
        {
            Sdr sdr = new Sdr();

            sdr.HEAD_NUM              = 1;
            sdr.RecordHeader.REC_LEN += 1;
            sdr.SITE_GRP              = 1;
            sdr.RecordHeader.REC_LEN += 1;
            sdr.SITE_CNT              = (byte)numberOfSites;
            sdr.RecordHeader.REC_LEN += 1;
            sdr.SITE_NUM              = sitesGenerator(numberOfSites);// new byte[] { 1, 2, 3, 4, ... };
            sdr.RecordHeader.REC_LEN += (ushort)sdr.SITE_NUM.Length;
            sdr.HAND_ID = lotInfo.HAND_ID;
            sdr.RecordHeader.REC_LEN += (ushort)(sdr.HAND_ID.Length);
            sdr.LOAD_ID = lotInfo.LOAD_ID;
            sdr.RecordHeader.REC_LEN += (ushort)(sdr.LOAD_ID.Length);
            sfw.WriteRecord(sdr);
        }