Exemple #1
0
        public byte[] Do(byte[] frame)
        {
            DataWriter   dw       = new DataWriter();
            DataReader   dr       = new DataReader(frame);
            FunctionCode funcCode = dr.GetFuncCode();

            byte regAddr = dr.GetByte();

            if (regAddr >= _regiestArr.Length)
            {
                ResultFunction rf = new ResultFunction(1);
                return(rf.Do(null));
            }

            if (funcCode == FunctionCode.RegiestReadShort)
            {
                dw.Add(funcCode);
                dw.Add(_regiestArr[regAddr]);
                return(dw.GetBuffer());
            }
            else if (funcCode == FunctionCode.RegiestWriteShort)
            {
                _regiestArr[regAddr] = dr.GetShort();

                ResultFunction rf = new ResultFunction(0);
                return(rf.Do(null));
            }
            else
            {
                ResultFunction rf = new ResultFunction(1);
                return(rf.Do(null));
            }
        }
Exemple #2
0
        public byte[] Do(byte[] frame)
        {
            DataWriter   dw       = new DataWriter();
            DataReader   dr       = new DataReader(frame);
            FunctionCode funcCode = dr.GetFuncCode();

            byte dispLine = dr.GetByte();

            if (dispLine >= _lcdDispLineArr.Length)
            {
                ResultFunction rf = new ResultFunction(1);
                return(rf.Do(null));
            }

            if (funcCode == FunctionCode.LCDRead)
            {
                dw.Add(funcCode);
                dw.Add(_lcdDispLineArr[dispLine]);
                return(dw.GetBuffer());
            }
            else if (funcCode == FunctionCode.LCDWrite)
            {
                _lcdDispLineArr[dispLine] = dr.GetString();

                ResultFunction rf = new ResultFunction(0);
                return(rf.Do(null));
            }
            else
            {
                ResultFunction rf = new ResultFunction(1);
                return(rf.Do(null));
            }
        }
Exemple #3
0
        public byte[] Do(byte[] frame)
        {
            DataWriter dw = new DataWriter();

            dw.Add(FunctionCode.Result);
            dw.Add(_result);

            return(dw.GetBuffer());
        }
Exemple #4
0
 public bool AddUsers(IList <UTransit.Models.User> users)
 {
     foreach (var user in users)
     {
         _users.Add(user);
         DataWriter.Add(user, "Users");
     }
     return(true);
 }
Exemple #5
0
 public bool UploadVoucher(IList <TripVoucher> tripVoucher)
 {
     foreach (var t in tripVoucher)
     {
         _vouchers.Add(t);
         DataWriter.Add(t, "Vouchers");
     }
     return(true);
 }
        public bool AddStudents(IList <UTransit.Models.Student> students)
        {
            foreach (var s in students)
            {
                _students.Add(s);
                DataWriter.Add(s, "Students");
            }

            return(true);
        }
        public (bool Success, float Balance) BuyVoucher(UTransit.Models.StudentTransaction transaction)
        {
            var result = _students.Next.Find((x, y) => x.IndexNumber[y] == transaction.IndexNumber);

            if (result.success)
            {
                result.Value.Transactions[result.Index].Add(transaction);
                result.Value.Balance[result.Index] += transaction.Amount;
                DataWriter.Add(transaction, "Transactions");
                return(Success : true, result.Value.Balance[result.Index]);
            }
            return(Success : false, result.Value.Balance[result.Index]);
        }
Exemple #8
0
        public bool UpdateVoucher(string voucherId)
        {
            var result = _vouchers.Next.Find((x, y) => x.VoucherId[y] == voucherId);

            if (!result.success)
            {
                return(false);
            }
            result.Value.Used[result.Index] = true;
            result.Value.State[result.Index]++;
            var voucher = CreateVoucher(result);

            DataWriter.Add(voucher, "Vouchers");
            return(true);
        }
Exemple #9
0
 public bool UploadVoucher(TripVoucher tripVoucher)
 {
     _vouchers.Add(tripVoucher);
     DataWriter.Add(tripVoucher, "Vouchers");
     return(true);
 }
Exemple #10
0
 public bool AddStudent(UTransit.Models.Student student)
 {
     _students.Add(student);
     DataWriter.Add(student, "Students");
     return(true);
 }
 public bool Add(StudentTransaction transaction)
 {
     DataWriter.Add(transaction, "Transactions");
     return(true);
 }