private void ShowTariff(TariffOfLimitation info)
 {
     this.rdTariffOfLimitation.Checked  = true;
     this.txtFreeMinutes4.IntergerValue = info.FreeMinutes;
     if (info.FirstCharge != null)
     {
         this.chkFirstCharge.Checked        = true;
         this.txtFirstMinutes.IntergerValue = (short)info.FirstCharge.Minutes;
         this.txtFirstFee1.DecimalValue     = info.FirstCharge.Fee;
     }
     else
     {
         this.chkFirstCharge.Checked        = false;
         this.txtFirstMinutes.IntergerValue = 0;
         this.txtFirstFee1.DecimalValue     = 0;
     }
     this.ck_Is12Hour.Checked = info.FeeOf12Hour > 0;
     if (this.ck_Is12Hour.Checked)
     {
         this.txtFee12Hour.DecimalValue = info.FeeOf12Hour;
     }
     this.ck_Is24Hour.Checked = info.FeeOf24Hour > 0;
     if (this.ck_Is24Hour.Checked)
     {
         this.txtFee24Hour.DecimalValue = info.FeeOf24Hour;
     }
     this.chkLimitFeeOfMax.Checked = info.FeeOfMax > 0;
     if (this.chkLimitFeeOfMax.Checked)
     {
         this.txtLimitFeeOfMax.DecimalValue = info.FeeOfMax;
     }
     this.txtRegularMinutes.IntergerValue = (short)info.RegularCharge.Minutes;
     this.txtRegularFee.DecimalValue      = info.RegularCharge.Fee;
 }
Example #2
0
        public void TariffChanglongVIPTest()
        {
            TariffOfLimitation tariff = new TariffOfLimitation();

            tariff.FreeMinutes   = 0;
            tariff.FirstCharge   = new ChargeUnit(1439, 0);
            tariff.RegularCharge = new ChargeUnit(1440, 10);

            Assert.IsTrue(tariff.CalculateFee(new DateTime(2012, 1, 1, 8, 0, 0), new DateTime(2012, 1, 2, 7, 59, 0)) == 0);
            Assert.IsTrue(tariff.CalculateFee(new DateTime(2012, 1, 1, 8, 0, 0), new DateTime(2012, 1, 2, 8, 0, 0)) == 10);
            Assert.IsTrue(tariff.CalculateFee(new DateTime(2012, 1, 1, 8, 0, 0), new DateTime(2012, 1, 3, 7, 59, 0)) == 10);
            Assert.IsTrue(tariff.CalculateFee(new DateTime(2012, 1, 1, 8, 0, 0), new DateTime(2012, 1, 3, 8, 0, 0)) == 20);
        }
        private TariffOfLimitation GetTariffOfLimitationFromInput()
        {
            TariffOfLimitation tariff = new TariffOfLimitation();

            tariff.FreeMinutes = (byte)this.txtFreeMinutes4.IntergerValue;
            if (this.chkFirstCharge.Checked)
            {
                tariff.FirstCharge = new ChargeUnit((short)this.txtFirstMinutes.IntergerValue, this.txtFirstFee1.DecimalValue);
            }
            tariff.RegularCharge = new ChargeUnit((short)this.txtRegularMinutes.IntergerValue, this.txtRegularFee.DecimalValue);
            tariff.FeeOf12Hour   = this.ck_Is12Hour.Checked ? this.txtFee12Hour.DecimalValue : 0;
            tariff.FeeOf24Hour   = this.ck_Is24Hour.Checked ? this.txtFee24Hour.DecimalValue : 0;
            tariff.FeeOfMax      = this.chkLimitFeeOfMax.Checked ? this.txtLimitFeeOfMax.DecimalValue : 0;
            return(tariff);
        }
