public void CreateNewEthernetData(EthernetParams data, Action <IIndexItem <EthernetExtraInfo> > onSuccess, OnErr onError) { this.Create(data.Display, data, this.ethernetStorage, onSuccess, (ethernetParam) => { this.RaiseEthernetListChange(() => { }, onError); }, onError, new EthernetExtraInfo(data)); }
public void T11_EditAndSave() { try { TestHelpers.CatchUnexpected(() => { this.SubscribeToChange(); List <IIndexItem <EthernetExtraInfo> > list = this.SetupAndRetrieveList(2); IIndexItem <EthernetExtraInfo> idx = list[0]; EthernetParams p = this.RetrieveData(idx); string display = "BLAH PHUT"; string address = "221.221.221.1"; string port = "99"; p.Display = display; p.EthernetAddress = address; p.EthernetServiceName = port; TDI.Wrapper.SaveEthernetData(idx, p, this.OnSuccessDummy, AssertErr); this.AssertCompleteFired(); this.AssertIndexChangeFired(); this.RetrieveAndValidate(idx, display, address, port); }); } finally { this.UnsubscribeToChange(); } }
public void T02_CreateNewWithIndex() { TestHelpers.CatchUnexpected(() => { try { this.SubscribeToChange(); EthernetParams data = new EthernetParams() { Display = "Extra param", EthernetAddress = "192.168.1.33", EthernetServiceName = "10000", }; IIndexItem <EthernetExtraInfo> idx = null; TDI.Wrapper.CreateNewEthernetData(data, (x) => { idx = x; }, AssertErr); Assert.NotNull(idx, "Bad index item"); this.AssertIndexChangeFired(); this.SetupData(3); EthernetParams retrieved = this.RetrieveData(idx); Assert.NotNull(retrieved, "Bad retrieved params"); Assert.AreEqual(data.UId, retrieved.UId); Assert.AreEqual(data.Display, retrieved.Display, "retrieved"); Assert.AreEqual(data.EthernetAddress, retrieved.EthernetAddress, "retrieved"); Assert.AreEqual(data.EthernetServiceName, retrieved.EthernetServiceName, "retrieved"); Assert.AreEqual(data.Display, idx.Display, "idx"); Assert.AreEqual(data.EthernetAddress, idx.ExtraInfoObj.Address, "idx"); Assert.AreEqual(data.EthernetServiceName, idx.ExtraInfoObj.Port, "idx"); } finally { this.UnsubscribeToChange(); } }); }
private EthernetParams RetrieveData(IIndexItem <EthernetExtraInfo> index) { EthernetParams data = null; TDI.Wrapper.RetrieveEthernetData(index, p => { data = p; }, this.AssertErr); Assert.NotNull(data, "Failed to retrieve"); return(data); }
private void Ethernet_ParamsRequestedEventHandler(object sender, EthernetParams e) { ErrReport report; WrapErr.ToErrReport(out report, 200107, "Failure on Ethernet_ParamsRequestedEventHandler", () => { this.EthernetParamsRequestedEvent?.Invoke(sender, e); }); this.RaiseIfException(report); }
public void ConnectAsync(EthernetParams dataModel) { this.OnEthernetConnectionAttemptCompleted?.Invoke(this, new MsgPumpResults() { Code = MsgPumpResultCode.NotConnected, ErrorString = "NOT IMPLEMENTED", //SocketErr = SocketErrCode.Unknown, }); }
public EthernetInfo(Window parent, EthernetParams info) { this.parent = parent; InitializeComponent(); this.Title = info.Display; this.txtHost.Content = info.EthernetAddress; this.txtService.Content = info.EthernetServiceName; this.SizeToContent = SizeToContent.WidthAndHeight; }
public void EthernetConnectAsync(EthernetParams dataModel) { ErrReport report; WrapErr.ToErrReport(out report, 200100, "Failure on EthernetConnectAsync", () => { this.log.Info("EthernetConnect", "Connecting to ethernet"); this.ethernet.ConnectAsync(dataModel); }); this.RaiseIfException(report); }
public void T04_RetrieveItem() { TestHelpers.CatchUnexpected(() => { var index = this.SetupAndRetrieveList(2); EthernetParams p = this.RetrieveData(index[0]); Assert.AreEqual("EthernetParam 0", p.Display); Assert.AreEqual("192.168.1.0", p.EthernetAddress); Assert.AreEqual("0", p.EthernetServiceName); }); }
private EthernetParams RetrieveAndValidate(IIndexItem <EthernetExtraInfo> index, string display, string address, string port) { EthernetParams p = this.RetrieveData(index); Assert.AreEqual(display, p.Display, "Param Data"); Assert.AreEqual(address, p.EthernetAddress, "Param Data"); Assert.AreEqual(port, p.EthernetServiceName, "Param Data"); Assert.AreEqual(p.Display, index.Display, "index Data"); Assert.AreEqual(p.EthernetAddress, index.ExtraInfoObj.Address, "index Data"); Assert.AreEqual(p.EthernetServiceName, index.ExtraInfoObj.Port, "index Data"); return(p); }
private void SetupData(uint count) { for (uint i = 0; i < count; i++) { EthernetParams item = new EthernetParams() { Display = string.Format("EthernetParam {0}", i), EthernetAddress = string.Format("192.168.1.{0}", i), EthernetServiceName = i.ToString(), }; try { this.SubscribeToChange(); TDI.Wrapper.CreateNewEthernetData(item, this.OnSuccessDummy, this.AssertErr); this.AssertCompleteFired(); this.AssertIndexChangeFired(); } finally { this.UnsubscribeToChange(); } } }
public void SaveEthernetData(IIndexItem <EthernetExtraInfo> idx, EthernetParams data, Action onSuccess, OnErr onError) { WrapErr.ToErrReport(9999, () => { ErrReport report; WrapErr.ToErrReport(out report, 9999, () => { idx.ExtraInfoObj.Update(data); this.Save(this.ethernetStorage, idx, data, (obj, idx) => { }, onSuccess, (d) => { this.RaiseEthernetListChange(() => { }, onError); //this.GetEthernetDataList( // (list) => { // this.OnEthernetListChange?.Invoke(this, list); // //onSuccess.Invoke(); // }, onError); }, onError); }); if (report.Code != 0) { onError.Invoke(this.GetText(MsgCode.SaveFailed)); } }); }
public void ConnectAsync(EthernetParams dataModel) { this.log.InfoEntry("ConnectAsync ***************"); if (dataModel.EthernetAddress.Length == 0 || dataModel.EthernetServiceName.Length == 0) { // TODO - request params event this.log.Error(9999, "Params requested"); this.ParamsRequestedEvent?.Invoke(this, dataModel); } // Check for erroron data model if (dataModel.EthernetAddress.Length == 0 || dataModel.EthernetServiceName.Length == 0) { this.log.Error(9999, "ERROR ON Params requested"); this.OnError(this, new MsgPumpResults(MsgPumpResultCode.EmptyParams)); } else { //this.Disconnect(); Thread.Sleep(500); this.log.Error(9999, "Doing connect"); // Test Arduino: 192.168.1.88:9999 this.msgPump.ConnectAsync2(new SocketMsgPumpConnectData() { MaxReadBufferSize = 100, RemoteHostName = dataModel.EthernetAddress, ServiceName = dataModel.EthernetServiceName, // TODO - determine protection level according to connection ProtectionLevel = SocketProtectionLevel.PlainSocket, }); } }
public EthernetExtraInfo(EthernetParams info) { this.Update(info); }
private void Wrapper_EthernetParamsRequestedEventHandler(object sender, EthernetParams e) { //throw new NotImplementedException(); // TODO Show an ethernet params window }
public static void ShowBox(Window parent, EthernetParams info) { EthernetInfo win = new EthernetInfo(parent, info); win.ShowDialog(); }
public void Update(EthernetParams info) { this.Address = info.EthernetAddress; this.Port = info.EthernetServiceName; }
public void CreateNewEthernetData(EthernetParams data, Action onSuccess, OnErr onError) { this.CreateNewEthernetData(data, (idx) => { onSuccess(); }, onError); }
private void DoEthernetPort() { string subDir = @"MultiCommSerialTerminal\EthernetData"; string oldPath = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), subDir); this.log.Info("DoEthernetPort", () => string.Format("oldPath:{0}", oldPath)); // Old storage exits if (Directory.Exists(oldPath)) { this.log.Info("DoEthernetPort", () => string.Format("Path exist")); IIndexedStorageManager <Ethernet.Common.Net.DataModels.EthernetParams, DefaultFileExtraInfo> ethSt = new IndexedStorageManager <Ethernet.Common.Net.DataModels.EthernetParams, DefaultFileExtraInfo>( new JsonReadWriteSerializerIndented <Ethernet.Common.Net.DataModels.EthernetParams>(), new JsonReadWriteSerializerIndented <IIndexGroup <DefaultFileExtraInfo> >()); ethSt.StorageSubDir = subDir; ethSt.IndexFileName = "EthernetDataIndex.txt"; this.log.Info("DoEthernetPort", () => string.Format("Number Items:", ethSt.IndexedItems.Count)); foreach (var ndx in ethSt.IndexedItems) { Ethernet.Common.Net.DataModels.EthernetParams data = ethSt.Retrieve(ndx); if (data != null) { //this.log.Info("DoEthernetPort", () => string.Format("")); this.log.Info("DoEthernetPort", () => string.Format("Data good:{0}", data.Display)); // the objects have either Display or Name. So we will get it from the old index first part string display = data.Display; if (display.Length == 0) { string[] parts = ndx.Display.Split(':'); if (parts != null && parts.Length > 0) { display = parts[0]; } } EthernetParams newData = new EthernetParams() { UId = data.UId, Display = display, EthernetAddress = data.EthernetAddress, EthernetServiceName = data.EthernetServiceName, }; IIndexItem <EthernetExtraInfo> idx = new IndexItem <EthernetExtraInfo>(newData.UId, new EthernetExtraInfo(newData)) { Display = newData.Display, }; bool ok = this.ethernetStorage.Store(newData, idx); this.log.Info("DoEthernetPort", () => string.Format("Stored result:{0}", ok)); } } // Try it once ethSt.DeleteStorageDirectory(); } }
private void paramsRequestedEventHandler(object sender, EthernetParams e) { this.Dispatcher.Invoke(() => { EthernetEditRequest.ShowBox(this, this.selectedEthernet); }); }