Exemplo n.º 1
0
        public void processParamaterFile()
        {
            ParameterFile parameterFile = new ParameterFile();

            parameterFile.Load(@"c:\Temp\demo.parfile");
            logger.Info(parameterFile.Model.Name);
            logger.Info(parameterFile.Model.FrameSize.ToString());
            logger.Info(parameterFile.Classifier.Product.ToString());
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Loads the machine parameters
        /// </summary>
        /// <param name="strConnection">The STR connection.</param>
        /// <externalUnit/>
        /// <revision revisor="dev11" date="12/23/2008" version="1.0.0.0">
        ///     Member Created
        /// </revision>
        private void LoadMachParams(string strConnection)
        {
            BallotEntrySet machParm = new BallotEntrySet(typeof(StpMachParm));

            machParm.Load(strConnection);

            for (int i = 0; i < machParm.Count; i = i + 1)
            {
                ParameterFile file = new ParameterFile();
                file.Name = machParm.GetValueStr(i, StpMachParm.ParamName);
                this.machineParams.ParameterFiles.Add(file);
            }
        }
Exemplo n.º 3
0
        public void downloadFile(IPAddress ipAddress, string filePath, DownloadType fileType)
        {
            try
            {
                BlockingCommsUser commsUser = new BlockingCommsUser();
                CommsAddress      address   = new CommsAddress(ipAddress, 0);

                // Set communication protocol
                T_STATUS State = commsUser.Go(Protocol.EthernetProtocol());

                if (State != T_STATUS.OK)
                {
                    logger.Error("Failed To Connect : Status Code : " + State.ToString());
                    return;
                }

                logger.Debug("Connected to Drive");

                string destination = null;
                switch (fileType)
                {
                case DownloadType.PARAMETERS:
                    //destination = "/par/all"; // can only read
                    destination = "par/macro";
                    break;

                case DownloadType.MACRO:
                    destination = "/par/macro";
                    break;

                case DownloadType.ONBOARD:
                    destination = "/sys/prog/user";
                    break;
                }

                string rawFilePath       = filePath;
                string parameterFilePath = filePath;

                if (fileType == DownloadType.PARAMETERS)
                {
                    //Change the parameter file into a macro file
                    XmlDocument doc = new XmlDocument();
                    doc.Load(filePath);
                    XmlNodeList aNodes = doc.SelectNodes("/ParameterFile");
                    if (aNodes.Count != 1)
                    {
                        //There should only be one node by this name
                        throw new Exception("ParameterFile Node missing, or incorrectly formated Paarmeter File");
                    }
                    if (aNodes[0].Attributes == null)
                    {
                        throw new Exception("ParameterFile Node incorrectly formated, missing Attributes");
                    }

                    if (aNodes[0].Attributes["type"] == null)
                    {
                        throw new Exception("ParameterFile Node incorrectly formated, missing type Attribute");
                    }
                    aNodes[0].Attributes["type"].Value = "Macro"; //Change the file to a macro file

                    parameterFilePath = Path.ChangeExtension(filePath, "tmp_par");

                    doc.Save(parameterFilePath);
                    if (!File.Exists(parameterFilePath))
                    {
                        throw new Exception("Error Processing Parameter File Save Macro");
                    }
                }

                if (fileType == DownloadType.PARAMETERS || fileType == DownloadType.MACRO)
                {
                    //Load the parameter file
                    ParameterFile parameterFile = new ParameterFile();
                    parameterFile.Load(parameterFilePath);

                    //convert the parameter file to a raw file for download
                    RawParameterFile rawParams = RawParameterFile.CreateFromParameterFile(parameterFile);

                    rawFilePath = parameterFilePath.Replace(Path.GetExtension(parameterFilePath), ".bin"); //Replace the original filename with the bin file
                    rawParams.Write(rawFilePath, true);
                    if (!File.Exists(rawFilePath))
                    {
                        logger.Error("Error writing intermediate raw file " + rawFilePath);
                        return;
                    }
                }

                FileWriteDiskMessageRequest writeDiskReq = new FileWriteDiskMessageRequest(rawFilePath, destination, FileWriteOptions.None);

                FileWriteDiskMessageResponse response;
                logger.Debug("Downloading File");
                T_RESPONSE_STATUS Status = commsUser.FileWriteDisk(address, writeDiskReq, out response);
                logger.Info("Download Complete");
                //logger.Info("Download Complete - Time Taken : " + response.TimeTaken + " Status : " + response.Status.ToString());

                if (Status != T_RESPONSE_STATUS.OK)
                {
                    logger.Error("Download Failed - Status: " + Status.ToString());
                }

                //Delete the intermediate raw file if created
                if (fileType == DownloadType.PARAMETERS || fileType == DownloadType.MACRO)
                {
                    File.Delete(rawFilePath);
                }
            } catch (Exception ex)
            {
                logger.Error("Execption : " + ex.ToString());
                return;
            }
        }