Example #4
0
        private Packet FormatTariffOfLimitation(TariffOfLimitation tariff, int index, TollOptionSetting tos)
        {
            Packet packet = new Packet();

            packet.Order   = OrderCode.Comm_WriteParameterTable;
            packet.Address = CanAddress.HostEntrance;

            packet.AddByte((byte)index); //下载而号
            //16字节 单字节选项
            packet.AddByte(0x0);
            packet.AddByte(GetVoice(tariff.CarType));
            packet.AddByte(GetVoice(tariff.CarType));
            packet.AddBytes(new byte[13]);
            //以下为公共收费参数 16字节
            packet.AddByte(0x0);                 //为1表示无入场记录按次收费
            packet.AddShort(0x0);                //无入场记录按上次出场时间计算免费时间(分钟)
            packet.AddShort(0x0);                //无入场记录按次收费金额
            packet.AddByte(0x0);                 //备用
            packet.AddShort(tariff.FreeMinutes); //入场免费时间
            packet.AddShort(0x0);                //免费零头时间
            packet.AddShort(0x0);                //中央收费后免费时间
            if (tariff.FeeOf12Hour > 0)
            {
                packet.AddShort(12 * 60);  //公用的周期限额计费时间(小时)(12小时)
                packet.AddShort((short)(tos.FromYuan(tariff.FeeOf12Hour)));
            }
            else
            {
                packet.AddShort(24 * 60);  //公用的周期限额计费时间(小时)(24小时)
                packet.AddShort((short)(tos.FromYuan(tariff.FeeOf24Hour)));
            }
            //不分时段普通收费参数16byte
            packet.AddByte(0x03);                                                                          //计费模式 3=仅一次入场收费
            packet.AddBytes(new byte[3]);
            packet.AddShort((short)(tariff.FirstCharge == null ? 0 : tariff.FirstCharge.Minutes));         //入场计费时间
            packet.AddShort((short)tos.FromYuan(tariff.FirstCharge == null ? 0 : tariff.FirstCharge.Fee)); //入场收费金额
            packet.AddShort(tariff.RegularCharge.Minutes);                                                 //单位时间收费:计费时间(分钟)
            packet.AddShort((short)(tos.FromYuan(tariff.RegularCharge.Fee)));                              //单位时间收费:计费金额
            packet.AddShort(0x0);                                                                          //备用1
            packet.AddShort(0x0);                                                                          //备用2
            ////下面为空
            packet.AddBytes(new byte[240 - 49]);                                                           //参数总共240字节,
            return(packet);
        }
Example #5
0
        public void TariffOfLimitationTest()
        {
            //有限额收费 入场30分钟免费,入场收5元
            TariffOfLimitation tt = new TariffOfLimitation();

            tt.FreeMinutes   = 30;
            tt.FeeOf24Hour   = 15;
            tt.FirstCharge   = new ChargeUnit(60, 5);
            tt.RegularCharge = new ChargeUnit(60, 1);
            Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 1, 10, 0, 0), new DateTime(2011, 3, 1, 10, 0, 0)) == 0);
            Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 1, 10, 0, 0), new DateTime(2011, 3, 1, 10, 30, 0)) == 0);
            Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 1, 10, 0, 0), new DateTime(2011, 3, 1, 10, 31, 0)) == 5);
            Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 1, 10, 0, 0), new DateTime(2011, 3, 1, 12, 0, 0)) == 6);
            Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 1, 10, 0, 0), new DateTime(2011, 3, 1, 12, 2, 0)) == 7);
            Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 1, 10, 0, 0), new DateTime(2011, 3, 2, 0, 0, 0)) == 15);
            Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 1, 10, 0, 0), new DateTime(2011, 3, 2, 0, 1, 0)) == 15);
            Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 1, 10, 0, 0), new DateTime(2011, 3, 2, 10, 0, 0)) == 15);
            Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 1, 10, 0, 0), new DateTime(2011, 3, 2, 10, 1, 0)) == 16);
            Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 1, 10, 0, 0), new DateTime(2011, 3, 2, 15, 0, 0)) == 20);
            Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 1, 10, 0, 0), new DateTime(2011, 3, 3, 0, 1, 0)) == 30);
            Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 1, 10, 0, 0), new DateTime(2011, 3, 3, 10, 0, 0)) == 30);
            Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 1, 10, 0, 0), new DateTime(2011, 3, 3, 10, 1, 0)) == 31);
        }
