示例#1
0
文件: CRUD.cs 项目: gyygyy32/JTRSUHF
        public ModuleObj QueryOracle(string lot)
        {
            string sql = new Jsonhelp().readjson("OracleSql", AppDomain.CurrentDomain.BaseDirectory + "config.json");

            sql = string.Format(sql, lot);

            var       dataReader = dbhelp.ExecuteReader(sql, null);
            ModuleObj obj        = new ModuleObj();

            if (dataReader.Read())
            {
                string moduletime = DateTime.Parse(dataReader["DTCR"].ToString()).ToString("yyyy-MM-dd");
                obj.ModuleDate  = moduletime;
                obj.CellDate    = DateTime.Parse(dataReader["CellDate"].ToString()).ToString("yyyy-MM-dd");;
                obj.Pmax        = dataReader["PMAX"].ToString();
                obj.Voc         = dataReader["RSVOC"].ToString();
                obj.Vmp         = dataReader["RSVPM"].ToString();
                obj.Imp         = dataReader["RSIPM"].ToString();
                obj.Isc         = dataReader["RSISC"].ToString();
                obj.FF          = dataReader["MODULE_EFF"].ToString();
                obj.ModuleID    = lot;
                obj.ProductType = dataReader["NAME_PLATE"].ToString();
            }
            return(obj);
        }
示例#2
0
        private string CheckWrite()
        {
            //throw new Exception();
            string res = "";

            if (!objRFID.ReadTagID())
            {
                objRFID.Beep(20);
                res = "fail";
            }
            else
            {
                System.Threading.Thread.Sleep(20);
                ErrorCode ec = objRFID.IsTagWrited();// ReadData();
                switch (ec)
                {
                case ErrorCode.CanNotFindTag:
                    objRFID.Beep(20);
                    res = "无法找到标签,请重试!";
                    //WriteLog(lrtxtLog, str, 1);
                    break;

                case ErrorCode.OtherException:
                    objRFID.Beep(20);
                    res = "其他异常,请重试";
                    break;

                case ErrorCode.ReadFail:

                    res = "读取失败,请重试!";

                    break;

                case ErrorCode.ReadSuccessful:
                    //paintBackgroundColor(statusType.PASS);
                    objRFID.Beep(10);

                    //MessageBox.Show("read success");
                    //break;
                    ModuleObj mo = new ModuleObj();
                    mo  = TagDataFormat.ParserTag(objRFID.rfidConfig.readBuffer);
                    res = mo.ModuleID.ToString();
                    break;

                case ErrorCode.TagHasNoData:

                    res = "空标签!";

                    break;

                default:
                    break;
                }
            }
            return(res);
        }
示例#3
0
        public static byte[] CreateByteArray(ModuleObj mi)
        {
            int      year       = DateTime.Parse(mi.ModuleDate).Year;
            int      month      = DateTime.Parse(mi.ModuleDate).Month;
            int      day        = DateTime.Parse(mi.ModuleDate).Day;
            DateTime moduledate = new DateTime(year, month, day, 0, 0, 0);

            year  = DateTime.Parse(mi.CellDate).Year;
            month = DateTime.Parse(mi.CellDate).Month;
            day   = DateTime.Parse(mi.CellDate).Day;
            //string CellSource = mi.Cellsource;//add by genhong.hu On 2017-12-31,在此之前高频读卡器没有写入CellSource
            DateTime celldate = new DateTime(year, month, day, 0, 0, 0);
            decimal  iPmax    = Decimal.Parse(mi.Pmax) * 100M;
            decimal  iVoc     = Decimal.Parse(mi.Voc) * 100M;
            decimal  iIsc     = Decimal.Parse(mi.Isc) * 100M;
            decimal  iVpm     = Decimal.Parse(mi.Vmp) * 100M;
            decimal  iIpm     = Decimal.Parse(mi.Imp) * 100M;
            //添加ff add by xue lei on 2018-6-23
            decimal iFF = Decimal.Parse(mi.FF) * 100M;

            using (MemoryStream stream = new MemoryStream())
            {
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    writer.Write(PacketStart);//@@
                    writer.Write(mi.ProductType);
                    writer.Write(mi.ModuleID);
                    writer.Write(DateToInt16(moduledate));
                    writer.Write((int)iPmax);
                    writer.Write((short)iVoc);
                    writer.Write((short)iIsc);
                    writer.Write((short)iVpm);
                    writer.Write((short)iIpm);
                    // 添加ff add by xue lei on 2018-6-23
                    writer.Write((short)iFF);
                    // writer.Write(CellSource);//add by genhong.hu On 2017-12-31,在此之前高频读卡器没有写入CellSource
                    writer.Write(DateToInt16(celldate));
                    //writer.Write(PacketEnd);//##
                    writer.Close();
                }
                return(stream.ToArray());

                //string res = PacketStart + "|" + mi.ProductType + "|" + mi.Module_ID + "|" + dateOfModulePacked.ToString() + "|";// +
                //iPmax.ToString() + "|" + iVoc.ToString() + "|" + iIsc.ToString() + "|" + iVpm.ToString() + "|" + iIpm.ToString()
                //+ "|" + iFF.ToString() + "|" + celldate.ToString();
                //return System.Text.Encoding.Default.GetBytes(res);
            }
        }
