コード例 #1
0
        public async Task <List <DeviceExtended> > GetAllUnAssignedDevice(int instituteId)
        {
            var dt = new List <DeviceExtended>();
            await _connection.OpenAsync();

            try
            {
                using (MySqlCommand cmd = new MySqlCommand("Get_AllUnAssignedDevice", _connection))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("instituteIdVal", instituteId);
                    var dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        var row = new DeviceExtended();
                        row.Id           = Convert.ToInt32(dr["Id"]);
                        row.Model        = dr["Model"].ToString();
                        row.Description  = dr["description"].ToString();
                        row.SerialNumber = dr["SerialNumber"].ToString();
                        row.Version      = dr["Version"].ToString();
                        dt.Add(row);
                    }
                }
                return(dt);
            }
            catch
            {
                throw;
            }
            finally
            {
                await _connection.CloseAsync();
            }
        }
コード例 #2
0
        //Download To Device
        private bool DownloadToDevice(DeviceExtended deviceextended, string selectedPcInterface)
        {
            DeviceSinamicsG sinamicsG = new DeviceSinamicsG(deviceextended);

            DownloadProvider downloadProvider  = deviceextended.device.DeviceItems[1].GetService <DownloadProvider>(); //TODO check
            DownloadConfigurationDelegate pre  = PreDownload;
            DownloadConfigurationDelegate post = PostDownload;

            ConnectionConfiguration  connConfiguration = downloadProvider.Configuration;
            ConfigurationMode        configurationMode = connConfiguration.Modes.Find("PN/IE");
            ConfigurationPcInterface pcInterface       = configurationMode.PcInterfaces.Find(selectedPcInterface, 1);
            ConfigurationSubnet      subnet            = pcInterface.Subnets.Find(sinamicsG.subnet.Name);
            IConfiguration           configuration     = subnet.Addresses.Find(sinamicsG.ipAddress);

            try
            {
                downloadProvider.Download(configuration, pre, post, DownloadOptions.Software);
            }
            catch (Exception ex)
            {
                return(false);
            }

            return(true);
        }
コード例 #3
0
        public DeviceSinamicsG(DeviceExtended deviceextended)
        {
            this.deviceUserGroup = deviceextended.usergroup;

            this.device           = deviceextended.device;
            driveObject           = device.DeviceItems[1].GetService <DriveObjectContainer>().DriveObjects[0];
            safetyTelegram        = driveObject.Telegrams.Find(TelegramType.SafetyTelegram);
            mainTelegram          = driveObject.Telegrams.Find(TelegramType.MainTelegram);
            additionalTelegram    = driveObject.Telegrams.Find(TelegramType.AdditionalTelegram);
            supplementaryTelegram = driveObject.Telegrams.Find(TelegramType.SupplementaryTelegram);
            profinetInterface     = getProfinetInetface();
            ioConnector           = profinetInterface.IoConnectors[0];
            node               = profinetInterface.Nodes[0];
            Name               = device.DeviceItems[1].Name;
            PowerModule        = device.DeviceItems[2].TypeIdentifier;
            safetyAddress      = GetSafetyAddress();
            safetHwAddress_in  = getSafetyHwAddressIn();
            safetHwAddress_out = getSafetyHwAddressOut();
            hwAddress_in       = getHwAddressIn();
            hwAddress_out      = getHwAddressOut();
            hwAddress_supp_in  = getHwAddressSuppIn();
            hwAddress_supp_out = getHwAddressSuppOut();
            hwAddress_add_in   = getHwAddressAddIn();
            hwAddress_add_out  = getHwAddressAddOut();
            ioSystem           = ioConnector.ConnectedToIoSystem;
            subnet             = node.ConnectedSubnet;
            ipAddress          = node.GetAttribute("Address").ToString();
            pnDeviceNameAuto   = node.GetAttribute("PnDeviceNameAutoGeneration").ToString();
            pnDeviceName       = node.GetAttribute("PnDeviceName").ToString();
            PnDeviceNumber     = (int)ioConnector.GetAttribute("PnDeviceNumber");
            networkPorts       = GetNetworkPorts();
        }
コード例 #4
0
        private bool SamePowermodule(string selectedDriveName, string treeView)
        {
            DeviceExtended selectedDevice = myOpenness.lsDeviceExtendeds.Find(d => d.driveName == selectedDriveName);
            DeviceExtended evalDevice     = myOpenness.lsDeviceExtendeds.Find(d => d.driveName == treeView);

            return(selectedDevice.powerModule == evalDevice.powerModule);
        }
コード例 #5
0
        public async Task <List <DeviceExtended> > GetAllDetailDeviceByInstitute(int instituteId)
        {
            var dt = new List <DeviceExtended>();
            await _connection.OpenAsync();

            try
            {
                using (MySqlCommand cmd = new MySqlCommand("Get_AllDeviceByInstitute", _connection))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("InstituteIdVal", instituteId);
                    var dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        var row = new DeviceExtended();
                        row.Id           = Convert.ToInt32(dr["deviceId"]);
                        row.Model        = dr["Model"].ToString();
                        row.Description  = dr["Description"].ToString();
                        row.SerialNumber = dr["SerialNumber"].ToString();
                        row.Version      = dr["Version"].ToString();
                        if (int.TryParse(dr["userId"].ToString(), out int userId))
                        {
                            row.UserId = userId;
                        }
                        row.UserName = dr["Username"].ToString();
                        if (int.TryParse(dr["InstituteId"].ToString(), out int InstituteId))
                        {
                            row.InstituteId = InstituteId;
                        }
                        row.InstituteName = dr["InstituteName"].ToString();
                        row.UserFullName  = dr["UserFullName"].ToString();
                        if (int.TryParse(dr["UserTypeId"].ToString(), out int UserTypeId))
                        {
                            row.UserTypeId = UserTypeId;
                        }
                        row.UserType = dr["UserType"].ToString();
                        dt.Add(row);
                    }
                }

                return(dt);
            }
            catch
            {
                throw;
            }
            finally
            {
                await _connection.CloseAsync();
            }
        }