Beispiel #1
0
 public DeviceManager()
 {
     volumeController = new VolumeDevice();
     channelController = new ChannelDevice();
     channel_devices = new List<ChannelDevice>();
     volume_devices = new List<VolumeDevice>();
 }
Beispiel #2
0
        //Initialize "devices" list and Channel and volumeDevices
        public async Task initialize(StorageFolder devices_folder_)
        {
            is_initialized = true;
            // Device Manager Metadata Initialization 
            devices_folder = devices_folder_;
            devices_info_file = (StorageFile) await devices_folder.TryGetItemAsync("devices_info.txt");
            if(devices_info_file == null)
            {
                System.Diagnostics.Debug.WriteLine("No Devices info file!");
                return;
            }
            IList<string> input = await FileIO.ReadLinesAsync(devices_info_file);
            int num_channel_devices = Convert.ToInt32(input[0]);
            int cur_index = 1;
            String device_name;
            StorageFile cur_device_input_file;

            // Channel Device Initialization

            for(int i = 0; i < num_channel_devices; ++i)
            {
                device_name = input[cur_index++];
                try
                {
                    cur_device_input_file = (StorageFile)await get_input_file_from_name(device_name, 'c');
                    ChannelDevice c_device = new ChannelDevice(device_name, cur_device_input_file);
                    channel_devices.Add(c_device);
                }
                catch(Exception except)
                {
                    System.Diagnostics.Debug.WriteLine(except.Message);
                }
            }
            // Get Current Channel Device
            int chan_index = 0;
            bool found = false;
            string cur_chan_device_name = input[cur_index++];
            foreach(ChannelDevice cur in channel_devices)
            {
                if(cur.get_name().Equals(cur_chan_device_name))
                {
                    found = true;
                    break;
                }
                chan_index++;
            }
            if (!found)
            {
                // Throw Exception about channel device not found
            }
            else
            {
                channelController = channel_devices[chan_index];
                await channelController.initialize();
            }

            // Volume Device Initialization

            int num_vol_devices = Convert.ToInt32(input[cur_index++]);
            for(int i = 0; i < num_vol_devices; ++i)
            {
                device_name = input[cur_index++];
                cur_device_input_file = await get_input_file_from_name(device_name, 'v');
                VolumeDevice v_device = new VolumeDevice(device_name, cur_device_input_file);
                volume_devices.Add(v_device);
            }
            int vol_index = 0;
            string cur_vol_device_name = input[cur_index++];
            found = false;
            foreach(VolumeDevice cur_v in volume_devices)
            {
                if(cur_v.get_name().Equals(cur_vol_device_name))
                {
                    found = true;
                    break;
                }
                vol_index++;
            }
            if(!found)
            {
                // TODO: Throw Error
            }
            else
            {
                volumeController = volume_devices[vol_index];
                await volumeController.initialize();
            }
      
        }
Beispiel #3
0
 public async void addVolumeDevice(string name, List<string> IR_info)
 {
     string i_file_name = get_input_file_name(name, 'v');
     StorageFile vol_file = await devices_folder.CreateFileAsync(i_file_name, CreationCollisionOption.ReplaceExisting);
     VolumeDevice vol_dev = new VolumeDevice(name, vol_file, IR_info);
     volume_devices.Add(vol_dev);
     vol_dev.saveDevice();
     volumeController = vol_dev;
     volumeController.createButtons();
     saveDeviceList();
 }