public void WriteInt()
        {
            var rw     = ReadWriteFactory.GetReadWriteNet();
            var result = rw.Write(PLCAddress, PLCValue);

            if (result.IsSuccess)
            {
                ErrorMessage = "Success!";
            }
            else
            {
                ErrorMessage = result.Message;
            }
        }
Example #2
0
 /// <summary>
 /// 保存数据
 /// </summary>
 /// <param name="filename"></param>
 /// <param name="dh"></param>
 /// <param name="ph"></param>
 /// <returns></returns>
 //private static bool DoSave(string filename, DataHelper dh, PeekHelper ph)
 //{
 //    return DoSave(filename, dh, ph, null);
 //}
 /// <summary>
 /// 保存数据
 /// </summary>
 /// <param name="filename"></param>
 /// <param name="dh"></param>
 /// <param name="ph"></param>
 /// <returns></returns>
 private static bool DoSave(string filename, DataHelper dh, PeakHelper ph, DetectPeakParameter dpp)
 {
     try
     {
         if (dh == null || ph == null)
         {
             return(false);
         }
         IFileReadWrite file = ReadWriteFactory.CreateFileInstance(SerialType.Binary);
         try
         {
             file.OpenFile(filename, FileOpenFlag.Create);
             List <MemoryStream> mlst = new List <MemoryStream>();
             MemoryStream        ms   = new MemoryStream();
             //save points
             dh.Serialize(ref ms);
             mlst.Add(ms);
             file.WriteContent(mlst, 0);
             //save peaks
             mlst.Clear();
             ms = new MemoryStream();
             ph.SerializePeaks(ref ms);
             mlst.Add(ms);
             file.WriteContent(mlst, 1);
             //save operates
             //mlst.Clear();
             //ms = new MemoryStream();
             //ph.SerializeOperates(ref ms);
             //mlst.Add(ms);
             //file.WriteContent(mlst, 2);
             //save Detect Peak Parameter
             mlst.Clear();
             ms = new MemoryStream();
             dpp.Serialize(ref ms);
             mlst.Add(ms);
             file.WriteContent(mlst, 2);
         }
         finally
         {
             file.CloseFile();
         }
         return(true);
     }
     catch (Exception ex)
     {
         LogHelper.WriteError(ex);
         return(false);
     }
 }
Example #3
0
 /// <summary>
 /// 打开数据
 /// </summary>
 /// <param name="filename"></param>
 /// <returns></returns>
 private static bool DoOpen(string filename, DataHelper dh, PeakHelper ph, DetectPeakParameter dpp)
 {
     try
     {
         //if (dh == null || ph == null) return false;
         if (!File.Exists(filename))
         {
             return(false);
         }
         IFileReadWrite file = ReadWriteFactory.CreateFileInstance(SerialType.Binary);
         try
         {
             file.OpenFile(filename, FileOpenFlag.Open);
             List <MemoryStream> mlst = new List <MemoryStream>();
             //open points
             if (dh != null && file.ReadContent(0, out mlst))
             {
                 dh.Deserialize(mlst[0]);
             }
             mlst = new List <MemoryStream>();
             //open peaks
             if (ph != null && file.ReadContent(1, out mlst))
             {
                 ph.DeserializePeaks(mlst[0]);
             }
             mlst = new List <MemoryStream>();
             ////open operates
             //if (ph != null && file.ReadContent(2, out mlst))
             //    ph.DeserializeOperates(mlst[0]);
             //open Detect Peak Parameter
             if (dpp != null && file.ReadContent(2, out mlst))
             {
                 dpp.Deserialize(mlst[0]);
             }
             return(true);
         }
         finally
         {
             file.CloseFile();
         }
     }
     catch (Exception ex)
     {
         LogHelper.WriteError(ex);
         return(false);
     }
 }
Example #4
0
        /// <summary>
        /// 获得图形点集列表
        /// </summary>
        /// <returns></returns>
        private List <List <PointF> > GetGraphList(List <string> filenames)
        {
            if (filenames == null || filenames.Count == 0)
            {
                return(null);
            }
            IFileReadWrite        file     = ReadWriteFactory.CreateFileInstance(SerialType.Binary);
            string                filename = "";
            List <List <PointF> > lst      = new List <List <PointF> >();

            for (int i = 0; i < filenames.Count; i++)
            {
                filename = filenames[i];
                if (!File.Exists(filename))
                {
                    continue;
                }
                try
                {
                    file.OpenFile(filename, FileOpenFlag.Open);
                    List <MemoryStream> mlst = new List <MemoryStream>();
                    //open points
                    if (file.ReadContent(0, out mlst))
                    {
                        DataHelper dh = new DataHelper();
                        dh.Deserialize(mlst[0]);
                        if (dh != null && dh.List != null && dh.List.Count > 0)
                        {
                            lst.Add(dh.List);
                        }
                    }
                }
                finally
                {
                    file.CloseFile();
                }
            }
            return(lst);
        }