Example #6
0
        private Ralid.Park.Hardware.H_TariffInfo ConvertTariffInfo(short freeTimeAfterPay, Ralid.Park.BusinessModel.Model.TariffBase tariff)
        {
            H_TariffInfo h_Tariff = new H_TariffInfo();

            h_Tariff.TariffType = ConvertTariffType(tariff.TariffType);
            h_Tariff.CardType   = ConvertTariffCardType(tariff.CardType);
            h_Tariff.CarType    = ConvertTariffCarType(tariff.CarType, tariff.TariffType);
            h_Tariff.T2         = freeTimeAfterPay;

            if (tariff is TariffPerTime)//按次收费
            {
                TariffPerTime t = tariff as TariffPerTime;
                h_Tariff.ChargeType     = H_Tariff_ChargeType.Mode1;
                h_Tariff.ChargeProperty = H_Tariff_ChargeProperty.OverTimeInvalid
                                          | H_Tariff_ChargeProperty.DailyLimitInvalid
                                          | H_Tariff_ChargeProperty.IntervalTop1Invalid
                                          | H_Tariff_ChargeProperty.IntervalTop2Invalid
                                          | H_Tariff_ChargeProperty.Mode3Interval1Invalid
                                          | H_Tariff_ChargeProperty.Mode3Interval2Invalid
                                          | H_Tariff_ChargeProperty.MaximumAmountInvalid;
                h_Tariff.T1    = t.FreeMinutes;
                h_Tariff.M1[0] = (int)(t.FeePerTime * 100);
            }

            if (tariff is TariffPerDay)//按天收费
            {
                TariffPerDay t = tariff as TariffPerDay;
                h_Tariff.ChargeType     = H_Tariff_ChargeType.Mode2;
                h_Tariff.ChargeProperty = H_Tariff_ChargeProperty.DailyLimitInvalid
                                          | H_Tariff_ChargeProperty.IntervalTop1Invalid
                                          | H_Tariff_ChargeProperty.IntervalTop2Invalid
                                          | H_Tariff_ChargeProperty.Mode3Interval1Invalid
                                          | H_Tariff_ChargeProperty.Mode3Interval2Invalid;
                h_Tariff.T1    = t.FreeMinutes;
                h_Tariff.M1[0] = (int)(t.FeePerDay * 100);

                if (t.OverDay > 0)
                {
                    h_Tariff.T3 = t.OverDay;
                    h_Tariff.M2 = (int)(t.FeePerOverDay * 100);
                }
                else
                {
                    h_Tariff.ChargeProperty |= H_Tariff_ChargeProperty.OverTimeInvalid;
                }

                if (t.FeeOfMax > 0)
                {
                    h_Tariff.M7 = (int)(t.FeeOfMax * 100);
                }
                else
                {
                    h_Tariff.ChargeProperty |= H_Tariff_ChargeProperty.MaximumAmountInvalid;
                }
            }

            if (tariff is TariffOfTurning)//过点收费
            {
                TariffOfTurning t = tariff as TariffOfTurning;
                h_Tariff.ChargeType     = H_Tariff_ChargeType.Mode1;
                h_Tariff.ChargeProperty = H_Tariff_ChargeProperty.DailyLimitInvalid
                                          | H_Tariff_ChargeProperty.IntervalTop1Invalid
                                          | H_Tariff_ChargeProperty.IntervalTop2Invalid
                                          | H_Tariff_ChargeProperty.Mode3Interval1Invalid
                                          | H_Tariff_ChargeProperty.Mode3Interval2Invalid;
                h_Tariff.T1    = t.FreeMinutes;
                h_Tariff.M1[0] = (int)(t.FirstFee * 100);
                h_Tariff.T3    = (short)(Ralid.GeneralLibrary.BCDConverter.IntToBCD(t.Turning.Hour) * 0x100 + Ralid.GeneralLibrary.BCDConverter.IntToBCD(t.Turning.Minute));
                h_Tariff.M2    = (int)(t.FeeOfTurning * 100);

                if (t.FeeOfMax > 0)
                {
                    h_Tariff.M7 = (int)(t.FeeOfMax * 100);
                }
                else
                {
                    h_Tariff.ChargeProperty |= H_Tariff_ChargeProperty.MaximumAmountInvalid;
                }
            }

            if (tariff is TariffOfLimitation)//限额收费
            {
                TariffOfLimitation t = tariff as TariffOfLimitation;
                h_Tariff.ChargeType     = H_Tariff_ChargeType.Mode4;
                h_Tariff.ChargeProperty = H_Tariff_ChargeProperty.OverTimeInvalid
                                          | H_Tariff_ChargeProperty.IntervalTop2Invalid
                                          | H_Tariff_ChargeProperty.Mode3Interval1Invalid
                                          | H_Tariff_ChargeProperty.Mode3Interval2Invalid;
                h_Tariff.T1 = t.FreeMinutes;
                if (t.FirstCharge != null)
                {
                    h_Tariff.T4    = t.FirstCharge.Minutes;
                    h_Tariff.T5[0] = t.FirstCharge.Minutes;
                    h_Tariff.M1[0] = (int)(t.FirstCharge.Fee * 100);
                }
                h_Tariff.T6[0] = t.RegularCharge.Minutes;
                h_Tariff.M3[0] = (int)(t.RegularCharge.Fee * 100);
                if (t.FeeOf12Hour > 0)
                {
                    h_Tariff.T7 = 12 * 60;//12小时限额
                    h_Tariff.M5 = (int)(t.FeeOf12Hour * 100);
                }
                else
                {
                    h_Tariff.ChargeProperty |= H_Tariff_ChargeProperty.IntervalTop1Invalid;
                }
                if (t.FeeOf24Hour > 0)
                {
                    h_Tariff.M6 = (int)(t.FeeOf24Hour * 100);//24小时限额
                }
                else
                {
                    h_Tariff.ChargeProperty |= H_Tariff_ChargeProperty.DailyLimitInvalid;
                }
                if (t.FeeOfMax > 0)//封顶收费,最高收费
                {
                    h_Tariff.M7 = (int)(t.FeeOfMax * 100);
                }
                else
                {
                    h_Tariff.ChargeProperty |= H_Tariff_ChargeProperty.MaximumAmountInvalid;
                }
            }

            if (tariff is TariffOfGuanZhou)//日夜差异收费
            {
                TariffOfGuanZhou t = tariff as TariffOfGuanZhou;
                h_Tariff.ChargeType     = H_Tariff_ChargeType.Mode3;
                h_Tariff.ChargeProperty = H_Tariff_ChargeProperty.OverTimeInvalid;
                h_Tariff.T1             = t.FreeMinutes;
                h_Tariff.M6             = (int)(t.FeeOf24Hour * 100);//24小时限额

                //白天时段
                h_Tariff.TimeInterval[0]           = new H_TimeInterval();
                h_Tariff.TimeInterval[0].BeginTime = new H_TimeEntity(t.DayTimezone.Beginning.Hour, t.DayTimezone.Beginning.Minute);
                h_Tariff.TimeInterval[0].EndTime   = new H_TimeEntity(t.DayTimezone.Ending.Hour, t.DayTimezone.Ending.Minute);
                h_Tariff.T6[0] = t.DayTimezone.RegularCharge.Minutes;
                h_Tariff.M3[0] = (int)(t.DayTimezone.RegularCharge.Fee * 100);
                if (t.DayTimezone.LimiteFee.HasValue && t.DayTimezone.LimiteFee.Value > 0)//白天时段有最高限额
                {
                    h_Tariff.M4[0] = (int)(t.DayTimezone.LimiteFee.Value * 100);
                }
                else
                {
                    h_Tariff.ChargeProperty |= H_Tariff_ChargeProperty.IntervalTop1Invalid;
                }

                //夜间时段
                h_Tariff.TimeInterval[1]           = new H_TimeInterval();
                h_Tariff.TimeInterval[1].BeginTime = new H_TimeEntity(t.NightTimezone.Beginning.Hour, t.NightTimezone.Beginning.Minute);
                h_Tariff.TimeInterval[1].EndTime   = new H_TimeEntity(t.NightTimezone.Ending.Hour, t.NightTimezone.Ending.Minute);
                h_Tariff.T6[1] = t.NightTimezone.RegularCharge.Minutes;
                h_Tariff.M3[1] = (int)(t.NightTimezone.RegularCharge.Fee * 100);
                if (t.NightTimezone.LimiteFee.HasValue && t.NightTimezone.LimiteFee.Value > 0)//夜间有最高限额
                {
                    h_Tariff.M4[1] = (int)(t.NightTimezone.LimiteFee.Value * 100);
                }
                else
                {
                    h_Tariff.ChargeProperty |= H_Tariff_ChargeProperty.IntervalTop2Invalid;
                }

                if (t.FeeOf24Hour > 0)
                {
                    h_Tariff.M6 = (int)(t.FeeOf24Hour * 100);//24小时限额
                }
                else
                {
                    h_Tariff.ChargeProperty |= H_Tariff_ChargeProperty.DailyLimitInvalid;
                }

                if (t.FeeOfMax > 0)//封顶收费,最高收费
                {
                    h_Tariff.M7 = (int)(t.FeeOfMax * 100);
                }
                else
                {
                    h_Tariff.ChargeProperty |= H_Tariff_ChargeProperty.MaximumAmountInvalid;
                }
            }

            if (tariff is TariffOfDixiakongjian)//时段限额收费
            {
                TariffOfDixiakongjian t = tariff as TariffOfDixiakongjian;
                h_Tariff.ChargeType     = H_Tariff_ChargeType.Mode3;
                h_Tariff.ChargeProperty = H_Tariff_ChargeProperty.OverTimeInvalid
                                          | H_Tariff_ChargeProperty.IntervalTop1Invalid;
                h_Tariff.T1 = t.FreeMinutes;
                h_Tariff.M6 = (int)(t.FeeOf24Hour * 100);//24小时限额

                //正常时段
                h_Tariff.TimeInterval[0]           = new H_TimeInterval();
                h_Tariff.TimeInterval[0].BeginTime = new H_TimeEntity(t.LimitationTimezone.Ending.Hour, t.LimitationTimezone.Ending.Minute);       //以限价时段结束时间为开始时间
                h_Tariff.TimeInterval[0].EndTime   = new H_TimeEntity(t.LimitationTimezone.Beginning.Hour, t.LimitationTimezone.Beginning.Minute); //以限价时段开始时间为结束时间
                h_Tariff.T4    = (short)t.FirstMinutes;
                h_Tariff.T5[0] = t.FirstFee.Minutes;
                h_Tariff.M1[0] = (int)(t.FirstFee.Fee * 100);
                h_Tariff.T6[0] = t.RegularFee.Minutes;
                h_Tariff.M3[0] = (int)(t.RegularFee.Fee * 100);

                //限价时段
                h_Tariff.TimeInterval[1]           = new H_TimeInterval();
                h_Tariff.TimeInterval[1].BeginTime = new H_TimeEntity(t.LimitationTimezone.Beginning.Hour, t.LimitationTimezone.Beginning.Minute);
                h_Tariff.TimeInterval[1].EndTime   = new H_TimeEntity(t.LimitationTimezone.Ending.Hour, t.LimitationTimezone.Ending.Minute);
                h_Tariff.T6[1] = t.LimitationRegularFee.Minutes;
                h_Tariff.M3[1] = (int)(t.LimitationRegularFee.Fee * 100);
                h_Tariff.M4[1] = (int)(t.Limitation * 100);

                if (t.FeeOf24Hour > 0)
                {
                    h_Tariff.M6 = (int)(t.FeeOf24Hour * 100);//24小时限额
                }
                else
                {
                    h_Tariff.ChargeProperty |= H_Tariff_ChargeProperty.DailyLimitInvalid;
                }
                if (t.FeeOfMax > 0)//封顶收费,最高收费
                {
                    h_Tariff.M7 = (int)(t.FeeOfMax * 100);
                }
                else
                {
                    h_Tariff.ChargeProperty |= H_Tariff_ChargeProperty.MaximumAmountInvalid;
                }
            }

            return(h_Tariff);
        }