Exemplo n.º 1
0
        static void Main(string[] args)
        {
            bool exit = false;      //variable to exit do while loop.

            do
            {
                Messages.Menu();                 //Displays a menu.

                switch (Messages.GetUserInput()) //switch based on users input.
                {
                case "1":
                    AnswerChecker.GetAnswerChecker();
                    break;

                case "2":
                    MemoryBank.GetRandomProblem();
                    break;

                case "3":
                    DataBank.GetDataBank();
                    break;

                case "4":
                    NumberGuesser.GetNumberGuesser();
                    break;

                case "5":
                    exit = true;
                    break;

                default:
                    Messages.ErrorMessage();
                    break;
                }
            } while (exit == false);        //breaks out of while loop.
        }
Exemplo n.º 2
0
        static void BulkRead(TagData accessPassword, MemoryBank bank, ushort wordPointer, ushort wordCount)
        {
            TagOpSequence seq;
            TagReadOp     op;

            // Initialize variables
            tagData        = "";
            numOpsExecuted = 0;
            numOpsAdded    = 0;

            // Each TagReadOp can only access up to 32 words.
            // So, we need to break this read up into multiple operations.
            while (wordCount > 0)
            {
                // Define a new tag operation sequence.
                seq = new TagOpSequence();

                // Define a tag read operation
                op = new TagReadOp();
                op.AccessPassword = accessPassword;
                op.MemoryBank     = bank;
                op.WordPointer    = wordPointer;
                op.WordCount      = (wordCount < 32) ? wordCount : (ushort)32;

                // Add the read op to the operation sequence
                seq.Ops.Add(op);

                // Adjust the word count and pointer for the next reader operation
                wordCount   -= op.WordCount;
                wordPointer += op.WordCount;

                // Add the operation sequence to the reader
                reader.AddOpSequence(seq);
                numOpsAdded++;
            }
        }
Exemplo n.º 3
0
 public BothBanksRegister(ushort address, MemoryBank bank)
     : base(address, bank)
 {
 }
Exemplo n.º 4
0
 public MemoryWord16(ushort address, MemoryBank bank)
     : base(address, bank)
 {
 }
Exemplo n.º 5
0
 public Accumulator(ushort address, MemoryBank bank)
     : base(address, bank)
 {
 }
Exemplo n.º 6
0
 public void SetupBase()
 {
     Subject = new MemoryBank(State);
 }
Exemplo n.º 7
0
    /// <summary>
    /// Display the information about the current memory back provided.
    /// </summary>
    /// <param name="bank"> Memory Bank object. </param>
    public static void displayBankInformation(MemoryBank bank)
    {
        Debug.WriteLine("|------------------------------------------------------------------------");
        Debug.WriteLine("| Bank: (" + bank.BankDescription + ")");
        Debug.Write("| Implements : MemoryBank");

        if (bank is PagedMemoryBank)
        {
            Debug.Write(", PagedMemoryBank");
        }

        Debug.WriteLine("");
        Debug.WriteLine("| Size " + bank.Size + " starting at physical address " + bank.StartPhysicalAddress);
        Debug.Write("| Features:");

        if (bank.ReadWrite)
        {
            Debug.Write(" Read/Write");
        }

        if (bank.WriteOnce)
        {
            Debug.Write(" Write-once");
        }

        if (bank.ReadOnly)
        {
            Debug.Write(" Read-only");
        }

        if (bank.GeneralPurposeMemory)
        {
            Debug.Write(" general-purpose");
        }
        else
        {
            Debug.Write(" not-general-purpose");
        }

        if (bank.NonVolatile)
        {
            Debug.Write(" non-volatile");
        }
        else
        {
            Debug.Write(" volatile");
        }

        if (bank.needsProgramPulse())
        {
            Debug.Write(" needs-program-pulse");
        }

        if (bank.needsPowerDelivery())
        {
            Debug.Write(" needs-power-delivery");
        }

        // check if has paged services
        if (bank is PagedMemoryBank)
        {
            // caste to page bank
            PagedMemoryBank pbank = (PagedMemoryBank)bank;

            // page info
            Debug.WriteLine("");
            Debug.Write("| Pages: " + pbank.NumberPages + " pages of length ");
            Debug.Write(pbank.PageLength + " bytes ");

            if (bank.GeneralPurposeMemory)
            {
                Debug.Write("giving " + pbank.MaxPacketDataLength + " bytes Packet data payload");
            }

            if (pbank.hasPageAutoCRC())
            {
                Debug.WriteLine("");
                Debug.Write("| Page Features: page-device-CRC");
            }

            if (pbank.hasExtraInfo())
            {
                Debug.WriteLine("");
                Debug.WriteLine("| Extra information for each page:  " + pbank.ExtraInfoDescription + ", length " + pbank.ExtraInfoLength);
            }
            else
            {
                Debug.WriteLine("");
            }
        }
        else
        {
            Debug.WriteLine("");
        }

        Debug.WriteLine("|------------------------------------------------------------------------");
    }
