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);
        }
        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);
        }
        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"));
        }
示例#4
0
 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;
        }
示例#6
0
        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;
        }
示例#7
0
        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);
        }
示例#8
0
        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);
            }
        }
示例#9
0
 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;
                 }
             }
         }
     }
 }
示例#10
0
 public static string GetTableAttributes(DataTable table, string address)
 {
     return(DataTable_Functions.GetTableValue(table, "address", address, "attributes"));
 }
示例#11
0
 public static string GetTableValue(DataTable table, string address)
 {
     return(DataTable_Functions.GetTableValue(table, "address", address, "value"));
 }
示例#12
0
 public string GetShiftName(DataTable segmentsTable)
 {
     return(DataTable_Functions.GetTableValue(segmentsTable, "SHIFT_ID", Shift.ToString(), "SHIFT"));
 }