public string GetSegmentType(DataTable segmentsTable) { string format = "SHIFT_ID='{0}' AND SEGMENT_ID='{1}'"; string filter = string.Format(format, Shift, Segment); return(DataTable_Functions.GetTableValue(segmentsTable, filter, "TYPE")); }
public void SaveConfiguration(DataTable dt) { DataTable_Functions.TrakHound.DeleteRows(prefix + "*", "address", dt); int i = 0; foreach (var item in PartCountItems) { if (!string.IsNullOrEmpty(item.EventName) && !string.IsNullOrEmpty(item.EventValue)) { string eventPrefix = prefix + "Event||" + i.ToString("00"); DataTable_Functions.UpdateTableValue(dt, "address", eventPrefix, "attributes", "id||" + i.ToString("00") + ";"); DataTable_Functions.UpdateTableValue(dt, "address", eventPrefix + "/EventName", "value", item.EventName); DataTable_Functions.UpdateTableValue(dt, "address", eventPrefix + "/EventValue", "value", item.EventValue); DataTable_Functions.UpdateTableValue(dt, "address", eventPrefix + "/PreviousEventValue", "value", item.PreviousEventValue); DataTable_Functions.UpdateTableValue(dt, "address", eventPrefix + "/ValueType", "value", FormatValue(item.ValueType)); DataTable_Functions.UpdateTableValue(dt, "address", eventPrefix + "/CaptureItemLink", "value", item.CaptureItemLink); DataTable_Functions.UpdateTableValue(dt, "address", eventPrefix + "/CalculationType", "value", item.CalculationType); DataTable_Functions.UpdateTableValue(dt, "address", eventPrefix + "/StaticIncrementValue", "value", item.StaticIncrementValue.ToString()); i++; } } }
public void SaveConfiguration(DataTable dt) { // Save Descritpion DataTable_Functions.UpdateTableValue(dt, "address", dprefix + "Description", "value", DeviceDescription); // Save Type DataTable_Functions.UpdateTableValue(dt, "address", dprefix + "DeviceType", "value", DeviceType); // Save Manufacturer DataTable_Functions.UpdateTableValue(dt, "address", dprefix + "Manufacturer", "value", Manufacturer); // Save Id DataTable_Functions.UpdateTableValue(dt, "address", dprefix + "DeviceId", "value", DeviceId); // Save Model DataTable_Functions.UpdateTableValue(dt, "address", dprefix + "Model", "value", Model); // Save Serial DataTable_Functions.UpdateTableValue(dt, "address", dprefix + "Serial", "value", Serial); // Save Controller DataTable_Functions.UpdateTableValue(dt, "address", dprefix + "Controller", "value", Controller); // Save Location DataTable_Functions.UpdateTableValue(dt, "address", dprefix + "Location", "value", Location); // Save Device Logo DataTable_Functions.UpdateTableValue(dt, "address", dprefix + "LogoUrl", "value", manufacturerLogoFileName); // Save Device Image DataTable_Functions.UpdateTableValue(dt, "address", dprefix + "ImageUrl", "value", deviceImageFileName); }
public void SaveConfiguration(DataTable dt) { string prefix = "/GeneratedData/SnapShotData/"; // Clear all snapshot rows first (so that Ids can be sequentially assigned) DataTable_Functions.TrakHound.DeleteRows(prefix + "*", "address", dt); // Loop through SnapshotItems and add each item back to table with sequential id's foreach (var item in SnapshotItems) { if (item.ParentSnapshot != null) { var snapshot = item.ParentSnapshot; if (snapshot.Name != null && snapshot.Link != null) { string adr = "/GeneratedData/SnapShotData/" + String_Functions.UppercaseFirst(snapshot.Type.ToString().ToLower()); int id = DataTable_Functions.TrakHound.GetUnusedAddressId(adr, dt); adr = adr + "||" + id.ToString("00"); string attr = ""; attr += "id||" + id.ToString("00") + ";"; attr += "name||" + snapshot.Name + ";"; string link = snapshot.Link; attr += "link||" + link + ";"; DataTable_Functions.UpdateTableValue(dt, "address", adr, "attributes", attr); } } } }
void LoadAgentSettings(DataTable dt) { string prefix = "/Agent/"; string ip = DataTable_Functions.GetTableValue(dt, "address", prefix + "Address", "value"); string p = DataTable_Functions.GetTableValue(dt, "address", prefix + "Port", "value"); string devicename = DataTable_Functions.GetTableValue(dt, "address", prefix + "DeviceName", "value"); string proxyAddress = devicename = DataTable_Functions.GetTableValue(dt, "address", prefix + "ProxyAddress", "value"); string proxyPort = devicename = DataTable_Functions.GetTableValue(dt, "address", prefix + "ProxyPort", "value"); int port; int.TryParse(p, out port); // Proxy Settings MTConnect.HTTP.ProxySettings proxy = null; if (proxyPort != null) { int proxy_p = -1; if (int.TryParse(proxyPort, out proxy_p)) { proxy = new MTConnect.HTTP.ProxySettings(); proxy.Address = proxyAddress; proxy.Port = proxy_p; } } RunProbe(ip, proxy, port, devicename); }
void SaveCaptureItems(CaptureItem ci, Event e, DataTable dt) { string adr = "/GeneratedData/GeneratedEvents/Event||" + e.id.ToString("00") + "/Capture/Item"; int id = DataTable_Functions.TrakHound.GetUnusedAddressId(adr, dt); adr = adr + "||" + id.ToString("00"); ci.id = id; // Save Root string attr = ""; attr += "id||" + ci.id.ToString("00") + ";"; attr += "name||" + ci.name.Replace(' ', '_').ToLower() + ";"; string link = ci.link; List <CollectedItem> linkitems = CollectedItems.ToList(); CollectedItem dataitem = linkitems.Find(x => x.Display == link); if (dataitem != null) { link = dataitem.Id; } attr += "link||" + link + ";"; DataTable_Functions.UpdateTableValue(dt, "address", adr, "attributes", attr); }
public DateTime GetSegmentStartTime(DataTable segmentsTable) { // Get first segment in shift to test if in different day string format = "SHIFT_ID='{0}' AND SEGMENT_ID='{1}'"; string filter = string.Format(format, Shift, 0); string shiftStart = DataTable_Functions.GetTableValue(segmentsTable, filter, "START"); string test = FormattedDate + " " + shiftStart; DateTime startDate = DateTime.MinValue; DateTime.TryParse(test, out startDate); // Get segment start format = "SHIFT_ID='{0}' AND SEGMENT_ID='{1}'"; filter = string.Format(format, Shift, Segment); string start = DataTable_Functions.GetTableValue(segmentsTable, filter, "START"); test = FormattedDate + " " + start; DateTime date = DateTime.MinValue; DateTime.TryParse(test, out date); if (date < startDate) { date = date.AddDays(1); } return(date); }
public static Row FromDataRow(DataRow row) { var result = new Row(); result.Address = DataTable_Functions.GetRowValue("address", row); result.Value = DataTable_Functions.GetRowValue("value", row); result.Attributes = DataTable_Functions.GetRowValue("attributes", row); return(result); }
private void UpdateSnapshots(EventData data) { if (data.Id.ToLower() == "statusdata_snapshots") { if (data.Data02 != null) { DeviceStatus = DataTable_Functions.GetTableValue(data.Data02, "name", "Device Status", "value"); } } }
public void LoadConfiguration(DataTable dt) { Loading = true; configurationTable = dt; // Load Description DeviceDescription = DataTable_Functions.GetTableValue(dt, "address", dprefix + "Description", "value"); // Load Type DeviceType = DataTable_Functions.GetTableValue(dt, "address", dprefix + "DeviceType", "value"); if (DeviceId == null) { DeviceId = DataTable_Functions.GetTableValue(dt, "address", dprefix + "Device_Type", "value"); // Try deprecated value if not already found } // Load Manufacturer Manufacturer = DataTable_Functions.GetTableValue(dt, "address", dprefix + "Manufacturer", "value"); // Load Id DeviceId = DataTable_Functions.GetTableValue(dt, "address", dprefix + "DeviceId", "value"); if (DeviceId == null) { DeviceId = DataTable_Functions.GetTableValue(dt, "address", dprefix + "Device_ID", "value"); // Try deprecated value if not already found } // Load Model Model = DataTable_Functions.GetTableValue(dt, "address", dprefix + "Model", "value"); // Load Serial Serial = DataTable_Functions.GetTableValue(dt, "address", dprefix + "Serial", "value"); // Load Controller Controller = DataTable_Functions.GetTableValue(dt, "address", dprefix + "Controller", "value"); // Load Location Location = DataTable_Functions.GetTableValue(dt, "address", dprefix + "Location", "value"); // Load Manufacturer Logo manufacturerLogoFileName = DataTable_Functions.GetTableValue(dt, "address", dprefix + "LogoUrl", "value"); if (manufacturerLogoFileName == null) { manufacturerLogoFileName = DataTable_Functions.GetTableValue(dt, "address", dprefix + "Manufacturer_Logo_Path", "value"); // Try deprecated value if not already found } LoadManufacturerLogo(manufacturerLogoFileName); // Load Device Image deviceImageFileName = DataTable_Functions.GetTableValue(dt, "address", dprefix + "ImageUrl", "value"); if (deviceImageFileName == null) { deviceImageFileName = DataTable_Functions.GetTableValue(dt, "address", dprefix + "Image_Path", "value"); // Try deprecated value if not already found } LoadDeviceImage(deviceImageFileName); Loading = false; }
public void LoadConfiguration(DataTable dt) { Loading = true; configurationTable = dt; // Load IP Address Address = DataTable_Functions.GetTableValue(dt, "address", prefix + "Address", "value"); // Get deprecated value if new value is not found if (string.IsNullOrEmpty(Address)) { Address = DataTable_Functions.GetTableValue(dt, "address", prefix + "IP_Address", "value"); } // Load Port Port = DataTable_Functions.GetTableValue(dt, "address", prefix + "Port", "value"); // Load Device Name DeviceName = DataTable_Functions.GetTableValue(dt, "address", prefix + "DeviceName", "value"); // Get deprecated value if new value is not found if (string.IsNullOrEmpty(DeviceName)) { DeviceName = DataTable_Functions.GetTableValue(dt, "address", prefix + "Device_Name", "value"); } // Load Heartbeat int heartbeat; if (int.TryParse(DataTable_Functions.GetTableValue(dt, "address", prefix + "Heartbeat", "value"), out heartbeat)) { Heartbeat = heartbeat; } // Load Proxy Address ProxyAddress = DataTable_Functions.GetTableValue(dt, "address", prefix + "ProxyAddress", "value"); // Load Proxy Port ProxyPort = DataTable_Functions.GetTableValue(dt, "address", prefix + "ProxyPort", "value"); if (!string.IsNullOrEmpty(ProxyAddress) || !string.IsNullOrEmpty(ProxyPort)) { ProxySettings.IsExpanded = true; } else { ProxySettings.IsExpanded = false; } MTCDeviceList.Clear(); ConnectionTestResult = 0; ConnectionTestResultText = null; Loading = false; }
public static bool Update(UserConfiguration userConfig, DataTable table) { string uniqueId = DataTable_Functions.GetTableValue(table, "address", "/UniqueId", "value"); if (!string.IsNullOrEmpty(uniqueId)) { var deviceInfo = new DeviceInfo(uniqueId, table); return(Update(userConfig, deviceInfo)); } return(false); }
void SaveTrigger(Trigger t, Value v, Event e, DataTable dt, string addressPrefix) { if (t.link != null && t.modifier != null) { string adr = addressPrefix + "/Trigger"; int id = DataTable_Functions.TrakHound.GetUnusedAddressId(adr, dt); adr = adr + "||" + id.ToString("00"); t.id = id; // Save Root string attr = ""; attr += "id||" + t.id.ToString("00") + ";"; string link = t.link; List <CollectedItem> linkitems = CollectedItems.ToList(); CollectedItem dataitem = linkitems.Find(x => x.Display == link); if (dataitem != null) { link = dataitem.Id; } attr += "link||" + link + ";"; attr += "link_type||" + t.linkType + ";"; if (t.modifier != null) { switch (t.modifier) { case "Not Equal To": attr += "modifier||" + "not" + ";"; break; case "Greater Than": attr += "modifier||" + "greater_than" + ";"; break; case "Less Than": attr += "modifier||" + "less_than" + ";"; break; case "Contains": attr += "modifier||" + "contains" + ";"; break; case "Contains Match Case": attr += "modifier||" + "contains_match_case" + ";"; break; case "Contains Whole Word": attr += "modifier||" + "contains_whole_word" + ";"; break; case "Contains Whole Word Match Case": attr += "modifier||" + "contains_whole_word_match_case" + ";"; break; } } attr += "value||" + t.value + ";"; DataTable_Functions.UpdateTableValue(dt, "address", adr, "attributes", attr); } }
void SaveCycleNameLink(DataTable dt) { string val = null; if (SelectedCycleNameLink != null) { val = SelectedCycleNameLink.ToString(); } if (val != null) { DataTable_Functions.UpdateTableValue(dt, "address", prefix + "CycleNameLink", "value", val); } }
void SaveCycleEventName(DataTable dt) { string val = ""; if (SelectedCycleEventName != null) { val = SelectedCycleEventName.ToString(); } if (val != null) { DataTable_Functions.UpdateTableValue(dt, "address", prefix + "CycleEventName", "value", val.Replace(' ', '_').ToLower()); } }
void LoadStoppedEventValueName(DataTable dt) { string query = "Address = '" + prefix + "StoppedEventValue'"; var rows = dt.Select(query); if (rows != null) { foreach (var row in rows) { SelectedStoppedEventValue = DataTable_Functions.GetRowValue("Value", row); } } }
void SaveStoppedEventValueName(DataTable dt) { string val = ""; if (SelectedStoppedEventValue != null) { val = SelectedStoppedEventValue.ToString(); } if (val != null) { DataTable_Functions.UpdateTableValue(dt, "address", prefix + "StoppedEventValue", "value", val); } }
void ChangeSetting(string address, string name, string val) { string newVal = val; string oldVal = null; if (configurationTable != null) { oldVal = DataTable_Functions.GetTableValue(configurationTable, "address", address, "value"); } if (!loading) { SettingChanged?.Invoke(name, oldVal, newVal); } }
void LoadCycleNameLink(DataTable dt) { string query = "Address = '" + prefix + "CycleNameLink'"; var rows = dt.Select(query); if (rows != null) { foreach (var row in rows) { string val = DataTable_Functions.GetRowValue("Value", row); SelectedCycleNameLink = val; } } }
void SaveProductionTypes(DataTable dt) { foreach (var productionType in ProductionTypes) { var item = (Controls.ProductionTypeItem)productionType; int id = DataTable_Functions.TrakHound.GetUnusedAddressId(prefix + "ProductionTypes/Value", dt); string adr = prefix + "ProductionTypes/Value||" + id.ToString("00"); string attr = ""; attr += "id||" + id.ToString("00") + ";"; attr += "name||" + item.ValueName + ";"; attr += "type||" + item.productionType_COMBO.Text + ";"; DataTable_Functions.UpdateTableValue(dt, "address", adr, "attributes", attr); } }
private void UpdateVariables(EventData data) { if (data.Id.ToLower() == "statusdata_variables") { if (data.Data02 != null) { var currentTime = DataTable_Functions.GetTableValue(data.Data02, "variable", "shift_currenttime", "value"); if (currentTime != null) { DateTime time = DateTime.MinValue; if (DateTime.TryParse(currentTime, out time)) { CurrentTime = time; } } } } }
void SaveEvent(Event e, DataTable dt) { int id = DataTable_Functions.TrakHound.GetUnusedAddressId("/GeneratedData/GeneratedEvents/Event", dt); string adr = "/GeneratedData/GeneratedEvents/Event||" + id.ToString("00"); e.id = id; string attr = ""; attr += "id||" + e.id.ToString("00") + ";"; attr += "name||" + e.name.Replace(' ', '_').ToLower() + ";"; attr += "description||" + e.description + ";"; DataTable_Functions.UpdateTableValue(dt, "address", adr, "attributes", attr); int numval = e.values.Count; foreach (Value v in e.values) { if (v.result != null) { v.result.numval = numval; numval -= 1; } SaveValue(v, e, dt); } foreach (CaptureItem ci in e.captureItems) { SaveCaptureItems(ci, e, dt); } if (e.Default != null) { string addr = adr + "/Default"; attr = ""; attr += "numval||" + e.Default.numval.ToString() + ";"; string val = e.Default.value; DataTable_Functions.UpdateTableValue(dt, "address", addr, "attributes", attr); DataTable_Functions.UpdateTableValue(dt, "address", addr, "value", val); } }
public static HourRowInfo GetHourInfo(SQLiteConnection connection, DataRow row) { // Get Unique Id string uniqueId = DataTable_Functions.GetRowValue("unique_id", row); if (!string.IsNullOrEmpty(uniqueId)) { var result = new HourRowInfo(); result.UniqueId = uniqueId; var hourInfo = new Data.HourInfo(); hourInfo.Date = DataTable_Functions.GetRowValue("date", row); hourInfo.Hour = DataTable_Functions.GetIntegerFromRow("hour", row); hourInfo.PlannedProductionTime = DataTable_Functions.GetDoubleFromRow("planned_production_time", row); hourInfo.OperatingTime = DataTable_Functions.GetDoubleFromRow("operating_time", row); hourInfo.IdealOperatingTime = DataTable_Functions.GetDoubleFromRow("ideal_operating_time", row); hourInfo.TotalPieces = DataTable_Functions.GetIntegerFromRow("total_pieces", row); hourInfo.GoodPieces = DataTable_Functions.GetIntegerFromRow("good_pieces", row); hourInfo.Active = DataTable_Functions.GetDoubleFromRow("active", row); hourInfo.Idle = DataTable_Functions.GetDoubleFromRow("idle", row); hourInfo.Alert = DataTable_Functions.GetDoubleFromRow("alert", row); hourInfo.Production = DataTable_Functions.GetDoubleFromRow("production", row); hourInfo.Setup = DataTable_Functions.GetDoubleFromRow("setup", row); hourInfo.Teardown = DataTable_Functions.GetDoubleFromRow("teardown", row); hourInfo.Maintenance = DataTable_Functions.GetDoubleFromRow("maintenance", row); hourInfo.ProcessDevelopment = DataTable_Functions.GetDoubleFromRow("process_development", row); result.HourInfo = hourInfo; return(result); } return(null); }
void SaveMultiTrigger(MultiTrigger mt, Value v, Event e, DataTable dt) { string adr = "/GeneratedData/GeneratedEvents/Event||" + e.id.ToString("00"); adr += "/Value||" + v.id.ToString("00") + "/Triggers"; adr += "/MultiTrigger"; int id = DataTable_Functions.TrakHound.GetUnusedAddressId(adr, dt); adr = adr + "||" + id.ToString("00"); // Set Attributes string attr = ""; attr += "id||" + id.ToString("00") + ";"; DataTable_Functions.UpdateTableValue(dt, "address", adr, "attributes", attr); foreach (var trigger in mt.triggers) { SaveTrigger(trigger, v, e, dt, adr); } }
private void Save_Worker(object o) { bool success = false; var dt = (DataTable)o; if (dt != null) { // Reset Update ID DataTable_Functions.UpdateTableValue(dt, "address", "/UpdateId", "value", Guid.NewGuid().ToString()); if (userConfig != null) { success = Devices.Update(userConfig, dt); } // If not logged in Save to File in 'C:\TrakHound\' else { success = DeviceConfiguration.Save(dt); } if (success) { XmlDocument xml = DeviceConfiguration.TableToXml(dt); if (xml != null) { Dispatcher.BeginInvoke(new Action(() => { Configuration = DeviceConfiguration.Read(xml); ConfigurationTable = dt.Copy(); }), System.Windows.Threading.DispatcherPriority.Background, new object[] { }); } } } Dispatcher.BeginInvoke(new Action <bool>(Save_Finished), System.Windows.Threading.DispatcherPriority.Background, new object[] { success }); }
void SaveValue(Value v, Event e, DataTable dt) { int id = DataTable_Functions.TrakHound.GetUnusedAddressId("/GeneratedData/GeneratedEvents/Event||" + e.id.ToString("00") + "/Value", dt); string adr = "/GeneratedData/GeneratedEvents/Event||" + e.id.ToString("00") + "/Value||" + id.ToString("00"); v.id = id; // Save Root string attr = ""; attr += "id||" + v.id.ToString("00") + ";"; DataTable_Functions.UpdateTableValue(dt, "address", adr, "attributes", attr); // Save Triggers foreach (Trigger t in v.triggers.OfType <Trigger>()) { SaveTrigger(t, v, e, dt); } // Save MultiTriggers foreach (MultiTrigger mt in v.triggers.OfType <MultiTrigger>()) { SaveMultiTrigger(mt, v, e, dt); } // Save Result if (v.result != null) { string addr = adr + "/Result"; attr = ""; attr += "numval||" + v.result.numval.ToString() + ";"; string val = v.result.value; DataTable_Functions.UpdateTableValue(dt, "address", addr, "attributes", attr); DataTable_Functions.UpdateTableValue(dt, "address", addr, "value", val); } }
public void SaveConfiguration(DataTable dt) { // Remove old rows DataTable_Functions.TrakHound.DeleteRows(prefix + "*", "address", dt); // Save IP Address DataTable_Functions.UpdateTableValue(dt, "address", prefix + "Address", "value", Address); // Save Port DataTable_Functions.UpdateTableValue(dt, "address", prefix + "Port", "value", Port); // Save Device Name DataTable_Functions.UpdateTableValue(dt, "address", prefix + "DeviceName", "value", DeviceName); // Save Heartbeat DataTable_Functions.UpdateTableValue(dt, "address", prefix + "Heartbeat", "value", Heartbeat.ToString()); // Save Proxy Address DataTable_Functions.UpdateTableValue(dt, "address", prefix + "ProxyAddress", "value", ProxyAddress); // Save Proxy Port DataTable_Functions.UpdateTableValue(dt, "address", prefix + "ProxyPort", "value", ProxyPort); }
public static string GetTableAttributes(DataTable table, string address) { return(DataTable_Functions.GetTableValue(table, "address", address, "attributes")); }
public static string GetTableValue(DataTable table, string address) { return(DataTable_Functions.GetTableValue(table, "address", address, "value")); }
public static void EditTable(DataTable table, string address, object value, string attributes) { DataTable_Functions.UpdateTableValue(table, "address", address, "value", value == null ? string.Empty : value.ToString()); DataTable_Functions.UpdateTableValue(table, "address", address, "attributes", attributes); }