protected void Push(VooProtocol protocol) { Console.WriteLine("Application: Push(VooProtocol protocol)"); VooFile file = new VooFile(protocol.Source, protocol.Destination, protocol.Get("from"), protocol.Get("to"), Convert.ToInt64(protocol.Get("size"))); Console.WriteLine("Application: Push from = '{0}', to = '{1}', size = '{2}'", file.From, file.To, file.Size); pushes.Add(file); }
private void SendFileAction() { if (session != null) { // TODO: Create custom packets for sending files. Console.Write("Push: "); String from = Console.ReadLine(); Console.Write("To: "); String to = Console.ReadLine(); if (File.Exists(from)) { VooFile file = new VooFile(session.Source, session.Destination, from, to); Console.WriteLine("Application: SendFileAction() -> read file('{0}')", from); file.ReadToEnd(); // lock (RS485Events.synchronized) { RS485PacketManager manager = new RS485PacketManager( new RS485_dll.Voodoo.Libraries.RS485Library.RS485Terminal.InputData( RS485Packet.PriorityEnum.High, file.Data, session.Source, session.Destination, session.Source), 32); RS485Packet packet = new RS485Packet(session.Source, session.Source, session.Destination, RS485Packet.PriorityEnum.High, RS485Packet.CommandEnum.Data, VooProtocol.CreatePushCommand(session.ToString(), from, to, Convert.ToString(file.Data.Length))); manager.Packets.Insert(0, packet); Managers.Add(manager); } } else { Console.WriteLine("File doesn't exist."); } } else { Console.WriteLine("Please input session information."); } }
protected void Fetch(VooProtocol protocol) { Console.WriteLine("Application: Fetch(VooProtocol protocol)"); Console.WriteLine("Application: Fetch -> from = '{0}', to = '{1}'", protocol.Get("from"), protocol.Get("to")); VooFile file = new VooFile(protocol.Source, protocol.Destination, protocol.Get("from"), protocol.Get("to")); fetches.Add(file); Console.WriteLine("Application: Fetch -> read data"); file.ReadToEnd(); RS485PacketManager manager = new RS485PacketManager(new RS485_dll.Voodoo.Libraries.RS485Library.RS485Terminal.InputData(RS485Packet.PriorityEnum.Highest, file.Data, protocol.Destination, protocol.Source, protocol.Destination), 32); RS485Packet packet = new RS485Packet(protocol.Destination, protocol.Destination, protocol.Source, RS485Packet.PriorityEnum.Highest, RS485Packet.CommandEnum.Data, protocol.CreatePushCommand()); manager.Packets.Insert(0, packet); Console.WriteLine("Application: Call send packets."); RS485VooEvents.Instance.SendPackets(manager); }