using System; using Microsoft.SPOT; namespace miniCPF { class oldStuff { } } //public static byte[] addPair(ColumnNums columnNum, byte[] valueByteArray, byte[] inMessage) //{ // tabIndex = 0; // LFIndex = -1; // tabCounter = 0; // //find the index of the desired token // while (tabCounter != (int)columnNum) // { // if (inMessage[tabIndex] == token) // tabCounter = tabCounter + 1; // tabIndex = tabIndex + 1; // } // tabIndex = tabIndex + 1; //Column numbers start at 0 and don't include the token between data and time // //find the index of the terminating LF // LFIndex = Array.IndexOf(inMessage, LF, 0); // numValueArrayBytes = Array.IndexOf(valueByteArray, 0, 0); // //Clear the out message // Array.Clear(outMessage, 0, outMessage.Length); // //Copy everything in the in message up to the desired token into out message // Array.Copy(inMessage, 0, outMessage, 0, tabIndex); // sb.Clear(); // sb.Append(UTF8Encoding.UTF8.GetChars(outMessage)); // Debug.Print(sb.ToString()); // //Copy the value into out message after the desired token // Array.Copy(valueByteArray, 0, outMessage, tabIndex, numValueArrayBytes); // sb.Clear(); // sb.Append(UTF8Encoding.UTF8.GetChars(outMessage)); // Debug.Print(sb.ToString()); // //Copy everything in the in message after the desired token into out message after the value byte array // Array.Copy(inMessage, tabIndex + 1, outMessage, tabIndex + numValueArrayBytes, LFIndex - tabIndex); // sb.Clear(); // sb.Append(UTF8Encoding.UTF8.GetChars(outMessage)); // Debug.Print(sb.ToString()); // return outMessage; //} //Old version that works on the single channel ADuC data message //private static void ADuCPortDataReceived(object sender, SerialDataReceivedEventArgs e) //{ // ADuCPortBytesToRead = ADuCPort.BytesToRead; // try // { // ADuCPort.Read(ADuCPortReadBytes, 0, ADuCPortBytesToRead); // } // catch // { // Debug.Print("ADuC Read Exception"); //TODO do something smarter here // } // for (int i = 0; i < ADuCPortBytesToRead; i++) // { // ADuCPortInByteArray[ADuCPortInByteArrayIndex] = ADuCPortReadBytes[i]; // if (ADuCPortInByteArrayIndex == 0) //Check to make sure first character is = LF // { // if (ADuCPortInByteArray[0] == 10) //only move on to byte index 1 after we get a LF // { // ADuCPortInByteArrayIndex = ADuCPortInByteArrayIndex + 1; // } // } // else // { // if (ADuCPortInByteArray[ADuCPortInByteArrayIndex] == 13) // { // lock (ADuCLock) // { // bellowsPosition = ((ADuCPortInByteArray[1] - 48.0) * 10.0) + (ADuCPortInByteArray[2] - 48.0) + // ((ADuCPortInByteArray[4] - 48.0) * 0.1) + ((ADuCPortInByteArray[5] - 48.0) * 0.01); // Debug.Print(" "); // Debug.Print("Bellows Position = " + bellowsPosition.ToString("F2")); // Debug.Print(" "); // } // ADuCPortInByteArrayIndex = 0; // } // else // { // ADuCPortInByteArrayIndex = ADuCPortInByteArrayIndex + 1; // } // } // } //} //public static byte[] getNewLogArrayHeader(byte[] comment) //{ // timeNow = DateTime.Now; // Array.Clear(tempQueueArray, 0, tempQueueArray.Length); // sb.Clear(); // sb.Append(timeNow.ToString()); // // Year/Month/Day token // for (int i = 6; i < 10; i++) // tempQueueArray[i - 6] = (byte)sb[i]; // tempQueueArray[4] = (byte)'/'; // for (i = 0; i < 2; i++) // tempQueueArray[i + 5] = (byte)sb[i]; // tempQueueArray[7] = (byte)'/'; // for (i = 3; i < 5; i++) // tempQueueArray[i + 5] = (byte)sb[i]; // tempQueueArray[10] = token; // // Hour:Minute:Second token // for (i = 11; i < 19; i++) // tempQueueArray[i] = (byte)sb[i]; // tempQueueArray[19] = token; // // Add in comment // //trim off the trailing empty array elements // //Note: comment array must be (byte)characters for this to work // endOfCommentIndex = Array.IndexOf(comment, 0); // if (endOfCommentIndex >= 0) // { // Array.Copy(comment, 0, tempQueueArray, 20, endOfCommentIndex); // tempQueueArray[20 + endOfCommentIndex] = token; // Array.Copy(Program.stateName[(int)Program.CPFState], 0, tempQueueArray, (21 + endOfCommentIndex), Program.stateName[(int)Program.CPFState].Length); // } // else // { // Array.Copy(comment, 0, tempQueueArray, 20, comment.Length); // tempQueueArray[20 + comment.Length] = token; // Array.Copy(Program.stateName[(int)Program.CPFState], 0, tempQueueArray, (21 + comment.Length), Program.stateName[(int)Program.CPFState].Length); // } // //tempCharArray = UTF8Encoding.UTF8.GetChars(tempQueueArray); // return tempQueueArray; //}