상속: MonoBehaviour
예제 #1
0
        public async Task UpdateStatus_ConnectedEquipment_UpdateSynchronizedObject()
        {
            // arrange
            var testMic     = new EquipmentDevice("mic1", "Microphone", DeviceType.Mic);
            var testDevices = new List <EquipmentDevice> {
                testMic
            };

            var(user, equipmentHub) = await ConnectEquipment(testDevices);

            var update = new Dictionary <ProducerSource, UseMediaStateInfo>
            {
                { ProducerSource.Mic, new UseMediaStateInfo(true, true, false, null) }
            };

            // act
            await equipmentHub.InvokeAsync(nameof(EquipmentHub.UpdateStatus), update);

            // assert
            await user.SyncObjects.AssertSyncObject <SynchronizedEquipment>(
                SynchronizedEquipment.SyncObjId(user.User.Sub), syncObj =>
            {
                var connection = Assert.Single(syncObj.Connections).Value;
                Assert.Equal(update, connection.Status);
            });
        }
예제 #2
0
        public async Task InitializeEquipment_MultipleDevicesSameId_UpdateSynchronizedObject()
        {
            // arrange
            var testMic     = new EquipmentDevice("mic1", "Microphone", DeviceType.Mic);
            var testMic2    = new EquipmentDevice("mic1", "Webcam", DeviceType.Webcam);
            var testDevices = new List <EquipmentDevice> {
                testMic, testMic2
            };

            var(user, _) = await ConnectEquipment(testDevices);

            // assert
            await user.SyncObjects.AssertSyncObject <SynchronizedEquipment>(
                SynchronizedEquipment.SyncObjId(user.User.Sub), syncEquipment =>
            {
                var connection = Assert.Single(syncEquipment.Connections);
                AssertHelper.AssertScrambledEquals(testDevices, connection.Value.Devices);
            });
        }
예제 #3
0
        public async Task InitializeEquipment_WithValidToken_UpdateSynchronizedObject()
        {
            // arrange
            var testMic     = new EquipmentDevice("mic1", "Microphone", DeviceType.Mic);
            var testDevices = new List <EquipmentDevice> {
                testMic
            };

            var(user, _) = await ConnectEquipment(testDevices);

            // assert
            await user.SyncObjects.AssertSyncObject <SynchronizedEquipment>(
                SynchronizedEquipment.SyncObjId(user.User.Sub), syncEquipment =>
            {
                var connection = Assert.Single(syncEquipment.Connections);
                Assert.Equal(EquipmentName, connection.Value.Name);
                Assert.Empty(connection.Value.Status);
                var actualDevice = Assert.Single(connection.Value.Devices);

                Assert.Equal(testMic, actualDevice);
            });
        }
예제 #4
0
    public void addDeviceAndMoleculesComponent(DisplayedDevice equipedDeviceScript)
    {
        if (equipedDeviceScript == null)
        {
            Logger.Log("GraphMoleculeList::addDeviceAndMoleculesComponent device == null", Logger.Level.WARN);
        }
        else
        {
            //equipedDevice is "EquipedDevicePrefabPos" object
            GameObject equipedDevice = equipedDeviceScript.gameObject;

            bool newEquiped = (!_equipedDevices.Exists(equiped => equiped.device == equipedDeviceScript._device));
            if (newEquiped)
            {
                //EquipedDisplayedDeviceWithMolecules
                GameObject prefab = Resources.Load(DisplayedDevice.equipedWithMoleculesPrefabURI) as GameObject;
                //deviceWithMoleculesComponent is "EquipedDisplayedDeviceWithMoleculesButtonPrefab" object
                //it needs an EquipmentDevice instance - it has only an EquipmentDeviceDummy object
                GameObject deviceWithMoleculesComponent = Instantiate(prefab, new Vector3(0.0f, 0.0f, 0.0f), Quaternion.identity) as GameObject;
                deviceWithMoleculesComponent.transform.parent     = transform;
                deviceWithMoleculesComponent.transform.localScale = new Vector3(1f, 1f, 0);

                EquipedDisplayedDeviceWithMolecules eddwm = deviceWithMoleculesComponent.GetComponent <EquipedDisplayedDeviceWithMolecules>();


                //equipmentDevice
                GameObject equipmentDevicePrefab    = Resources.Load(DisplayedDevice.equipmentPrefabURI) as GameObject;
                GameObject equipmentDeviceComponent = Instantiate(equipmentDevicePrefab, new Vector3(0.0f, 0.0f, 0.0f), Quaternion.identity) as GameObject;
                eddwm.equipmentDevice = equipmentDeviceComponent;
                EquipmentDevice equipmentD = equipmentDeviceComponent.GetComponent <EquipmentDevice>() as EquipmentDevice;
                eddwm.equipmentDeviceScript = equipmentD;

                //equipedDevice
                GameObject equipedDeviceComponent = Instantiate(equipedDevice) as GameObject;
                eddwm.equipedDevice = equipedDeviceComponent;
                EquipedDisplayedDevice edd = equipedDeviceComponent.GetComponent <EquipedDisplayedDevice>() as EquipedDisplayedDevice;
                eddwm.equipedDeviceScript = edd;
                eddwm.device = equipedDeviceScript._device;
                edd._device  = equipedDeviceScript._device;

                eddwm.initialize(equipmentDeviceDummy, equipedDeviceDummy);

                _equipedDevices.Add(eddwm);

                //search if there's already in the cell a molecule that this device produces
                foreach (DisplayedMolecule molecule in _displayedMolecules)
                {
                    if (molecule.getCodeName() == eddwm.device.getFirstGeneProteinName())
                    {
                        displayMoleculeInDevice(molecule, eddwm);
                    }
                }

                //depends on displayed list of molecules
                //Vector3 localPosition = getNewPosition(previousEquipedDevicesCount);
                //deviceWithMoleculesComponent.transform.localPosition = localPosition;
                positionDeviceAndMoleculeComponents();
            }
            else
            {
                Logger.Log("addDevice failed: newEquiped=" + newEquiped, Logger.Level.TRACE);
            }
        }
    }