示例#4
0
 // add by xue lei on 2019-2-1
 private bool CheckModuleInfo(ModuleObj obj)
 {
     if (obj.ModuleDate == string.Empty ||
         obj.ProductType == string.Empty ||
         obj.FF == string.Empty ||
         obj.Imp == string.Empty ||
         obj.Isc == string.Empty ||
         obj.Pmax == string.Empty ||
         obj.Vmp == string.Empty ||
         obj.Voc == string.Empty
         )
     {
         return(false);
     }
     return(true);
 }
示例#5
0
        public void ShowModuleIndo(ModuleObj obj)
        {
            var json = new Jsonhelp();
            var path = AppDomain.CurrentDomain.BaseDirectory + "config.json";

            txtCellDate.Text              = obj.CellDate;
            txtModuleDate.Text            = obj.ModuleDate;
            txtIECDate.Text               = json.readjson("IECDate", path);
            txtISO9001.Text               = json.readjson("ISO", path);
            txtCertificationProvider.Text = json.readjson("CertificationProvider", path);
            txtModuleCountry.Text         = json.readjson("Country", path);
            txtModuleCellSupplier.Text    = json.readjson("ModuleCellSupplier", path);
            txtIsc.Text         = obj.Isc;
            txtImp.Text         = obj.Imp;
            txtPmax.Text        = obj.Pmax;
            txtVmp.Text         = obj.Vmp;
            txtVoc.Text         = obj.Voc;
            txtFF.Text          = obj.FF;
            txtProductType.Text = obj.ProductType;
        }
示例#6
0
 /// <summary>
 /// 解析标签内容,读取时用到
 /// </summary>
 /// <param name="tagBuff"></param>
 /// <returns></returns>
 public static ModuleObj ParserTag(byte[] tagBuff)
 {
     try
     {
         ModuleObj    o           = new ModuleObj();
         MemoryStream memStream   = new MemoryStream(tagBuff);
         BinaryReader buffReader  = new BinaryReader(memStream);
         string       packetStart = buffReader.ReadString();
         if (packetStart != PacketStart)
         {
             throw new Exception("数据包开始标志出错");
         }
         o.ProductType = buffReader.ReadString();
         o.ModuleID    = buffReader.ReadString();
         DateTime moduledate = DateFormInt16(buffReader.ReadInt16());
         o.ModuleDate = moduledate.ToString("yyyy-MM-dd");
         //string pivf = buffReader.ReadString();
         double Pmax = buffReader.ReadInt32() * 1.0 / 100;
         double Voc  = buffReader.ReadInt16() * 1.0 / 100;
         double Isc  = buffReader.ReadInt16() * 1.0 / 100;
         double Vpm  = buffReader.ReadInt16() * 1.0 / 100;
         double Ipm  = buffReader.ReadInt16() * 1.0 / 100;
         double FF   = buffReader.ReadInt16() * 1.0 / 100;
         o.Pmax = Pmax.ToString("0.00");
         o.Voc  = Voc.ToString("0.00");
         o.Isc  = Isc.ToString("0.00");
         o.Vmp  = Vpm.ToString("0.00");
         o.Imp  = Ipm.ToString("0.00");
         o.FF   = FF.ToString("0.00");
         DateTime celldate = DateFormInt16(buffReader.ReadInt16());// Add by genhong.hu On 2014-08-11 ;
         //电池时间是组件时间-7天
         o.CellDate = celldate.ToString("yyyy-MM-dd");
         return(o);
     }
     catch (Exception ex)
     {
         throw new Exception("解析数据包出错:\r\n" + ex.Message);
     }
 }
