예제 #1
0
        private Packet FormatTariffOfMidNight(TariffOfMidNight 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(24 * 60);            //公用的周期限额计费时间(小时)(24小时)
            packet.AddShort((short)(tos.FromYuan(tariff.FeeOf24Hour)));
            //不分时段普通收费参数16byte
            packet.AddByte(0x00);                                  //计费模式
            packet.AddBytes(new byte[3]);
            packet.AddShort(0x0);                                  //入场计费时间
            packet.AddShort((short)tos.FromYuan(tariff.FirstFee)); //入场收费金额
            packet.AddShort(0x0);                                  //单位时间收费:计费时间(分钟)
            packet.AddShort(0x0);                                  //单位时间收费:计费金额
            packet.AddShort(0x0);                                  //备用1
            packet.AddShort(0x0);                                  //备用2
            //不规则收费参数 16字节
            packet.AddByte(0x2);                                   //1=过点后改为限额收费
            packet.AddShort(0);                                    //过零点
            packet.AddBytes(new byte[13]);
            ////下面为空
            packet.AddBytes(new byte[240 - 65]);  //参数总共240字节,
            return(packet);
        }
예제 #2
0
        public void TariffOfMidNightTest()
        {
            //过零点收费 入场30分钟免费,入场收5元,过零点改收10元,每24小时10元
            TariffOfMidNight tt = new TariffOfMidNight();

            tt.FreeMinutes   = 30;
            tt.FirstFee      = 5;
            tt.FeeOfMidNight = 10;
            tt.FeeOf24Hour   = 10;
            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, 2, 0, 0, 0)) == 5);
            Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 1, 10, 0, 0), new DateTime(2011, 3, 2, 0, 1, 0)) == 10);
            Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 1, 10, 0, 0), new DateTime(2011, 3, 2, 10, 0, 0)) == 10);
            Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 1, 10, 0, 0), new DateTime(2011, 3, 2, 10, 1, 0)) == 20);
            Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 1, 10, 0, 0), new DateTime(2011, 3, 3, 0, 0, 0)) == 20);
            Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 1, 10, 0, 0), new DateTime(2011, 3, 3, 0, 1, 0)) == 20);
            Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 1, 10, 0, 0), new DateTime(2011, 3, 3, 10, 0, 0)) == 20);
            Assert.IsTrue(tt.CalculateFee(new DateTime(2011, 3, 1, 10, 0, 0), new DateTime(2011, 3, 3, 10, 1, 0)) == 30);
        }