示例#1
0
        private Packet FormatTariffPerDay(TariffPerDay 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);                //中央收费后免费时间
            packet.AddShort((short)(24 * 60));   //公用的周期限额计费时间(小时)(24小时)
            packet.AddShort((short)(tos.FromYuan(tariff.FeePerDay)));
            //不分时段普通收费参数16byte
            packet.AddByte(0x02); //计费模式 2按天
            packet.AddBytes(new byte[15]);
            //下面为空
            packet.AddBytes(new byte[240 - 49]);  //参数总共240字节,
            return(packet);
        }
示例#2
0
        private TariffPerDay GetTariffPerDayFromInput()
        {
            TariffPerDay tariff = new TariffPerDay((byte)this.txtFreeMinutes2.IntergerValue, this.txtFeePerDay1.DecimalValue);

            tariff.OverDay       = (short)(chkOverDay.Checked ? this.txtOverDay.IntergerValue : 0);
            tariff.FeePerOverDay = chkOverDay.Checked ? this.txtFeePerOverDay.DecimalValue : 0;
            tariff.FeeOfMax      = chkPerDayFeeOfMax.Checked ? this.txtPerDayFeeOfMax.DecimalValue : 0;
            return(tariff);
        }
示例#3
0
 private void ShowTariff(TariffPerDay info)
 {
     this.rdTariffPerDay.Checked         = true;
     this.txtFreeMinutes2.IntergerValue  = info.FreeMinutes;
     this.txtFeePerDay1.DecimalValue     = info.FeePerDay;
     this.chkOverDay.Checked             = info.OverDay > 0;
     this.txtOverDay.IntergerValue       = info.OverDay;
     this.txtFeePerOverDay.DecimalValue  = info.FeePerOverDay;
     this.chkPerDayFeeOfMax.Checked      = info.FeeOfMax > 0;
     this.txtPerDayFeeOfMax.DecimalValue = info.FeeOfMax;
 }
示例#4
0
        public void TariffPerDayTest()
        {
            TariffPerDay tt = new TariffPerDay(30, 5);

            Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 1, 10, 0, 0), new DateTime(2011, 3, 1, 9, 0, 0)) == 0);
            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, 15, 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)) == 5);
            Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 1, 10, 0, 0), new DateTime(2011, 3, 1, 23, 59, 59)) == 5);
            Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 1, 10, 0, 0), new DateTime(2011, 3, 2, 5, 59, 59)) == 5);  //没有超过24小时
            Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 1, 10, 0, 0), new DateTime(2011, 3, 2, 10, 1, 0)) == 10);  //起过24小时
            Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 1, 10, 0, 0), new DateTime(2011, 3, 3, 10, 59, 59)) == 15);
        }
示例#5
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);
        }