示例#7
0
        private void btnRead_Click(object sender, EventArgs e)
        {
            //read tag
            if (!objRFID.ReadTagID())
            {
                //WriteLog(lrtxtLog, "没有发现标签!", 1);
                //
                //
                Log("没有发现标签!", 0);
                return;
            }
            else
            {
                System.Threading.Thread.Sleep(20);

                ErrorCode ec = objRFID.IsTagWrited();// ReadData();
                switch (ec)
                {
                case ErrorCode.CanNotFindTag:
                    Log("无法找到标签,请重试!", 0);
                    break;

                case ErrorCode.OtherException:
                    Log("其他异常,请重试", 0);
                    break;

                case ErrorCode.ReadFail:
                    Log("读取失败,请重试!", 0);
                    break;

                case ErrorCode.TagHasNoData:
                    Log("空标签!", 0);
                    break;

                case ErrorCode.ReadSuccessful:

                    ModuleObj objModule = null;
                    objModule   = TagDataFormat.ParserTag(objRFID.rfidConfig.readBuffer);
                    txtLot.Text = objModule.ModuleID.ToString();

                    //显示组件信息
                    ShowModuleIndo(objModule);

                    //显示曲线
                    //LoadChart(Isc, Imp, Vmp, Voc, Pmax)
                    string script = "LoadChart({0},{1},{2},{3},{4})";
                    script = String.Format(script, objModule.Isc, objModule.Imp, objModule.Vmp, objModule.Voc, objModule.Pmax);
                    //Log(script);
                    myBrowser.ExecuteScriptAsync(script);

                    Log(objModule.ModuleID + "读取成功", 1);

                    //ShowModuleInfo(true);
                    ////add by xue lei 计算ff
                    //tbx_ff.Text = oModuleInfo.FF + "%";
                    //ShowIVCurves(double.Parse(oModuleInfo.Isc), double.Parse(oModuleInfo.Ipm), double.Parse(oModuleInfo.Vpm), double.Parse(oModuleInfo.Voc), oModuleInfo.Module_ID);
                    //string storedDataString = Encoding.ASCII.GetString(_RFIDDevice.rConfig.readBuffer);
                    //WriteLog(lrtxtLog, storedDataString.Replace("@@", "").Replace("##", ""), 0);
                    //_RFIDDevice.Speech("读取成功");
                    break;

                default:
                    break;
                }
            }
        }
示例#8
0
        private void txtLot_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.KeyCode == Keys.Enter)
                {
                    //query module
                    ModuleObj objModule = null;
                    if (!cbxIsTest.Checked)
                    {
                        objModule = QueryModuleIndo(txtLot.Text);
                    }
                    else
                    {
                        objModule = new ModuleObj {
                            ModuleID = txtLot.Text, Pmax = txtPmax.Text, Voc = txtVoc.Text, Isc = txtIsc.Text, Vmp = txtVmp.Text, Imp = txtImp.Text, FF = txtFF.Text, ModuleDate = txtModuleDate.Text, CellDate = txtCellDate.Text, ProductType = txtProductType.Text
                        };
                    }
                    //显示组件信息
                    ShowModuleIndo(objModule);

                    //显示曲线
                    //LoadChart(Isc, Imp, Vmp, Voc, Pmax)
                    string script = "LoadChart({0},{1},{2},{3},{4})";
                    script = String.Format(script, objModule.Isc, objModule.Imp, objModule.Vmp, objModule.Voc, objModule.Pmax);
                    //Log(script);
                    myBrowser.ExecuteScriptAsync(script);

                    //写标签
                    if (cbxisWrite.Checked == true)
                    {
                        //检查组件信息是否完整
                        if (!CheckModuleInfo(objModule))
                        {
                            Log(objModule.ModuleID + "烧录失败:" + "组件信息不全", 0);
                            txtLot.Text = "";
                            return;
                        }

                        if (objRFID.WriteTagBuff(TagDataFormat.CreateByteArray(objModule)) == true && CheckWrite() == objModule.ModuleID)
                        {
                            Log(objModule.ModuleID + "烧录成功", 1);
                            //读取卡关
                            if (cbxIsRead.Checked)
                            {
                                System.Threading.Thread.Sleep(Convert.ToInt32(ddlinternalTime.SelectedValue + "000"));
                                Log(objModule.ModuleID + "读取成功", 1);
                            }

                            string wcInfo = "ModuleID:" + objModule.ModuleID + "|"
                                            + "ModuleDate:" + objModule.ModuleDate + "|"
                                            + "Imp:" + objModule.Imp + "|"
                                            + "Isc:" + objModule.Isc + "|"
                                            + "Voc" + objModule.Voc + "|"
                                            + "Vmp" + objModule.Vmp + "|"
                                            + "Pmax" + objModule.Pmax + "|"
                                            + "ProductType" + objModule.ProductType + "|"
                                            + "FF" + objModule.FF;
                            //var res =new CRUD().InvokeWebService("http://10.60.3.27/PMSService/DataService.asmx", "RecordRfidInfo", new object[] { objModule.ModuleID, wcInfo });
                            Type   t   = assemblyobj.GetType("client.Service", true, true);
                            object obj = Activator.CreateInstance(t);
                            System.Reflection.MethodInfo mi = t.GetMethod("RecordRfidInfo");
                            mi.Invoke(obj, new object[] { objModule.ModuleID, wcInfo });
                        }
                        else
                        {
                            Log(objModule.ModuleID + "烧录失败:" + objRFID.rfidConfig.Errormsg, 0);
                        }
                    }
                    txtLot.Text = "";
                }
            }
            catch (Exception ex)
            {
                Log("烧录失败:" + ex.Message, 0);
                txtLot.Text = "";
            }
        }