public IEnumerator addBlockID(string _block) { WWWForm form = new WWWForm(); form.AddField("requestType", "getBlock"); form.AddField("block", _block); form.AddField("includeTransactions", "true"); form.AddField("includeExecutedPhased", "true"); UnityWebRequest www = UnityWebRequest.Post("http://localhost:27876/nxt", form); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { //Debug.Log(www.downloadHandler.text); info = JsonUtility.FromJson <dataBlock>(www.downloadHandler.text); //tools.getClassValues(returnData); GameObject _display = Instantiate(ardorBlock, new Vector3(Center.transform.localPosition.x, Center.transform.localPosition.y, Center.transform.localPosition.z), Quaternion.identity); _display.transform.parent = Center.transform; _display.SendMessage("handle", info); blockList.Add(_display); refreshList(); } yield return(null); }
public IEnumerator refreshBlock(requestBlock data) { if (data == null) { data = new requestBlock(); } WWWForm form = new WWWForm(); form.AddField("requestType", "getBlock"); string request = "http://localhost:27876/nxt"; request += "requestType "; if (data.block != null) { form.AddField("block", data.block); } if (data.height != null) { form.AddField("height", data.height); } if (data.timestamp != null) { form.AddField("timestamp", data.timestamp); } //if (data.includeTransactions != false) // { form.AddField("includeTransactions", "true"); //} // if (data.includeExecutedPhased != false) // { form.AddField("includeExecutedPhased", "true"); // } if (data.requireBlock != null) { form.AddField("requireBlock", data.requireBlock); } if (data.requireLastBlock != null) { form.AddField("requireLastBlock", data.requireLastBlock); } UnityWebRequest www = UnityWebRequest.Post("http://localhost:27876/nxt", form); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { //Debug.Log(www.downloadHandler.text); _data = JsonUtility.FromJson <dataBlock>(www.downloadHandler.text); //tools.getClassValues(returnData); StartCoroutine(createTransactions(_data)); } }
/// <summary> /// Load the file. /// </summary> /// <param name="b"></param> public void load(byte[] b) { //Stream. MemoryStream src = new MemoryStream(b); BinaryDataReader br = new BinaryDataReader(src); br.ByteOrder = ByteOrder.LittleEndian; //Stuff. magic = br.ReadChars(4); identifier = br.ReadUInt32(); fileSize = br.ReadUInt32(); headerSize = br.ReadUInt16(); nBlocks = br.ReadUInt16(); data = new dataBlock(); data.magic = br.ReadChars(4); data.size = br.ReadUInt32(); data.info = new infoStuff(); data.info.waveType = br.ReadByte(); data.info.loopFlag = br.ReadByte(); data.info.nSampleRate = br.ReadUInt16(); data.info.nTime = br.ReadUInt16(); data.info.nloopOffset = br.ReadUInt16(); data.info.nNonLoopLength = br.ReadUInt32(); switch (data.info.waveType) { case 0: data.pcm8 = br.ReadBytes((int)data.size - 0x14); break; case 1: data.pcm16 = br.ReadInt16s(((int)data.size - 0x14) / 2); break; case 2: data.imaAdpcm = br.ReadBytes((int)data.size - 0x14); break; } }
public IEnumerator createTransactions(dataBlock info) { yield return(new WaitForEndOfFrame()); _data = info; transactions = info.transactions; labelBlockID.text = info.block; int i = 0; foreach (dataTransactions trans in info.transactions) { print(trans.block); GameObject _display = Instantiate(display, new Vector3(transactionHolder.transform.position.x, transactionHolder.transform.localPosition.y + i + 1, transactionHolder.transform.position.z), Quaternion.identity); _display.transform.parent = transactionHolder.transform; _display.SendMessage("fillData", trans); i++; } yield return(null); }
public string[] ConvertS19Data(int iLengthDataBlock) { List <string> sTarget = new List <string>(); int icount = recordCount(); s19rec rec = default(s19rec); int recDecimalAddress = 0; int recDataLength = 0; List <dataBlock> listDataBlock = new List <dataBlock>(); List <dataBlock> listAlignedDataBlock = new List <dataBlock>(); List <byte> currentBlockData = new List <byte>(); int currentBlockAddress = 0; //Dim prevBlockData As New List(Of Byte) //Dim prevBlockAddress As Integer = 0 int nextStartAddress = 0; List <byte> bytesTemp = new List <byte>(); for (var i = 0; i <= icount - 1; i++) { rec = getS19Rec(System.Convert.ToInt32(i)); switch (rec.type) { case '0': myAddS19Record(sTarget, rec.type, convBytesToHexa(rec.address.ToArray()), convBytesToHexa(rec.data.ToArray())); break; case '1': break; case '2': break; case '3': //dirección y longitud del bloque de datos recDecimalAddress = RoutinesLibrary.Data.DataType.IntegerUtils.BytesToInt(rec.address.ToArray(), true); //is BigEndian recDataLength = rec.data.Count; //address gap if (recDecimalAddress > nextStartAddress) { //new block. recording cumulative data if (currentBlockData.Count > 0) { dataBlock block = new dataBlock(currentBlockAddress, currentBlockData.ToArray()); listDataBlock.Add(block); } //accumulates new data currentBlockData.Clear(); currentBlockData.AddRange(rec.data.ToArray()); currentBlockAddress = recDecimalAddress; //no gap } else { //add to current block currentBlockData.AddRange(rec.data.ToArray()); } //calculate next address, to control gaps nextStartAddress = recDecimalAddress + recDataLength; break; case '5': break; case '7': case '8': case '9': break; } } //add remaining data in last block if (currentBlockData.Count > 0) { dataBlock block = new dataBlock(currentBlockAddress, currentBlockData.ToArray()); listDataBlock.Add(block); } //'Align all directions to 128 (iLengthDataBlock) //For i = 0 To listDataBlock.Count - 1 // If listDataBlock.Item(i).m_Address Mod iLengthDataBlock <> 0 Then // 'Calculamos el gap inicial // Dim nInitialGap As Integer = listDataBlock.Item(i).m_Address - ((listDataBlock.Item(i).m_Address \ 128) * 128) // 'Rellenamos los datos iniciales con FF // Dim alignData(listDataBlock.Item(i).m_Data.Length + nInitialGap - 1) As Byte // setArrayTo(alignData, &HFF) // Array.Copy(listDataBlock.Item(i).m_Data, 0, alignData, nInitialGap, listDataBlock.Item(i).m_Data.Length) // 'Actualizamos el array de datos // listDataBlock.Item(i).m_Data = alignData // 'Actualizamos el address // listDataBlock.Item(i).m_Address -= nInitialGap // End If //Next //Align all directions to 128 int lastAlignedDataBlock = -1; for (var i = 0; i <= listDataBlock.Count - 1; i++) { lastAlignedDataBlock = listAlignedDataBlock.Count - 1; if (listDataBlock[System.Convert.ToInt32(i)].m_Address % iLengthDataBlock != 0) { //If listDataBlock.Item(i).m_Address > 486635784 Then // MsgBox("> 486635784") //End If int nInitialGap = 0; int nEndGap = 0; byte[] alignData = null; int nCopyDataLength = 0; int nTargetBufferToCopyLength = 0; // ver si la dirección está dentro del bloque alineado anterior (múltiplo de 128) bool bAlignBlock = true; if (i > 0 & lastAlignedDataBlock >= 0) { int iPreviousBlockAddress = System.Convert.ToInt32(listAlignedDataBlock[lastAlignedDataBlock].m_Address); int iPreviousBlockDataLength = System.Convert.ToInt32(listAlignedDataBlock[lastAlignedDataBlock].m_Data.Length); int iPreviousBlockAlignedBlocks = iPreviousBlockDataLength / iLengthDataBlock; if (iPreviousBlockDataLength / iLengthDataBlock != (double)iPreviousBlockDataLength / iLengthDataBlock) { iPreviousBlockAlignedBlocks++; } if (listDataBlock[System.Convert.ToInt32(i)].m_Address < iPreviousBlockAddress + (iPreviousBlockAlignedBlocks * iLengthDataBlock)) { // copiar parte de los datos al bloque anterior // primero el gap entre el fin de datos y la nueva dirección nEndGap = System.Convert.ToInt32(listDataBlock[System.Convert.ToInt32(i)].m_Address - (iPreviousBlockAddress + iPreviousBlockDataLength)); // espacio que tengo para copiar = el total alineado menos los datos existentes y el gap añadido nTargetBufferToCopyLength = (iPreviousBlockAlignedBlocks * iLengthDataBlock) - (iPreviousBlockDataLength + nEndGap); // datos a copiar: mínimo entre espacio destino y datos origen nCopyDataLength = Math.Min(nTargetBufferToCopyLength, System.Convert.ToInt32(listDataBlock[System.Convert.ToInt32(i)].m_Data.Length)); //Rellenamos los datos iniciales con FF alignData = new byte[nEndGap + nCopyDataLength - 1 + 1]; setArrayTo(ref alignData, (byte)(0xFF)); Array.Copy((System.Array)(listDataBlock[System.Convert.ToInt32(i)].m_Data), 0, alignData, nEndGap, nCopyDataLength); // copiar a bloque anterior bytesTemp.Clear(); bytesTemp.AddRange(listAlignedDataBlock[lastAlignedDataBlock].m_Data); bytesTemp.AddRange(alignData); listAlignedDataBlock[lastAlignedDataBlock].m_Data = bytesTemp.ToArray(); // quitar estos datos del bloque actual y modificar address bytesTemp.Clear(); bytesTemp.AddRange(listDataBlock[System.Convert.ToInt32(i)].m_Data); bytesTemp.RemoveRange(0, nCopyDataLength); if (bytesTemp.Count > 0) { listDataBlock[System.Convert.ToInt32(i)].m_Data = bytesTemp.ToArray(); // modificar address listDataBlock[System.Convert.ToInt32(i)].m_Address = listDataBlock[System.Convert.ToInt32(i)].m_Address + nCopyDataLength; } else { bAlignBlock = false; } } } if (bAlignBlock) { //Calculamos el gap inicial nInitialGap = System.Convert.ToInt32(listDataBlock[System.Convert.ToInt32(i)].m_Address - ((listDataBlock[System.Convert.ToInt32(i)].m_Address / iLengthDataBlock) * iLengthDataBlock)); //Rellenamos los datos iniciales con FF alignData = new byte[listDataBlock[System.Convert.ToInt32(i)].m_Data.Length + nInitialGap - 1 + 1]; setArrayTo(ref alignData, (byte)(0xFF)); Array.Copy((System.Array)(listDataBlock[System.Convert.ToInt32(i)].m_Data), 0, alignData, nInitialGap, System.Convert.ToInt32(listDataBlock[System.Convert.ToInt32(i)].m_Data.Length)); //Actualizamos el array de datos listDataBlock[System.Convert.ToInt32(i)].m_Data = alignData; //Actualizamos el address listDataBlock[System.Convert.ToInt32(i)].m_Address -= nInitialGap; // add aligned block listAlignedDataBlock.Add(listDataBlock[System.Convert.ToInt32(i)]); } } else { // add block, already aligned listAlignedDataBlock.Add(listDataBlock[System.Convert.ToInt32(i)]); } } // build SREC in iDataBlock format byte[] newData = null; newData = new byte[iLengthDataBlock - 1 + 1]; int iCopyLength = 0; int iDataLengthRemainder = 0; int iAddress = 0; int nextStartByte = 0; int iBlockNumber = 0; bool bEnd = false; //recorrer todos los bloques de datos //For i = 0 To listDataBlock.Count - 1 for (var i = 0; i <= listAlignedDataBlock.Count - 1; i++) { //dirección y datos del bloque de datos //currentBlockAddress = listDataBlock.Item(i).m_Address currentBlockAddress = System.Convert.ToInt32(listAlignedDataBlock[System.Convert.ToInt32(i)].m_Address); currentBlockData.Clear(); //currentBlockData.AddRange(listDataBlock.Item(i).m_Data) currentBlockData.AddRange(listAlignedDataBlock[System.Convert.ToInt32(i)].m_Data); //If currentBlockAddress > 486635784 Then // MsgBox("> 486635784") //End If nextStartByte = 0; iBlockNumber = 0; bEnd = false; //loop por el bloque para dividir en direcciones de 128 do { //determinar cuanto queda por copiar iDataLengthRemainder = currentBlockData.Count - nextStartByte; if (iDataLengthRemainder > 0) { //copiamos un bloque entero de datos o el resto if (iDataLengthRemainder > iLengthDataBlock) { iCopyLength = iLengthDataBlock; } else { iCopyLength = iDataLengthRemainder; } //número de bloque a copiar iBlockNumber++; //el buffer de 128 a HFF setArrayTo(ref newData, (byte)(0xFF)); //copy data Array.Copy(currentBlockData.ToArray(), nextStartByte, newData, 0, iCopyLength); //la nueva dirección es la dirección base del bloque más la cantidad de bloques copiados iAddress = currentBlockAddress + (iLengthDataBlock * (iBlockNumber - 1)); //grabar el bloque myAddS19Record(sTarget, '3', convBytesToHexa(intToBytesAddress(iAddress, true)), convBytesToHexa(newData)); //actualizar la siguiente dirección nextStartByte += iCopyLength; } else { bEnd = true; } } while (!bEnd); } return(sTarget.ToArray()); }
public void handle(dataBlock info) { StartCoroutine(createTransactions(info)); print("sent"); }
/// <summary> /// Load the file. /// </summary> /// <param name="b"></param> public void load(byte[] b) { //Reader. MemoryStream src = new MemoryStream(b); BinaryDataReader br = new BinaryDataReader(src); br.ByteOrder = ByteOrder.LittleEndian; //Read stuff. magic = br.ReadChars(4); identifier = br.ReadUInt32(); fileSize = br.ReadUInt32(); headerSize = br.ReadUInt16(); nBlocks = br.ReadUInt16(); head = new headBlock(); data = new dataBlock(); //Head block. head.magic = br.ReadChars(4); head.size = br.ReadUInt32(); head.waveType = br.ReadByte(); head.loop = br.ReadByte(); head.numChannel = br.ReadByte(); head.unknown = br.ReadByte(); head.nSampleRate = br.ReadUInt16(); head.nTime = br.ReadUInt16(); head.nLoopOffset = br.ReadUInt32(); head.nSample = br.ReadUInt32(); head.nDataOffset = br.ReadUInt32(); head.nBlock = br.ReadUInt32(); head.nBlockLen = br.ReadUInt32(); head.nBlockSample = br.ReadUInt32(); head.nLastBlockLen = br.ReadUInt32(); head.nLastBlockSample = br.ReadUInt32(); head.reserved = br.ReadBytes(32); //Data block. data.magic = br.ReadChars(4); data.size = br.ReadUInt32(); switch (head.waveType) { case 0: data.pcm8 = new byte[head.numChannel][]; if (head.nBlock != 1) { throw new Exception("BAD PCM8 BLOCK!"); } for (int i = 0; i < head.numChannel; i++) { data.pcm8[i] = br.ReadBytes((int)head.nLastBlockLen); } break; case 1: data.pcm16 = new short[head.numChannel][]; if (head.nBlock != 1) { throw new Exception("BAD PCM16 BLOCK!"); } for (int i = 0; i < head.numChannel; i++) { data.pcm16[i] = br.ReadInt16s((int)head.nLastBlockLen / 2); } break; //The big one! case 2: data.imaAdpcm = new dataBlock.imaAdpcmBlock[head.numChannel][]; for (int i = 0; i < head.numChannel; i++) { data.imaAdpcm[i] = new dataBlock.imaAdpcmBlock[head.nBlock]; } for (int i = 0; i < head.nBlock - 1; i++) { for (int j = 0; j < head.numChannel; j++) { data.imaAdpcm[j][i] = new dataBlock.imaAdpcmBlock(); //data.imaAdpcm[j][i].identifier = br.ReadUInt32(); data.imaAdpcm[j][i].data = br.ReadBytes((int)head.nBlockLen); } } for (int j = 0; j < head.numChannel; j++) { data.imaAdpcm[j][head.nBlock - 1] = new dataBlock.imaAdpcmBlock(); //data.imaAdpcm[j][head.nBlock - 1].identifier = br.ReadUInt32(); data.imaAdpcm[j][head.nBlock - 1].data = br.ReadBytes((int)head.nLastBlockLen); } break; } }
public static dataBlockData ReadDataBlock(BufferedStreamReader streamReader, int offset, dataBlock offsetBlock) { dataBlockData data = new dataBlockData(); data.rawBlock = offsetBlock; data.unkInt0 = offsetBlock.unkInt0; streamReader.Seek(offsetBlock.internalName0Offset + offset, System.IO.SeekOrigin.Begin); data.internalName0 = AquaObjectMethods.ReadCString(streamReader); streamReader.Seek(offsetBlock.chatCommandOffset + offset, System.IO.SeekOrigin.Begin); data.chatCommand = AquaObjectMethods.ReadCString(streamReader); streamReader.Seek(offsetBlock.internalName1Offset + offset, System.IO.SeekOrigin.Begin); data.internalName1 = AquaObjectMethods.ReadCString(streamReader); streamReader.Seek(offsetBlock.lobbyActionIdOffset + offset, System.IO.SeekOrigin.Begin); data.lobbyActionId = AquaObjectMethods.ReadCString(streamReader); streamReader.Seek(offsetBlock.commonReferenceOffset0 + offset, System.IO.SeekOrigin.Begin); data.commonReference0 = AquaObjectMethods.ReadCString(streamReader); streamReader.Seek(offsetBlock.commonReferenceOffset1 + offset, System.IO.SeekOrigin.Begin); data.commonReference1 = AquaObjectMethods.ReadCString(streamReader); streamReader.Seek(offsetBlock.unkIntOffset0 + offset, System.IO.SeekOrigin.Begin); data.unkOffsetInt0 = streamReader.Read <int>(); streamReader.Seek(offsetBlock.unkIntOffset1 + offset, System.IO.SeekOrigin.Begin); data.unkOffsetInt1 = streamReader.Read <int>(); streamReader.Seek(offsetBlock.unkIntOffset2 + offset, System.IO.SeekOrigin.Begin); data.unkOffsetInt2 = streamReader.Read <int>(); streamReader.Seek(offsetBlock.iceNameOffset + offset, System.IO.SeekOrigin.Begin); data.iceName = AquaObjectMethods.ReadCString(streamReader); streamReader.Seek(offsetBlock.humanAqmOffset + offset, System.IO.SeekOrigin.Begin); data.humanAqm = AquaObjectMethods.ReadCString(streamReader); streamReader.Seek(offsetBlock.castAqmOffset1 + offset, System.IO.SeekOrigin.Begin); data.castAqm1 = AquaObjectMethods.ReadCString(streamReader); streamReader.Seek(offsetBlock.castAqmOffset2 + offset, System.IO.SeekOrigin.Begin); data.castAqm2 = AquaObjectMethods.ReadCString(streamReader); streamReader.Seek(offsetBlock.kmnAqmOffset + offset, System.IO.SeekOrigin.Begin); data.kmnAqm = AquaObjectMethods.ReadCString(streamReader); streamReader.Seek(offsetBlock.vfxOffset + offset, System.IO.SeekOrigin.Begin); data.vfxIce = AquaObjectMethods.ReadCString(streamReader); return(data); }