Exemplo n.º 8
0
        private void ReadMemoryBank(MemoryBank mb, out byte[] readBuf)
        {
            int size = mb.Size;

            readBuf = new byte[size];

            byte[][] extraInfo = null;
            try
            {
                Debug.WriteLine("Reading memory...");

                if (mb is PagedMemoryBank)
                {
                    PagedMemoryBank pmb       = (PagedMemoryBank)mb;
                    int             len       = pmb.PageLength;
                    int             numPgs    = (size / len) + (size % len > 0 ? 1 : 0);
                    bool            hasExtra  = pmb.hasExtraInfo();
                    int             extraSize = pmb.ExtraInfoLength;
                    if (hasExtra)
                    {
                        extraInfo[numPgs] = new byte[numPgs];
                        for (var i = 0; i < numPgs; i++)
                        {
                            extraInfo[0] = new byte[extraSize];
                        }
                    }
                    int retryCnt = 0;
                    for (int i = 0; i < numPgs;)
                    {
                        try
                        {
                            bool readContinue = (i > 0) && (retryCnt == 0);
                            if (hasExtra)
                            {
                                pmb.readPage(i, readContinue, readBuf, i * len, extraInfo[i]);
                                Debug.WriteLine("Read Extra Info!");
                            }
                            else
                            {
                                pmb.readPage(i, readContinue, readBuf, i * len);
                            }
                            i++;
                            retryCnt = 0;
                        }
                        catch (Exception e)
                        {
                            if (++retryCnt > 15)
                            {
                                throw e;
                            }
                        }
                    }
                }
                else
                {
                    int retryCnt = 0;
                    while (true)
                    {
                        try
                        {
                            mb.read(0, false, readBuf, 0, size);
                            break;
                        }
                        catch (Exception e)
                        {
                            if (++retryCnt > 15)
                            {
                                throw e;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
                Debug.Write(e.StackTrace);
                return;
            }

            Debug.WriteLine("Done Reading memory...");
        }
Exemplo n.º 9
0
 public TensionHandler(
     MemoryBank bank
     )
 {
     _bank = bank;
 }
Exemplo n.º 10
0
 public RomOnly(byte[] binaryRomData)
 {
     rom = new MemoryBank(binaryRomData);
     ram = new MemoryBank(CartridgeParser.GetRamSize(binaryRomData));
 }
Exemplo n.º 11
0
        public static bool SetAccessPassword(byte[] oldAccessPwd, byte[] newAccessPwd, byte[] selCode, MemoryBank selArea, out string errInfo)
        {
            errInfo = "";
            Invengo.NetAPI.Protocol.IRP1.AccessPwdConfig_6C msg = null;
            if (selCode != null)
            {
                msg = new AccessPwdConfig_6C(Antenna, oldAccessPwd, newAccessPwd, selCode, selArea);
            }
            else
            {
                msg = new AccessPwdConfig_6C(Antenna, oldAccessPwd, newAccessPwd);
            }

            if (RfReader.Send(msg))
            {
                return(true);
            }
            else
            {
                if (msg.ErrInfo == null || msg.ErrInfo == "")
                {
                    errInfo = string.Format("0x{0}", msg.StatusCode.ToString("X2"));
                }
                else
                {
                    errInfo = msg.ErrInfo;
                }
                Log.Debug(msg.ErrInfo);
            }
            return(false);
        }
Exemplo n.º 12
0
 public CombatantHandler(
     MemoryBank bank
     )
 {
     _bank = bank;
 }
Exemplo n.º 13
0
 public void Initialize()
 {
     m_Bank = new MemoryBank(64);
 }
Exemplo n.º 14
0
 public ErasableMemory(ushort address, MemoryBank bank)
     : base(address, bank)
 {
 }
Exemplo n.º 15
0
        public TagAccessForm(MyReader myReader, Byte antenna, String tagIDStr, String tagType, MemoryBank mb)
        {
            InitializeComponent();
            this.myReader = myReader;
            this.antenna = antenna;
            this.tagIDStr = tagIDStr;
            this.tagType = tagType;
            

            tagID = Util.ConvertHexStringToByteArray(this.tagIDStr);
            this.mb = mb;
        }
Exemplo n.º 16
0
        public void SetValue_with_invalid_parametermode_should_throw()
        {
            var memory = new MemoryBank();

            Assert.Throws <InvalidEnumArgumentException>(() => memory.SetValue(0, 1, (ParameterMode)100));
        }
Exemplo n.º 17
0
        public static bool ReadUserdata_6C(uint offsetAddr, uint length, byte[] selCode, MemoryBank selArea, out byte[] data, out string errInfo)
        {
            data    = null;
            errInfo = "";
            byte            readlen = (byte)(length / 2);
            byte            ptr     = (byte)(offsetAddr / 2);
            ReadUserData_6C msg;

            if (selCode != null)
            {
                msg = new ReadUserData_6C(0x01, ptr, readlen, selCode, selArea);
            }
            else
            {
                msg = new ReadUserData_6C(0x01, ptr, readlen);
            }

            if (RfReader.Send(msg))
            {
                data = msg.ReceivedMessage.UserData;
                if (data != null)
                {
                    return(true);
                }
            }
            else
            {
                if (msg.ErrInfo == null || msg.ErrInfo == "")
                {
                    errInfo = string.Format("0x{0}", msg.StatusCode.ToString("X2"));
                }
                else
                {
                    errInfo = msg.ErrInfo;
                }
                Log.Debug(errInfo);
            }
            return(false);
        }
Exemplo n.º 18
0
 public FullRegister(ushort address, MemoryBank bank)
     : base(address, bank)
 {
 }
Exemplo n.º 19
0
 public static bool WriteEpc(byte[] accessPwd, byte[] writedata, byte[] selCode, MemoryBank selArea, out string errInfo)
 {
     errInfo = "";
     Invengo.NetAPI.Protocol.IRP1.WriteEpc msg;
     if (selCode != null)
     {
         msg = new WriteEpc(Antenna, accessPwd, writedata, selCode, selArea);
     }
     else
     {
         msg = new WriteEpc(Antenna, accessPwd, writedata);
     }
     if (RfReader.Send(msg))
     {
         if (msg.StatusCode == 0x00)
         {
             return(true);
         }
     }
     else
     {
         if (msg.ErrInfo == null || msg.ErrInfo == "")
         {
             errInfo = string.Format("0x{0}", msg.StatusCode.ToString("X2"));
         }
         else
         {
             errInfo = msg.ErrInfo;
         }
         Log.Debug(msg.ErrInfo);
     }
     return(false);
 }
Exemplo n.º 20
0
 public FixedMemory(ushort address, MemoryBank bank)
     : base(address, bank)
 {
 }
Exemplo n.º 21
0
        public static bool WriteUserdata_6C(uint offset, byte[] accessPwd, byte[] writedata, byte[] selCode, MemoryBank selArea, out string errInfo)
        {
            errInfo = "";
            WriteUserData_6C msg;
            byte             ptr = (byte)(offset / 2);

            if (selCode != null)
            {
                msg = new WriteUserData_6C(Antenna, accessPwd, ptr, writedata, selCode, selArea);
            }
            else
            {
                msg = new WriteUserData_6C(Antenna, accessPwd, ptr, writedata);
            }
            if (RfReader.Send(msg))
            {
                return(true);
            }
            else
            {
                if (msg.ErrInfo == null || msg.ErrInfo == "")
                {
                    errInfo = string.Format("0x{0}", msg.StatusCode.ToString("X2"));
                }
                else
                {
                    errInfo = msg.ErrInfo;
                }
                Log.Debug(errInfo);
            }
            return(false);
        }
Exemplo n.º 22
0
 public ErasableBankRegister(ushort address, MemoryBank bank)
     : base(address, bank)
 {
 }
Exemplo n.º 23
0
 public ShiftRightRegister(ushort address, MemoryBank bank)
     : base(address, bank)
 {
 }
Exemplo n.º 24
0
        public static bool BlockWriteData_6C(uint offset, byte[] accessPwd, MemoryBank writebank, byte[] writedata, byte[] selCode, MemoryBank selArea, ushort maxBlockLength, out int hadLen, out string errInfo)
        {
            bool ret    = false;
            int  tmpLen = writedata.Length;

            hadLen = 0;
            if (maxBlockLength < 1)
            {
                maxBlockLength = 4;
            }
            errInfo = "";
            bool bl = false;

            do
            {
                tmpLen = (writedata.Length - hadLen);
                if (tmpLen <= 0)
                {
                    break;
                }
                if (tmpLen > maxBlockLength)
                {
                    tmpLen = maxBlockLength;
                }
                byte[] tmpArr = new byte[tmpLen];
                Array.Copy(writedata, hadLen, tmpArr, 0, tmpLen);
                uint iOffset = (uint)(offset + hadLen);
                for (int i = 0; i < 3; i++)
                {
                    bl = BlockWriteDataRaw_6C(iOffset, accessPwd, writebank, (byte)maxBlockLength, tmpArr, selCode, selArea, out errInfo);
                    if (bl)
                    {
                        break;
                    }
                }
                if (!bl)
                {
                    break;
                }
                hadLen += tmpArr.Length;
            } while (hadLen < writedata.Length);

            if (hadLen >= writedata.Length)
            {
                hadLen = writedata.Length;
                ret    = true;
            }
            return(ret);
        }
        public AsSelectMaskParam(int index, MaskTargetType maskTarget, MaskActionType maskAction, MemoryBank maskBank, int maskOffset, string maskData, int maskLength, bool usedMask)
            : base(NSObjectFlag.Empty)
        {
            if (maskData == null)
            {
                throw new ArgumentNullException("maskData");
            }
            var nsmaskData = NSString.CreateNative(maskData);

            IsDirectBinding = GetType().Assembly == global::ApiDefinition.Messaging.this_assembly;
            if (IsDirectBinding)
            {
                InitializeHandle(global::ApiDefinition.Messaging.IntPtr_objc_msgSend_int_UInt32_UInt32_UInt32_int_IntPtr_int_bool(this.Handle, Selector.GetHandle("initWithParameterLength:target:action:bank:offset:mask:length:used:"), index, (UInt32)maskTarget, (UInt32)maskAction, (UInt32)maskBank, maskOffset, nsmaskData, maskLength, usedMask), "initWithParameterLength:target:action:bank:offset:mask:length:used:");
            }
            else
            {
                InitializeHandle(global::ApiDefinition.Messaging.IntPtr_objc_msgSendSuper_int_UInt32_UInt32_UInt32_int_IntPtr_int_bool(this.SuperHandle, Selector.GetHandle("initWithParameterLength:target:action:bank:offset:mask:length:used:"), index, (UInt32)maskTarget, (UInt32)maskAction, (UInt32)maskBank, maskOffset, nsmaskData, maskLength, usedMask), "initWithParameterLength:target:action:bank:offset:mask:length:used:");
            }
            NSString.ReleaseNative(nsmaskData);
        }
Exemplo n.º 26
0
        public static bool BlockEraseData_6C(uint offset, byte[] accessPwd, MemoryBank writebank, uint blockLength, uint blockSize, byte[] selCode, MemoryBank selArea, out string errInfo)
        {
            BlockErase_6C msg;

            errInfo = "";
            byte ptr = (byte)(offset / 2);

            if (selCode != null)
            {
                msg = new BlockErase_6C(Antenna, accessPwd, writebank, ptr, (byte)blockLength, (byte)blockSize, selCode, selArea);
            }
            else
            {
                msg = new BlockErase_6C(Antenna, accessPwd, writebank, ptr, (byte)blockLength, (byte)blockSize);
            }
            if (RfReader.Send(msg))
            {
                return(true);
            }
            else
            {
                if (msg.ErrInfo == null || msg.ErrInfo == "")
                {
                    errInfo = string.Format("0x{0}", msg.StatusCode.ToString("X2"));
                }
                else
                {
                    errInfo = msg.ErrInfo;
                }
                Log.Debug(errInfo);
            }
            return(false);
        }
Exemplo n.º 27
0
 public ProgramCounter(ushort address, MemoryBank bank)
     : base(address, bank)
 {
 }
Exemplo n.º 28
0
        public static bool LockTag_6C(byte[] accessPwd, byte operation, byte bank, byte[] selCode, MemoryBank selArea, out string errInfo)
        {
            errInfo = "";
            Invengo.NetAPI.Protocol.IRP1.LockMemoryBank_6C msg = null;
            if (selCode != null)
            {
                msg = new LockMemoryBank_6C(Antenna, accessPwd, operation, bank, selCode, selArea);
            }
            else
            {
                msg = new LockMemoryBank_6C(Antenna, accessPwd, operation, bank);
            }

            if (RfReader.Send(msg))
            {
                return(true);
            }
            else
            {
                if (msg.ErrInfo == null || msg.ErrInfo == "")
                {
                    errInfo = string.Format("0x{0}", msg.StatusCode.ToString("X2"));
                }
                else
                {
                    errInfo = msg.ErrInfo;
                }
                Log.Debug(msg.ErrInfo);
            }
            return(false);
        }
Exemplo n.º 29
0
 public MemoryWord(ushort address, MemoryBank bank)
 {
     this.bank = bank;
     Address   = address;
 }
Exemplo n.º 30
0
 public void InitializeMemoryBank()
 {
     var t_Bank = new MemoryBank(100);
 }