示例#1
0
        public static SqlDataReader ReaderSelect(MeasureE0Data d)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("select * from MeasureE0 ");
            return(WFNetLib.ADO.SQLServerOP.ReaderExecuteSQL(sql.ToString()));
        }
示例#2
0
        public static DataTable DataTableSelect(MeasureE0Data d)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("select * from MeasureE0 where ID=");
            sql.Append("");
            sql.Append(d.ID.ToString());
            sql.Append("");
            return(WFNetLib.ADO.SQLServerOP.DataTableSQL(sql.ToString()));
        }
示例#3
0
        public static int Delete(MeasureE0Data d)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("delete from MeasureE0 ");
            sql.Append(" where ID=");
            sql.Append("");
            sql.Append(d.ID.ToString());
            sql.Append("");
            return(WFNetLib.ADO.SQLServerOP.NonQuerySQL(sql.ToString()));
        }
示例#4
0
        public static int Update(MeasureE0Data d)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("update MeasureE0 set ");
            sql.Append("Source=");
            sql.Append("");
            sql.Append(d.Source.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("Ident=");
            sql.Append("'");
            sql.Append(d.Ident.ToString());
            sql.Append("'");
            sql.Append(", ");
            sql.Append("Time=");
            sql.Append("'");
            sql.Append(d.Time.ToString("yyyy-MM-dd HH:mm:ss"));
            sql.Append("'");
            sql.Append(", ");
            sql.Append("Reserve=");
            sql.Append("'");
            sql.Append(d.Reserve.ToString());
            sql.Append("'");
            sql.Append(", ");
            sql.Append("bRead=");
            sql.Append("");
            if (d.bRead)
            {
                sql.Append("1");
            }
            else
            {
                sql.Append("0");
            }
            sql.Append("");
            sql.Append(", ");
            sql.Append("A0=");
            sql.Append("");
            sql.Append(d.A0.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("A1=");
            sql.Append("");
            sql.Append(d.A1.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("A2=");
            sql.Append("");
            sql.Append(d.A2.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("A3=");
            sql.Append("");
            sql.Append(d.A3.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("A4=");
            sql.Append("");
            sql.Append(d.A4.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("A5=");
            sql.Append("");
            sql.Append(d.A5.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("A6=");
            sql.Append("");
            sql.Append(d.A6.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("A7=");
            sql.Append("");
            sql.Append(d.A7.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("A8=");
            sql.Append("");
            sql.Append(d.A8.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("A9=");
            sql.Append("");
            sql.Append(d.A9.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("AA=");
            sql.Append("");
            sql.Append(d.AA.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("AB=");
            sql.Append("");
            sql.Append(d.AB.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("C0=");
            sql.Append("");
            sql.Append(d.C0.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("C1=");
            sql.Append("");
            sql.Append(d.C1.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("C2=");
            sql.Append("");
            sql.Append(d.C2.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("C3=");
            sql.Append("");
            sql.Append(d.C3.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("C4=");
            sql.Append("");
            sql.Append(d.C4.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("C5=");
            sql.Append("");
            sql.Append(d.C5.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("C6=");
            sql.Append("");
            sql.Append(d.C6.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("C7=");
            sql.Append("");
            sql.Append(d.C7.ToString());
            sql.Append("");
            sql.Append(" where ID=");
            sql.Append("");
            sql.Append(d.ID.ToString()); sql.Append("");

            return(WFNetLib.ADO.SQLServerOP.NonQuerySQL(sql.ToString()));
        }
示例#5
0
        public static int Insert(MeasureE0Data d)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("insert into MeasureE0 (");
            sql.Append("Source, ");
            sql.Append("Ident, ");
            sql.Append("Time, ");
            sql.Append("Reserve, ");
            sql.Append("bRead, ");
            sql.Append("A0, ");
            sql.Append("A1, ");
            sql.Append("A2, ");
            sql.Append("A3, ");
            sql.Append("A4, ");
            sql.Append("A5, ");
            sql.Append("A6, ");
            sql.Append("A7, ");
            sql.Append("A8, ");
            sql.Append("A9, ");
            sql.Append("AA, ");
            sql.Append("AB, ");
            sql.Append("C0, ");
            sql.Append("C1, ");
            sql.Append("C2, ");
            sql.Append("C3, ");
            sql.Append("C4, ");
            sql.Append("C5, ");
            sql.Append("C6, ");
            sql.Append("C7");
            sql.Append(") values (");
            sql.Append("");
            sql.Append(d.Source.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("'");
            sql.Append(d.Ident.ToString());
            sql.Append("'");
            sql.Append(", ");
            sql.Append("'");
            sql.Append(d.Time.ToString("yyyy-MM-dd HH:mm:ss"));
            sql.Append("'");
            sql.Append(", ");
            sql.Append("'");
            sql.Append(d.Reserve.ToString());
            sql.Append("'");
            sql.Append(", ");
            sql.Append("");
            if (d.bRead)
            {
                sql.Append("1");
            }
            else
            {
                sql.Append("0");
            }
            sql.Append("");
            sql.Append(", ");
            sql.Append("");
            sql.Append(d.A0.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("");
            sql.Append(d.A1.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("");
            sql.Append(d.A2.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("");
            sql.Append(d.A3.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("");
            sql.Append(d.A4.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("");
            sql.Append(d.A5.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("");
            sql.Append(d.A6.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("");
            sql.Append(d.A7.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("");
            sql.Append(d.A8.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("");
            sql.Append(d.A9.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("");
            sql.Append(d.AA.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("");
            sql.Append(d.AB.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("");
            sql.Append(d.C0.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("");
            sql.Append(d.C1.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("");
            sql.Append(d.C2.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("");
            sql.Append(d.C3.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("");
            sql.Append(d.C4.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("");
            sql.Append(d.C5.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("");
            sql.Append(d.C6.ToString());
            sql.Append("");
            sql.Append(", ");
            sql.Append("");
            sql.Append(d.C7.ToString());
            sql.Append("");
            sql.Append(")");
            return(WFNetLib.ADO.SQLServerOP.NonQuerySQL(sql.ToString()));
        }
示例#6
0
        public static MeasureE0Data Construct(DataRow dr)
        {
            MeasureE0Data data = new MeasureE0Data();

            try { data.ID = Convert.ToInt64(dr["ID"]); }
            catch { }

            try { data.Source = Convert.ToInt32(dr["Source"]); }
            catch { }

            try { data.Ident = Convert.ToString(dr["Ident"]); }
            catch { }

            try { data.Time = Convert.ToDateTime(dr["Time"]); }
            catch { }

            try { data.Reserve = Convert.ToString(dr["Reserve"]); }
            catch { }

            try { data.bRead = Convert.ToBoolean(dr["bRead"]); }
            catch { }

            try { data.A0 = Convert.ToInt32(dr["A0"]); }
            catch { }

            try { data.A1 = Convert.ToInt32(dr["A1"]); }
            catch { }

            try { data.A2 = Convert.ToInt32(dr["A2"]); }
            catch { }

            try { data.A3 = Convert.ToInt32(dr["A3"]); }
            catch { }

            try { data.A4 = Convert.ToInt32(dr["A4"]); }
            catch { }

            try { data.A5 = Convert.ToInt32(dr["A5"]); }
            catch { }

            try { data.A6 = Convert.ToInt32(dr["A6"]); }
            catch { }

            try { data.A7 = Convert.ToInt32(dr["A7"]); }
            catch { }

            try { data.A8 = Convert.ToInt32(dr["A8"]); }
            catch { }

            try { data.A9 = Convert.ToInt32(dr["A9"]); }
            catch { }

            try { data.AA = Convert.ToInt32(dr["AA"]); }
            catch { }

            try { data.AB = Convert.ToInt32(dr["AB"]); }
            catch { }

            try { data.C0 = Convert.ToInt32(dr["C0"]); }
            catch { }

            try { data.C1 = Convert.ToInt32(dr["C1"]); }
            catch { }

            try { data.C2 = Convert.ToInt32(dr["C2"]); }
            catch { }

            try { data.C3 = Convert.ToInt32(dr["C3"]); }
            catch { }

            try { data.C4 = Convert.ToInt32(dr["C4"]); }
            catch { }

            try { data.C5 = Convert.ToInt32(dr["C5"]); }
            catch { }

            try { data.C6 = Convert.ToInt32(dr["C6"]); }
            catch { }

            try { data.C7 = Convert.ToInt32(dr["C7"]); }
            catch { }

            return(data);
        }
示例#7
0
        public static MeasureE0Data Construct(DataGridView dgv, int rowIndex)
        {
            MeasureE0Data data = new MeasureE0Data();

            if (dgv.Rows.Count < rowIndex + 1)
            {
                return(null);
            }

            DataGridViewCellCollection dr = dgv.Rows[rowIndex].Cells;

            if (dr == null)
            {
                return(null);
            }

            try { data.ID = Convert.ToInt64(dr["ID"]); }
            catch { }

            try { data.Source = Convert.ToInt32(dr["Source"]); }
            catch { }

            try { data.Ident = Convert.ToString(dr["Ident"]); }
            catch { }

            try { data.Time = Convert.ToDateTime(dr["Time"]); }
            catch { }

            try { data.Reserve = Convert.ToString(dr["Reserve"]); }
            catch { }

            try { data.bRead = Convert.ToBoolean(dr["bRead"]); }
            catch { }

            try { data.A0 = Convert.ToInt32(dr["A0"]); }
            catch { }

            try { data.A1 = Convert.ToInt32(dr["A1"]); }
            catch { }

            try { data.A2 = Convert.ToInt32(dr["A2"]); }
            catch { }

            try { data.A3 = Convert.ToInt32(dr["A3"]); }
            catch { }

            try { data.A4 = Convert.ToInt32(dr["A4"]); }
            catch { }

            try { data.A5 = Convert.ToInt32(dr["A5"]); }
            catch { }

            try { data.A6 = Convert.ToInt32(dr["A6"]); }
            catch { }

            try { data.A7 = Convert.ToInt32(dr["A7"]); }
            catch { }

            try { data.A8 = Convert.ToInt32(dr["A8"]); }
            catch { }

            try { data.A9 = Convert.ToInt32(dr["A9"]); }
            catch { }

            try { data.AA = Convert.ToInt32(dr["AA"]); }
            catch { }

            try { data.AB = Convert.ToInt32(dr["AB"]); }
            catch { }

            try { data.C0 = Convert.ToInt32(dr["C0"]); }
            catch { }

            try { data.C1 = Convert.ToInt32(dr["C1"]); }
            catch { }

            try { data.C2 = Convert.ToInt32(dr["C2"]); }
            catch { }

            try { data.C3 = Convert.ToInt32(dr["C3"]); }
            catch { }

            try { data.C4 = Convert.ToInt32(dr["C4"]); }
            catch { }

            try { data.C5 = Convert.ToInt32(dr["C5"]); }
            catch { }

            try { data.C6 = Convert.ToInt32(dr["C6"]); }
            catch { }

            try { data.C7 = Convert.ToInt32(dr["C7"]); }
            catch { }

            return(data);
        }
示例#8
0
        public static void AnalyzeE0Data(ref MeasureE0Data e0, byte[] data, uint len)
        {
            for (uint i = 0; i < len; i += 3)
            {
                int adc = BytesOP.MakeShort(data[i + 2], data[i + 1]);
                switch (data[i])
                {
                case 0xa0:
                    e0.A0 = adc;
                    break;

                case 0xa1:
                    e0.A1 = adc;
                    break;

                case 0xa2:
                    e0.A2 = adc;
                    break;

                case 0xa3:
                    e0.A3 = adc;
                    break;

                case 0xa4:
                    e0.A4 = adc;
                    break;

                case 0xa5:
                    e0.A5 = adc;
                    break;

                case 0xa6:
                    e0.A6 = adc;
                    break;

                case 0xa7:
                    e0.A7 = adc;
                    break;

                case 0xa8:
                    e0.A8 = adc;
                    break;

                case 0xa9:
                    e0.A9 = adc;
                    break;

                case 0xaa:
                    e0.AA = adc;
                    break;

                case 0xab:
                    e0.AB = adc;
                    break;

                case 0xc0:
                    e0.C0 = adc;
                    break;

                case 0xc1:
                    e0.C1 = adc;
                    break;

                case 0xc2:
                    e0.C2 = adc;
                    break;

                case 0xc3:
                    e0.C3 = adc;
                    break;

                case 0xc4:
                    e0.C4 = adc;
                    break;

                case 0xc5:
                    e0.C5 = adc;
                    break;

                case 0xc6:
                    e0.C6 = adc;
                    break;

                case 0xc7:
                    e0.C7 = adc;
                    break;
                }
            }
        }
示例#9
0
        void CH368IntProc()
        {
            byte[] readHeaderList = new byte[7];
            byte[] readDataList   = new byte[0x100];
            byte   read           = 0;

            /************************************************************************/
            /*  读ram                                                               */
            /************************************************************************/
            //拉低片选
            if (CH368.CH367mWriteIoByte(CH368Index, mBaseAddr + 0xf8, 0xb0) == 0)
            {
                MessageBox.Show("1");
                return;
            }
            //读7个字节,判断是否为有效帧
//             CH368.CH367mAccessBlock(CH368Index, CH368.mFuncReadMemByte, mMemAddr, readList, 64);
//             this.Invoke((EventHandler)(delegate { textBox1.Text = StringsFunction.byteToHexStr(readList, 0, (int)64, " "); }));
            //Debug.WriteLine(StringsFunction.byteToHexStr(readList, 0, (int)9, " "));
            if (CH368.CH367mAccessBlock(CH368Index, CH368.mFuncReadMemByte, mMemAddr, readHeaderList, 7) == 0)
            {
                MessageBox.Show("2");
                return;
            }
            if (bLog)
            {
                this.Invoke((EventHandler)(delegate
                {
                    try
                    {
                        textBox1.AppendText(DateTime.Now.ToString() + ":");
                        textBox1.AppendText(StringsFunction.byteToHexStr(readHeaderList, 0, 7, " "));
                    }
                    catch
                    {
                    }
                }));
                //Debug.WriteLine(StringsFunction.byteToHexStr(readList, 0, 7, " "));
            }

            if (readHeaderList[0] == 0xfa && readHeaderList[1] == 0xf3 && readHeaderList[2] == 0x30)
            {
                //Debug.WriteLine(StringsFunction.byteToHexStr(readList, 0, 7, " "));
                uint readDataLen = readHeaderList[6];// BytesOP.MakeShort(readHeaderList[5], readHeaderList[6]);
                if (CH368.CH367mAccessBlock(CH368Index, CH368.mFuncReadMemByte, mMemAddr + 7, readDataList, readDataLen) == 0)
                {
                    MessageBox.Show("3");
                    return;
                }
                if (bLog)
                {
                    string str = StringsFunction.byteToHexStr(readDataList, 0, (int)readDataLen, " ");
                    try
                    {
                        this.Invoke((EventHandler)(delegate
                        {
                            textBox1.AppendText(str);
                        }));
                    }
                    catch
                    {
                    }
                }
                if (readHeaderList[3] == 0xe0 || readHeaderList[3] == 0xe2)
                {
                    MeasureE0Data e0 = new MeasureE0Data();
                    e0.Source = readHeaderList[3];
                    Fuction.AnalyzeE0Data(ref e0, readDataList, readDataLen);
                    e0.Time = DateTime.Now;
                    MeasureE0DataDBOption.Insert(e0);
                }
                else if (readHeaderList[3] == 0xe1 || readHeaderList[3] == 0xe3)
                {
                    MeasureE1Data e1 = new MeasureE1Data();
                    e1.Source = readHeaderList[3];
                    Fuction.AnalyzeE1Data(ref e1, readDataList, readDataLen);
                    e1.Time = DateTime.Now;
                    MeasureE1DataDBOption.Insert(e1);
                }
                //Debug.WriteLine(StringsFunction.byteToHexStr(readList, 0, (int)len, " "));
            }
            if (bLog)
            {
                this.Invoke((EventHandler)(delegate
                {
                    try
                    {
//                         bLog = false;
//                         timerLog.Enabled = true;
                        textBox1.AppendText("\r\n");
                    }
                    catch
                    {
                    }
                }));
            }
            //拉高片选
            if (CH368.CH367mWriteIoByte(CH368Index, mBaseAddr + 0xf8, 0xb1) == 0)
            {
                MessageBox.Show("4");
                return;
            }
            /************************************************************************/
            /*  完成读取,告知单片机                                                */
            /************************************************************************/
            //拉低SCS,表示在处理完成
            if (CH368.CH367mWriteIoByte(CH368Index, mBaseAddr + 0xe8, 0x03) == 0)
            {
                MessageBox.Show("5");
                return;
            }
            //等待单片机退出通信流程
            while (true)
            {
                if (CH368.CH367mReadIoByte(CH368Index, mBaseAddr + 0xf8, ref read) == 0)
                {
                    MessageBox.Show("10");
                    return;
                }
                if (BytesOP.GetBit(read, 3))
                {
                    break;
                }
            }
            //SCS 高电平
            if (CH368.CH367mWriteIoByte(CH368Index, mBaseAddr + 0xe8, 0x07) == 0)
            {
                MessageBox.Show("12");
                return;
            }
        }