Ejemplo n.º 1
0
        public SipperSimulator(String sipperFileName)
        {
            InitializeComponent();

            if (String.IsNullOrEmpty(sipperFileName))
            {
                sipperFileName = "C:\\Pices\\SipperFiles\\WB0813\\WB0813DSH09\\WB0813DSH09_03.spr";
            }

            //ConvertCTDfile ();

            simulatorDir = OSservices.AddSlash(OSservices.AddSlash(PicesSipperVariables.SipperInterfaceDir()) + "Simulator");

            configRec      = new SipperConfigRec();
            currentDataRow = new InstrumentData();

            conversationBuffer   = Queue.Synchronized(new Queue());
            serialPortBuffers    = new SerialPortBuffer[3];
            serialPortBuffers[0] = new SerialPortBuffer(512);
            serialPortBuffers[1] = new SerialPortBuffer(512);
            serialPortBuffers[2] = new SerialPortBuffer(512);

            // SplitFile ();
            // ChkFile ();
            //LoadSipperFile();

            ctdData         = new List <char>();
            ctdDataNextByte = 0;

            pitchRollData        = new ArrayList();
            pitchRollDataNextRow = 0;

            ExtractDataFromSIPPERFile(sipperFileName);

            LoadCameraLines();

            batteryPack  = new BatteryPack();
            sipperCamera = new SipperCamera();

            ctdThread      = new Thread(new ThreadStart(CTDDataInstrument));
            ctdThread.Name = "SipperCtdData";
            ctdThread.Start();

            pitchRollThread      = new Thread(new ThreadStart(PitchRollDataInstrument));
            pitchRollThread.Name = "SipperPitchRollData";
            pitchRollThread.Start();

            batteryPackThread      = new Thread(new ThreadStart(BatteryPackInstrument));
            batteryPackThread.Name = "SipperBatteryData";
            batteryPackThread.Start();

            LoadSipperFilesNames();
        }
Ejemplo n.º 2
0
        } /* ReadHardDrive */

        private void  ReadSerialPort(string s)
        {
            s = s.Trim();

            int serialPortNum = PicesKKStr.StrToInt(s);

            if ((serialPortNum < 0) || (serialPortNum >= serialPortBuffers.Length))
            {
                WriteToSocket("Invalid Serial Port[" + serialPortNum + "]\n");
                WriteToTextWindow("Invalid Serial Port[" + serialPortNum + "]\n");
            }

            else
            {
                SerialPortBuffer sp = serialPortBuffers[serialPortNum];
                if (sp == null)
                {
                    WriteToSocket("Invalid Serial Port[" + serialPortNum + "]\n");
                    WriteToTextWindow("Invalid Serial Port[" + serialPortNum + "]\n");
                }

                else
                {
                    int amtDataAvailable = sp.SpaceUsed();
                    int x = 0;

                    string textLine = "";

                    for (x = 0; x < amtDataAvailable; x++)
                    {
                        char ch = sp.ReadChar();
                        textLine += ch.ToString();
                    }

                    WriteToSocket(textLine);
                    WriteToTextWindow(textLine);

                    if (sp.SpaceUsed() > 0)
                    {
                        WriteToSocket("** WARNING ** Buffer not emptied.");
                        WriteToTextWindow("** WARNING ** Buffer not emptied.");
                    }
                }
            }
        } /* ReadSerialPort */