/// <summary> /// Uploads an RDY file to the terminal. /// </summary> /// <param name="path">The path to the RDY file.</param> /// <param name="replace">True to replace any existing table. False to throw an exception if the table exists already. (True by default.)</param> /// <param name="force">True to upload the file even if it fails validation. (False by default.)</param> public void UploadTableFromFile(string path, bool replace = true, bool force = false) { if (!string.Equals(Path.GetExtension(path), ".rdy", StringComparison.OrdinalIgnoreCase)) { throw new ArgumentException("Pass the full or relative path to a .RDY file."); } if (!File.Exists(path)) { throw new FileNotFoundException(string.Format("Could not find a file at {0}", Path.GetFullPath(path))); } // Read the file into an RDY var rdy = RdyFile.Read(path, force); // Check for directory files if (rdy.IsDirectoryFile) { // Upload each file referenced separately foreach (var record in rdy.Records) { // find the new full path var p = Path.GetDirectoryName(path) + Path.DirectorySeparatorChar + record.Data; // recurse to upload each file UploadTableFromFile(p, replace, force); } } else { // Just upload the single RDY Util.Log("Uploading " + rdy.Filename, _client.RemoteEndPoint.Address); UploadTableFromRdy(rdy, replace, force); } }
public void Can_Read_Normal_Rdy_File() { RdyFile rdy; using (var stream = File.OpenRead(@"TestData\msg800.rdy")) { rdy = RdyFile.Read(stream); } Assert.IsNotNull(rdy); Assert.IsFalse(rdy.IsDirectoryFile); Assert.AreEqual('V', rdy.Header.TableType); Assert.AreEqual(800, rdy.Header.TableId); Assert.AreEqual(64, rdy.Header.RecordCount); }
public void Can_Read_Directory_Rdy_File() { RdyFile rdy; using (var stream = File.OpenRead(@"TestData\dir001.rdy")) { rdy = RdyFile.Read(stream); } Assert.IsNotNull(rdy); Assert.IsTrue(rdy.IsDirectoryFile); Assert.AreEqual('z', rdy.Header.TableType); Assert.AreEqual(1, rdy.Header.TableId); Assert.AreEqual(87, rdy.Header.TotalCharacters); Assert.AreEqual(3, rdy.Records.Count); }
public void Can_Set_Fixed_Clock_Transitions() { var rdy = RdyFile.Read(@"TestData\sys001.rdy"); var sys = new SystemParameters(rdy); Assert.AreEqual(0, sys.ClockTransitions.Count); sys.ClockTransitions = new ClockTransition[] { new FixedClockTransition(1, new DateTime(2013, 3, 10, 2, 0, 0)), new FixedClockTransition(-1, new DateTime(2013, 11, 3, 2, 0, 0)) }; var value = sys.Parameters[5]; Assert.AreEqual("11003130200+110311130200-1", value); }
public void Can_Program_Clock_Transition() { var rdy = RdyFile.Read(@"TestData\sys001.rdy"); var sys = new SystemParameters(rdy); sys.ClockTransitions = new ClockTransition[] { new FixedClockTransition(1, new DateTime(2013, 3, 10, 2, 0, 0)), new FixedClockTransition(-1, new DateTime(2013, 11, 3, 2, 0, 0)) }; using (var client = TestSettings.Connect()) using (var p = client.Terminal.Programming()) { var rdyFile = sys.GetRdyFile(); p.UploadTableFromRdy(rdyFile); } }
public void Can_Parse_System_Parameters_Rdy_File() { var rdy = RdyFile.Read(@"TestData\sys001.rdy"); Assert.IsNotNull(rdy); Assert.IsFalse(rdy.IsDirectoryFile); Assert.AreEqual('p', rdy.Header.TableType); Assert.AreEqual(001, rdy.Header.TableId); var sys = new SystemParameters(rdy); Assert.IsNotNull(sys); Assert.AreEqual(10, sys.Parameters.Count); Assert.AreEqual("05", sys.Parameters[0]); Assert.AreEqual("B", sys.Parameters[1]); Assert.AreEqual("00000", sys.Parameters[2]); Assert.AreEqual("Y", sys.Parameters[3]); Assert.AreEqual("15", sys.Parameters[4]); Assert.AreEqual("", sys.Parameters[5]); Assert.AreEqual("50", sys.Parameters[6]); Assert.AreEqual("N", sys.Parameters[9]); Assert.AreEqual("3", sys.Parameters[11]); Assert.AreEqual("--", sys.Parameters[13]); }
/// <summary> /// Returns an awaitable task that uploads a stream containing an RDY file to the terminal. /// </summary> /// <param name="stream">The stream containing the RDY file content.</param> /// <param name="replace">True to replace any existing table. False to throw an exception if the table exists already. (True by default.)</param> /// <param name="force">True to upload the file even if it fails validation. (False by default.)</param> public async Task UploadTableFromStreamAsync(Stream stream, bool replace = true, bool force = false) { var rdy = RdyFile.Read(stream, force); await UploadTableFromRdyAsync(rdy, replace, force); }
/// <summary> /// Uploads a stream containing an RDY file to the terminal. /// </summary> /// <param name="stream">The stream containing the RDY file content.</param> /// <param name="replace">True to replace any existing table. False to throw an exception if the table exists already. (True by default.)</param> /// <param name="force">True to upload the file even if it fails validation. (False by default.)</param> public void UploadTableFromStream(Stream stream, bool replace = true, bool force = false) { var rdy = RdyFile.Read(stream, force); UploadTableFromRdy(rdy, replace, force); }