public void OnEndDrag(PointerEventData eventData) { //OnMouseMove(new Vector3(eventData.position.x, eventData.position.y, 0)); OnMouseUp(); //AddLetterDataEnd(); _lastWriteTime = Time.time; _writeStatus = WriteStatus.WritingPause; }
// 进行识别 private void Recognizing() { Debug.Log("Recognizing"); _writeStatus = WriteStatus.Recognizing; RecognizingFun(); }
public MemoryRangeDescriptor(ulong minimum, ulong maximum, ulong length, ulong alignment, WriteStatus writeStatus) : base(AddressSpaceDescriptor.ResourceType.MemoryRange, minimum, maximum, length, alignment) { this.acpiMemoryFlags = AcpiMemoryFlags.None; this.memoryToIoTranslation = MemoryToIoTranslation.TypeStatic; this.addressRangeAttribute = AddressRangeAttribute.Memory; this.cacheableAttribute = CacheableAttribute.NonCacheable; this.writeStatus = writeStatus; }
// 识别完成 private void RecognizeComplete() { _writeStatus = WriteStatus.RecognizeFinished; // 清理画布 Clear(texRender); DrawImage(); ClearLetterData(); _writeStatus = WriteStatus.Init; }
public void OnDrag(PointerEventData eventData) { _OnUpdated.Invoke(); float x = eventData.position.x - rawMousePosition.x; float y = eventData.position.y - rawMousePosition.y; AddLetterData(x, y); OnMouseMove(new Vector3(eventData.position.x, eventData.position.y, 0)); DrawImage(); _writeStatus = WriteStatus.Writing; }
public void OnDrag(PointerEventData eventData) { //Debug.Log("OnDrag"); float x = eventData.position.x - rawMousePosition.x; float y = eventData.position.y - rawMousePosition.y; //Debug.Log("rawMousePosition : " + rawMousePosition); //AddLetterData(x, y); OnMouseMove(new Vector3(eventData.position.x, eventData.position.y, 0)); DrawImage(); _writeStatus = WriteStatus.Writing; }
public MemoryRangeDescriptor(ResourceType resourceType, ulong minimum, ulong maximum, ulong length, ulong alignment, ulong addressTranslationOffset, bool minimumAddressIsFixed, bool maximumAddressIsFixed, DecodeType decodeType, ConsumerProducer consumerProducer, AcpiMemoryFlags acpiMemoryFlags, MemoryToIoTranslation memoryToIoTranslation, AddressRangeAttribute addressRangeAttribute, CacheableAttribute cacheableAttribute, WriteStatus writeStatus) : base(resourceType, minimum, maximum, length, alignment, addressTranslationOffset, minimumAddressIsFixed, maximumAddressIsFixed, decodeType, consumerProducer) { this.acpiMemoryFlags = acpiMemoryFlags; this.memoryToIoTranslation = memoryToIoTranslation; this.addressRangeAttribute = addressRangeAttribute; this.cacheableAttribute = cacheableAttribute; this.writeStatus = writeStatus; }
public string this[string key] { get { DbEntry keyEntry = DbEntry.InOut(Encoding.Default.GetBytes(key)); DbEntry dataEntry = DbEntry.InOut(dataStream.GetBuffer()); ReadStatus res = btree.Get(txn, ref keyEntry, ref dataEntry, DbFile.ReadFlags.None); return(Encoding.Default.GetString(dataEntry.Buffer, 0, dataEntry.Size)); } set { DbEntry keyEntry = DbEntry.InOut(Encoding.Default.GetBytes(key)); DbEntry dataEntry = DbEntry.InOut(Encoding.Default.GetBytes(value)); WriteStatus res = btree.Put(txn, ref keyEntry, ref dataEntry); } }
//byte[] bytes = null; //private IEnumerator coroutine; void RecognizingFun() { // 识别功能 // 将 texture 保存为图片 string pathDir = Application.streamingAssetsPath + "/temp/writepanel"; //RenderTexture prev = RenderTexture.active; //RenderTexture.active = texRender; //设置当前的 render //System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); //sw.Start(); // 获取缩放后的图片, 此时的图片大小为200,200 Texture2D newPng = ScaleTexture(raw.texture, writePanelConfig.writePanelWordRectWidth, writePanelConfig.writePanelWordRectHeight); // 保存至本地,可关闭该功能 string filename = UnityEngine.Random.Range(0, 999).ToString(); SaveBytesToFile(newPng.EncodeToPNG(), pathDir, filename); //sw.Stop(); short[] datas = PrepareLetterData(); // write File.WriteAllText(Application.streamingAssetsPath + "/temp/writepanel/" + filename + ".txt", String.Join(",", datas)); //Debug.Log("File : " + filename); _recogQueuer.AddRecogTask(datas, _OnRecognizeError, _OnRecognizeSuccess, () => { _writeStatus = WriteStatus.RecognizeFinished; }); // 清理 //Destroy(png); //png = null; //Texture2D.DestroyImmediate(png); //RenderTexture.active = prev; }
private void AddRecord(DbBTree btree, Txn txn, Customer value, TextWriter writer) { // use standard .NET serialization, with the binary formatter keyStream.Position = 0; formatter.Serialize(keyStream, value.Name); DbEntry key = DbEntry.InOut(keyStream.GetBuffer(), 0, (int)keyStream.Position); dataStream.Position = 0; formatter.Serialize(dataStream, value); DbEntry data = DbEntry.InOut(dataStream.GetBuffer(), 0, (int)dataStream.Position); // calling PutNew means we don't want to overwrite an existing record WriteStatus status = btree.PutNew(txn, ref key, ref data); // if we tried to insert a duplicate, let's report it if (status == WriteStatus.KeyExist) { writer.WriteLine("Duplicate record: " + value.Name); } }
void FixedUpdate() { float now = Time.time; if (_writeStatus == WriteStatus.Writing) { } if (_writeStatus == WriteStatus.WritingPause && ((now - _lastWriteTime) > 2f)) { _writeStatus = WriteStatus.WriteFinished; } if (_writeStatus == WriteStatus.WriteFinished) { // 开始确认 _writeStatus = WriteStatus.Init; } }
void FixedUpdate() { float now = Time.time; if (_writeStatus == WriteStatus.Writing) { } if (_writeStatus == WriteStatus.WritingPause && ((now - _lastWriteTime) > writePanelConfig.recognizeIntervalTime)) { _writeStatus = WriteStatus.WriteFinished; } if (_writeStatus == WriteStatus.WriteFinished) { FinishAddLetterData(); // 开始确认 _writeStatus = WriteStatus.RecognizeStart; } if (_writeStatus == WriteStatus.RecognizeStart) { Recognizing(); } if (_writeStatus == WriteStatus.Recognizing) { // Do Recognizing } if (_writeStatus == WriteStatus.RecognizeFinished) { // DO Recognize finished RecognizeComplete(); _writeStatus = WriteStatus.Init; } }
public void Save <T>(IEnumerable <T> items) where T : class { dbName = typeof(T).FullName; initDatabase(); Txn trans = env.TxnBegin(null, Txn.BeginFlags.ReadCommitted); foreach (T t in items) { MemoryStream memKey = new MemoryStream( ); MemoryStream memVal = new MemoryStream(); formatter.Serialize(memKey, t.GetHashCode()); formatter.Serialize(memVal, t); memKey.Flush(); memVal.Flush(); DbEntry key = DbEntry.InOut(memKey.ToArray()); DbEntry value = DbEntry.InOut(memVal.ToArray()); WriteStatus status = dbInstance.PutUnique(trans, ref key, ref value); if (status == WriteStatus.KeyExist) { Debug.Print("key {0} duplicated", t.GetHashCode()); } if (status == WriteStatus.KeyExist) { Delete <T>(t); WriteStatus st = dbInstance.PutUnique(trans, ref key, ref value); } } trans.Commit(Txn.CommitMode.Sync); env.Close(); }
// load databases from files vendors.txt and inventory.txt private void LoadBtn_Click(object sender, EventArgs e) { if (errStream != null) { errStream.Close(); } Databases dbs = Databases.Instance; string dbPath = Path.Combine(Application.StartupPath, "Db"); string appName = Path.GetFileName(Application.ExecutablePath); errStream = File.Open(Path.Combine(dbPath, "errors.txt"), FileMode.OpenOrCreate, FileAccess.Write); dbs.Open(dbPath, appName, errStream); // load vendors StreamReader sr = new StreamReader(Path.Combine(dbPath, "vendors.txt")); Regex rgx = new Regex("(.*)#(.*)#(.*)#(.*)#(.*)#(.*)#(.*)#(.*)", RegexOptions.Compiled); Vendor vendor = new Vendor(); string line; DbEntry keyEntry; DbEntry dataEntry; while ((line = sr.ReadLine()) != null && line.Length > 0) { Match match = rgx.Match(line); GroupCollection groups = match.Groups; if (groups.Count < 9) { throw new ApplicationException("Input error on vendors.txt"); } InitVendorFromRegex(vendor, groups); keyEntry = dbs.Fmt.ToDbEntry <string>(vendor.Name); dataEntry = dbs.Fmt.ToDbEntry <Vendor>(vendor); WriteStatus status = dbs.VendorDb.Put(null, ref keyEntry, ref dataEntry); if (status != WriteStatus.Success) { throw new ApplicationException("Put failed"); } } // load inventory sr = new StreamReader(Path.Combine(dbPath, "inventory.txt")); rgx = new Regex("(.*)#(.*)#(.*)#(.*)#(.*)#(.*)", RegexOptions.Compiled); StockItem item = new StockItem(); int count = 0; while ((line = sr.ReadLine()) != null && line.Length > 0) { Match match = rgx.Match(line); GroupCollection groups = match.Groups; if (groups.Count < 7) { throw new ApplicationException("Input error on inventory.txt"); } InitStockItemFromRegex(item, groups); keyEntry = dbs.Fmt.ToDbEntry <string>(item.Sku); dataEntry = dbs.Fmt.ToDbEntry <StockItem>(item); WriteStatus status = dbs.InventoryDb.Put(null, ref keyEntry, ref dataEntry); if (status != WriteStatus.Success) { throw new Exception("Put failed"); } count++; } }
public int Getaaa(string enumName) { WriteStatus writeStatus = Enum.Parse <WriteStatus>(enumName); return((int)writeStatus); }
public void OnBeginDrag(PointerEventData eventData) { //OnMouseUp(); //OnMouseMove(new Vector3(eventData.position.x, eventData.position.y, 0)); _writeStatus = WriteStatus.Init; }
public PipeWriteResult(WriteStatus status, int?bytesWritten) { Status = status; BytesWritten = bytesWritten; }
public PipeWriteResult(WriteStatus status) : this(status, null) { }
public string Getaaa(int enumNumber) { WriteStatus writeStatus = (WriteStatus)enumNumber; return(writeStatus.ToString()); }
private bool ProcessFile(Guid aFolderId, string aSourceFilePath, MaterialFolderIndexRecord aNewRecord, TimeInterval aInterval, string aNewFilePath) { bool result = false; bool waitforIntra = true; Guid clientGuid = Guid.NewGuid(); try { using (FileStream file = File.OpenRead(aSourceFilePath)) { using (IMaterialFile newFile = MaterialFileFactory.CreateMaterialFile(aFolderId, aNewRecord, aNewFilePath)) { int readBytes = 0; int startFrameOffset = 0; bool startFound = false; byte[] buffer = new byte[16 * 1024]; DateTime lastFrameTimeStamp = DateTime.MinValue; List <byte> frameBuffer = new List <byte>(); do { if (_stopTask.IsCancellationRequested) { return(false); } startFrameOffset = 0; readBytes = file.Read(buffer, 0, buffer.Length); for (int pos = 0; pos < readBytes - Constants.FrameStart.Length; ++pos) { if (IsEqual(buffer, pos, Constants.FrameStart)) { startFound = true; startFrameOffset = pos; frameBuffer.Clear(); } if (IsEqual(buffer, pos, Constants.FrameEnd)) { int endFramePos = pos + Constants.FrameEnd.Length; CopyBuffer(frameBuffer, buffer, startFrameOffset, endFramePos); startFound = false; startFrameOffset = 0; Frame frame = null; try { using (MemoryStream stream = new MemoryStream(frameBuffer.ToArray())) { try { frame = new Frame(); frame.Deserialize(stream); } catch { continue; } if (frame.Metadata.Timestamp <= lastFrameTimeStamp) { // Skip old frames continue; } if (frame.Metadata.ChannelId != aNewRecord.ChannelId || frame.DataType != aNewRecord.DataType) { // Skip other data continue; } if (waitforIntra && !frame.Metadata.IsIntra) { // Skip non intra if we wait intra continue; } waitforIntra = false; if (aInterval.Contains(frame.Metadata.Timestamp)) { MaterialPosition position = null; WriteStatus writeStatus = newFile.Write(frame, ref position); if (writeStatus == WriteStatus.OK) { // Update material folder index record if (aNewRecord.BeginTimestamp.Ticks == 0) { aNewRecord.BeginTimestamp = frame.Metadata.Timestamp; } aNewRecord.EndTimestamp = frame.Metadata.Timestamp; // Update result result = true; // Add to frame times lastFrameTimeStamp = frame.Metadata.Timestamp; } else { SendError($"Write frame error, status: {writeStatus}, source file {aSourceFilePath}, destination file {aNewFilePath}!"); waitforIntra = true; } } } } catch (Exception ex) { SendError(ex.Message); waitforIntra = true; } finally { frame?.Release(); } } } if (startFound) { CopyBuffer(frameBuffer, buffer, startFrameOffset, buffer.Length); } } while (readBytes > 0); } } } catch (Exception ex) { SendError(ex.Message); } return(result); }