Esempio n. 1
0
        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);
        }
Esempio n. 3
0
        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"));
        }
Esempio n. 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");
         }
     }
 }
Esempio n. 5
0
        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;
        }
Esempio n. 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;
        }
Esempio n. 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);
        }
Esempio n. 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);
            }
        }
Esempio n. 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;
                 }
             }
         }
     }
 }
Esempio n. 10
0
 public static string GetTableAttributes(DataTable table, string address)
 {
     return(DataTable_Functions.GetTableValue(table, "address", address, "attributes"));
 }
Esempio n. 11
0
 public static string GetTableValue(DataTable table, string address)
 {
     return(DataTable_Functions.GetTableValue(table, "address", address, "value"));
 }
Esempio n. 12
0
 public string GetShiftName(DataTable segmentsTable)
 {
     return(DataTable_Functions.GetTableValue(segmentsTable, "SHIFT_ID", Shift.ToString(), "SHIFT"));
 }