예제 #1
0
        private string GetTimerInfo()
        {
#if LIYUUSB
            int nLimitTime = 0;
            int nDuration  = 0;
            int nLang      = 0;
            if (CoreInterface.GetPasswdInfo(ref nLimitTime, ref nDuration, ref nLang) != 0)
            {
                string Limit = nLimitTime.ToString() + "(Hours)";
                if (nLimitTime == 0)
                {
                    Limit = "Permanent";
                }
                string mbversion =
                    "Limit time:" + Limit + "\n"
                    + "Elapsed time:" + nDuration.ToString() + "(Hours)" + "\n"
                    + DoWithLangInfo(nLang);
                return(mbversion);
            }
            else
            {
                return("");
            }
#else
            SPwdInfo pwdinfo = new SPwdInfo();
            string   ret     = "";
            if (CoreInterface.GetPWDInfo(ref pwdinfo) != 0)
            {
                string Limit = pwdinfo.nLimitTime.ToString() + "(Hours)";
                if (pwdinfo.nLimitTime == 0)
                {
                    Limit = "Permanent";
                }
                string LimitInk = pwdinfo.nLimitInk[0].ToString() + "(L)";
                if (pwdinfo.nLimitInk[0] == 0)
                {
                    LimitInk = "Not Limit Ink";
                }

                //string usedInk = 0;
                string mbversion =
                    "Limit time:" + Limit + "\n"
                    + "Elapsed time:" + pwdinfo.nDuration.ToString() + "(Hours)" + "\n"
                    + DoWithLangInfo(pwdinfo.nLang)
                    + "Limit Ink:" + LimitInk + "\n";

                SPrinterProperty PrinterProperty = new SPrinterProperty();
                CoreInterface.GetSPrinterProperty(ref PrinterProperty);
                int colornum = CoreConst.OLD_MAX_COLOR_NUM;//PrinterProperty.GetRealColorNum();
                if (EpsonLCD.IsNewDurationInkCmd())
                {
                    for (int i = 0; i < colornum; i++)
                    {
                        long[] durationInk = new long[8];
                        if (EpsonLCD.GetDurationInk(ref durationInk))
                        {
                            if (i < durationInk.Length)
                            {
                                ColorEnum_Short ink = ColorEnum_Short.N;
                                if (Enum.IsDefined(typeof(ColorEnum_Short), PrinterProperty.eColorOrder[i]))
                                {
                                    ink = (ColorEnum_Short)PrinterProperty.eColorOrder[i];
                                }
                                mbversion += string.Format("Ink{0}[", i + 1) + ink.ToString() + "] Printed Ink:" + (((double)durationInk[i]) / (Math.Pow(10, 12))).ToString("0.0000") + "(L)" + "\r\n";
                            }
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < colornum && i < pwdinfo.nDurationInk.Length; i++)
                    {
                        ColorEnum_Short ink = ColorEnum_Short.N;
                        if (Enum.IsDefined(typeof(ColorEnum_Short), PrinterProperty.eColorOrder[i]))
                        {
                            ink = (ColorEnum_Short)PrinterProperty.eColorOrder[i];
                        }
                        mbversion += string.Format("Ink{0}[", i + 1) + ink.ToString() + "] Printed Ink:"
                                     + pwdinfo.nDurationInk[i].ToString("0.0") + "(L)" + "\n";
                    }
                }
                ret += mbversion;
            }
#if UV_LIMIT
            SPwdInfo_UV pwdinfo_uv = new SPwdInfo_UV();
            if (CoreInterface.GetPWDInfo_UV(ref pwdinfo_uv) != 0)
            {
                string mbversion = "";
                mbversion += " Left UV: "
                             + "Limit:" + pwdinfo_uv.nLimitUV[0].ToString() + "(Hours)"
                             + "Duration:" + (pwdinfo_uv.nDurationUV[0] / 3600f).ToString("F3") + "(Hours)" + "\n";
                mbversion += " Right UV: "
                             + "Limit:" + pwdinfo_uv.nLimitUV[1].ToString() + "(Hours)"
                             + "Duration:" + (pwdinfo_uv.nDurationUV[1] / 3600f).ToString("F3") + "(Hours)" + "\n";
                ret += mbversion;
            }
#endif
            return(ret);
#endif
        }
예제 #2
0
        /// <summary>
        /// 获取当前累计已消耗墨量
        /// </summary>
        /// <returns></returns>
        private List <Tuple <ColorEnum, double> > GetUsedInk()
        {
            List <Tuple <ColorEnum, double> > curInks = new List <Tuple <ColorEnum, double> >();

            try
            {
                if (EpsonLCD.IsNewDurationInkCmd())
                {
                    //pl墨量统计

                    #region PL单位墨量统计

                    long[] durationInk = new long[8];
                    if (EpsonLCD.GetDurationInk(ref durationInk))
                    {
                        List <MbInfo> list = GetMbList();
                        for (int i = 1; i < list.Count; i++) //多个主板 将每一个的都加到pwdinfo1里面
                        {
                            long[] durationInk2 = new long[8];
                            if (EpsonLCD.GetDurationInk(ref durationInk2, list[i].MbId))
                            {
                                if (durationInk2 == null)
                                {
                                    durationInk2 = durationInk;
                                }
                                else
                                {
                                    for (int j = 0; j < durationInk.Length; j++)
                                    {
                                        durationInk[j] += durationInk2[j];
                                    }
                                }
                            }
                        }

                        SPrinterProperty PrinterProperty = new SPrinterProperty();
                        CoreInterface.GetSPrinterProperty(ref PrinterProperty);
                        int colornum = PrinterProperty.GetRealColorNum();
                        for (int i = 0; i < colornum; i++)
                        {
                            if (i < durationInk.Length)
                            {
                                Tuple <ColorEnum, double> ink = new Tuple <ColorEnum, double>(
                                    (ColorEnum)PrinterProperty.eColorOrder[i],
                                    (((double)durationInk[i]) / (Math.Pow(10, 12))));
                                curInks.Add(ink);
                            }
                        }
                    }
                    else
                    {
                        LogWriter.SaveOptionLog("GetUsedInk:GetDurationInk fail!");
                    }
                    #endregion
                }
                else
                {
                    LogWriter.SaveOptionLog("GetUsedInk:IsNewDurationInkCmd=false!");
                    List <MbInfo> list     = GetMbList();
                    SPwdInfo      pwdinfo1 = new SPwdInfo();
                    for (int i = 1; i < list.Count; i++)
                    {
                        SPwdInfo pwdinfo2 = new SPwdInfo();
                        if (CoreInterface.GetPWDInfo(ref pwdinfo2, list[i].MbId) != 0)
                        {
                            if (pwdinfo1.nDurationInk == null)
                            {
                                pwdinfo1 = pwdinfo2;
                            }
                            else
                            {
                                for (int j = 0; j < pwdinfo1.nDurationInk.Length; j++)
                                {
                                    pwdinfo1.nDurationInk[j] += pwdinfo2.nDurationInk[j];
                                }
                            }
                        }
                    }

                    string mbversion = string.Empty;
                    if (pwdinfo1.nDurationInk != null)
                    {
                        SPrinterProperty PrinterProperty = new SPrinterProperty();
                        CoreInterface.GetSPrinterProperty(ref PrinterProperty);
                        int colornum = PrinterProperty.GetRealColorNum();
                        for (int i = 0; i < colornum && i < pwdinfo1.nDurationInk.Length; i++)
                        {
                            Tuple <ColorEnum, double> ink =
                                new Tuple <ColorEnum, double>((ColorEnum)PrinterProperty.eColorOrder[i],
                                                              pwdinfo1.nDurationInk[i]);
                            curInks.Add(ink);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogWriter.SaveOptionLog("GetUsedInk:Exception=" + ex.Message);
            }

            return(curInks);
        }