示例#1
0
 public bool Write(UInt64 val)
 {
     DTPMaster.CheckConnAndVal();
     if (ph.File_Append(BitConverter.GetBytes(val)))
     {
         cacheLength += _Ui64;
         CursorPos   += _Ui64;
         return(true);
     }
     return(false);
 }
示例#2
0
 internal SecurityManager(DTPMaster dTPMaster)
 {
     ParentMaster         = dTPMaster;
     IsValidationRequired = ParentMaster.ph.Security_IsValidationRequired();
     try
     {
         _validated = ParentMaster.ph.Device_DataTest(new byte[] { 1, 2 });
     }
     catch (SecurityException)
     {
         _validated = false;
     }
 }
示例#3
0
 public bool Write(byte val)
 {
     DTPMaster.CheckConnAndVal();
     if (ph.File_Append(new byte[1] {
         val
     }))
     {
         cacheLength += _Ui8;
         CursorPos   += _Ui8;
         return(true);
     }
     return(false);
 }
示例#4
0
        public bool Validate(SecurityKey Key)
        {
            if (IsValidated)
            {
                return(true);
            }

            DTPMaster.CheckConnAndVal(true);
            if (ParentMaster.ph.Security_Validate(Key.key))
            {
                _validKey = Key;
                return(true);
            }
            return(false);
        }
示例#5
0
        public SecurityForm(DTPMaster master)
        {
            InitializeComponent();
            Master = master;
            radioButton1.Checked = !master.SecurityManager.IsValidationRequired;
            // radioButton2.Checked = master.SecurityManager.IsValidationRequired;

            if (master.SecurityManager.IsValidationRequired)
            {
                radioButton2.Checked = true;
            }

            button2.Enabled = !radioButton1.Checked;
            button3.Enabled = !radioButton1.Checked;
        }
示例#6
0
        public void Close()
        {
            DTPMaster.CheckConnAndVal();
            if (!IsOpen)
            {
                throw new FileHandlerException("Файл закрыт");
            }
            var res = Master.ph.File_Close();

            if (!res)
            {
                throw new FailOperationException("Не удалось закрыть файл");
            }
            IsOpen = false;
            IsGlobalOpenedFiles = false;
        }
示例#7
0
        public SdCardBinnaryFileReadResult <byte[]> ReadByteArray(UInt32 length)
        {
            DTPMaster.CheckConnAndVal();
            if (CursorPos + length > cacheLength)
            {
                throw new ArgumentOutOfRangeException();
            }
            var res = ph.File_Read(CursorPos, length);

            if (res.Status == GeneralPacketHandler.WriteReadFileHandleResult.OK)
            {
                CursorPos += length;
                return(new SdCardBinnaryFileReadResult <byte[]>(res.Result, true));
            }
            return(new SdCardBinnaryFileReadResult <byte[]>(new byte[0], false));
        }
示例#8
0
        private SdCardBinnaryFileReadResult <object> ReadDouble()
        {
            DTPMaster.CheckConnAndVal();
            if (CursorPos + _D > cacheLength)
            {
                throw new ArgumentOutOfRangeException();
            }
            var res = ph.File_Read(CursorPos, _D);

            if (res.Status == GeneralPacketHandler.WriteReadFileHandleResult.OK)
            {
                CursorPos += _D;
                return(new SdCardBinnaryFileReadResult <object>(BitConverter.ToDouble(res.Result, 0), true));
            }
            return(new SdCardBinnaryFileReadResult <object>(0, false));
        }
示例#9
0
        private SdCardBinnaryFileReadResult <object> ReadBool()
        {
            DTPMaster.CheckConnAndVal();
            if (CursorPos + _Ui8 > cacheLength)
            {
                throw new ArgumentOutOfRangeException();
            }
            var res = ph.File_Read(CursorPos, _Ui8);

            if (res.Status == GeneralPacketHandler.WriteReadFileHandleResult.OK)
            {
                CursorPos += _Ui8;
                return(new SdCardBinnaryFileReadResult <object>(res.Result[0] == 1, true));
            }
            return(new SdCardBinnaryFileReadResult <object>(0, false));
        }
示例#10
0
        public void Delete(bool DeleteSubItems)
        {
            DTPMaster.CheckConnAndVal();
            if (DirectoryPath == "/")
            {
                throw new FileHandlerException("Невозможно удалить корень -_-");
            }
            if (!IsExists)
            {
                throw new FileHandlerException("Папка не существует");
            }
            var res = master.ph.Dir_Delete(DirectoryPath, DeleteSubItems);

            if (res != GeneralPacketHandler.FileDirHandleResult.OK)
            {
                throw new FailOperationException(res);
            }
        }
示例#11
0
        public SdCardDirectory Create(bool CreateNecessary)
        {
            DTPMaster.CheckConnAndVal();
            if (DirectoryPath == "/")
            {
                throw new FileHandlerException("Невозможно создать корень -_-");
            }
            if (IsExists)
            {
                throw new FileHandlerException("Папка уже существует");
            }
            var res = master.ph.Dir_Create(DirectoryPath, CreateNecessary);

            if (res != GeneralPacketHandler.FileDirHandleResult.OK)
            {
                throw new FailOperationException("Не удалось создать папку", res);
            }
            return(this);
        }
示例#12
0
        public void ClearAllBytes()
        {
            DTPMaster.CheckConnAndVal();
            if (IsOpen)
            {
                if (!Master.ph.File_Close())
                {
                    throw new FailOperationException("Не удалось закрыть файл");
                }
            }
            var res = Master.ph.File_Open(FilePath, true);

            if (res != GeneralPacketHandler.WriteReadFileHandleResult.OK)
            {
                throw new FailOperationException("Не удалось открыть файл", res);
            }
            if (!IsOpen)
            {
                if (!Master.ph.File_Close())
                {
                    throw new FailOperationException("Не удалось закрыть файл");
                }
            }
        }
示例#13
0
 internal SdCardDirectory(string path, DTPMaster ph)
 {
     DirectoryPath = path;
     master        = ph;
 }
示例#14
0
 internal SdCardFile(string path, DTPMaster master)
 {
     FilePath = path;
     Master   = master;
 }