Exemple #1
0
        /// <summary>
        /// update the client infos
        /// </summary>
        /// <param name="pCco">the CCO</param>
        /// <param name="recievedFromClient">bool if request recieved from client or not</param>
        public void updateClient(ClientConfigObject pCco, bool recievedFromClient)
        {
            DataTable currentDataTable = getClientDataTable();

            DataColumn[] primaryKeyArray = new DataColumn[1];
            primaryKeyArray[0]          = currentDataTable.Columns["ClientId"];
            currentDataTable.PrimaryKey = primaryKeyArray;

            try
            {
                DataRow row = currentDataTable.Rows.Find(pCco.ID);
                row[0] = pCco.ID;
                row[1] = pCco.name;
                row[2] = pCco.ownIP;

                //write object
                BinaryFormatter formatter = new BinaryFormatter();
                MemoryStream    wrStream  = new MemoryStream();
                formatter.Serialize(wrStream, pCco);
                byte[] serInput = wrStream.ToArray();

                row[3] = (Object)serInput;
            }
            catch (Exception ex)
            {
                Log.LogManager.writeLog("[DataManager:DBManager] Update of Client " + pCco.name + " in database not possible. Reason: " + ex.Message);
            }
            updateKinectObjectInDB(currentDataTable);
            if (!recievedFromClient)
            {
                OnClientUpdatedEvent.BeginInvoke(pCco, null, null);
            }
        }
        /// <summary>
        /// constructor, loads the current config file
        /// </summary>
        public ConfigManager()
        {
            try
            {
                if (checkForConfigFile(configFilePath + configFileName))
                {
                    _ClientConfigObject = loadConfigFromFile(configFilePath + configFileName);
                    LogManager.writeLog("[ConfigManager] Config loaded from file");
                }
                else
                {
                    _ClientConfigObject = ClientConfigObject.createDefaultConfig();
                    //_ClientConfigObject.clientConnectionConfig.targetIP = "localhost:8999"; //ToDo: GATEWAY
                    LogManager.writeLog("[ConfigManager] Default config loaded");
                }
            }
            catch (Exception e)
            {
                LogManager.writeLog("[ConfigManager] " + e.ToString());
                _ClientConfigObject = ClientConfigObject.createDefaultConfig();
                //_ClientConfigObject.clientConnectionConfig.targetIP = "localhost:8999";
            }

            saveConfig();
            LogManager.writeLog("[ConfigManager] Successfully initialized");
        }
        /// <summary>
        /// task function to do the request
        /// </summary>
        /// <param name="URL">target</param>
        /// <param name="input">object to send to</param>
        /// <param name="pCco">identification object</param>
        /// <param name="pTimeout"timeout duration></param>
        /// <returns></returns>
        private responseStruct sendRequestThread(String URL, Object input, ClientConfigObject pCco, int pTimeout)
        {
            if (URL != null)
            {
                try
                {
                    // get the request stream
                    WebRequest request = WebRequest.Create(URL);
                    request.Method  = "POST";
                    request.Timeout = pTimeout;
                    Stream requestStream = request.GetRequestStream();

                    BinaryFormatter formatter = new BinaryFormatter();
                    formatter.Serialize(requestStream, input);
                    requestStream.Close();

                    // response to the request
                    WebResponse  response = request.GetResponse();
                    StreamReader reader   = new StreamReader(response.GetResponseStream());

                    responseStruct re = new responseStruct();
                    re.responseString = reader.ReadToEnd();
                    re.targetclient   = pCco;
                    return(re);
                }
                catch (Exception) { throw; }
            }

            responseStruct rel = new responseStruct();

            rel.responseString = "REQUEST NOT RECIEVED ERROR";
            rel.targetclient   = pCco;
            return(rel);
        }
        /// <summary>
        /// recieve a HelloRequest from the client
        /// </summary>
        /// <param name="pHro">the HRO</param>
        public void recieveHelloRequest(HelloRequestObject pHro)
        {
            Log.LogManager.writeLogDebug("[RegistrationService:RegistrationService] Hello request recieved from " + pHro.Name + " with the ID " + pHro.ID);
            ClientConfigObject cco = _DBManager.recieveHelloRequest(pHro);

            Log.LogManager.writeLogDebug("[RegistrationService:RegistrationService] Hello: CCO generated, isConnected: " + cco.clientRequestObject.isConnected);
            OnConfigRequestSendingEvent(cco);
        }
 /// <summary>
 /// removes a client from the database
 /// </summary>
 /// <param name="pCco">the CCO</param>
 public void removeClientFromList(ClientConfigObject pCco)
 {
     if (pCco.clientRequestObject.isConnected)
     {
         Log.LogManager.writeLog("[Registrationservice:RegistrationService] Client " + pCco.name + " disconnected.");
         pCco.clientRequestObject.isConnected = false;
         _DBManager.updateClient(pCco, false);
     }
 }
        /// <summary>
        /// starts a config request to change the configuration on the server
        /// </summary>
        /// <param name="clientConfigObject">the config object that is supposed to be written on the server</param>
        public void startConfigRequest(String pTargetIP, ClientConfigObject clientConfigObject)
        {
            //send data
            Task <String> t = new Task <String>(() => sendRequestThread(@"http://" + pTargetIP + @"/CONFIG", clientConfigObject, 10000));

            t.ContinueWith(TaskFaultedHandler, TaskContinuationOptions.OnlyOnFaulted);
            t.ContinueWith(ConfigRequestSuccessfulHandler, TaskContinuationOptions.OnlyOnRanToCompletion);
            t.Start();
        }
Exemple #7
0
 /// <summary>
 /// the regservice for the ping request event
 /// </summary>
 /// <param name="targetClient">the CCO</param>
 void _RegService_OnPingRequestSendingEvent(ClientConfigObject targetClient)
 {
     try {
         _WebserviceSender.sendPing(targetClient);
     }
     catch (Exception) {
         _RegService.removeClientFromList(targetClient);
     }
 }
Exemple #8
0
        /// <summary>
        /// updates the kinect status if the kinect is selected or deselected as master kinect
        /// </summary>
        /// <param name="pID"></param>
        /// <param name="master"></param>
        public void masterKinect(ClientConfigObject pCco, bool master)
        {
            pCco.clientKinectConfig.isMaster = master;
            if (pCco.clientKinectConfig.isMaster)
            {
                Log.LogManager.writeLog("[DataManager:DataManager] Client " + pCco.name + " is now the master Kinect.");
            }

            _DBManager.updateClient(pCco, true);
        }
        /// <summary>
        /// loads a config object from the configfile
        /// </summary>
        /// <param name="inputPath">config file path</param>
        /// <returns>config object</returns>
        static ClientConfigObject loadConfigFromFile(String inputPath)
        {
            FileStream         stream        = new FileStream(inputPath, FileMode.Open);
            BinaryFormatter    formatter     = new BinaryFormatter();
            ClientConfigObject _returnObject = (ClientConfigObject)formatter.Deserialize(stream);

            stream.Close();

            _returnObject.ownIP = getOwnIP();
            return(_returnObject);
        }
        /// <summary>
        /// sends the shutdown command to a client
        /// </summary>
        /// <param name="pCco">the client config object</param>
        public void sendShutdown(ClientConfigObject pCco)
        {
            Task <responseStruct> t = new Task <responseStruct>(() => sendRequestThread(
                                                                    @"http://" + pCco.ownIP + ":" + pCco.clientConnectionConfig.listeningPort + @"/SHUTDOWN",
                                                                    String.Empty,
                                                                    pCco, 10000));

            // if the task fails
            t.ContinueWith(TaskFaultedHandler, TaskContinuationOptions.OnlyOnFaulted);
            t.Start();
        }
        /// <summary>
        /// gets fired when the server recieves a config request from the client
        /// </summary>
        /// <param name="message">the stream</param>
        /// <returns>a status message</returns>
        public String responseConfig(Stream message)
        {
            // deserialize
            BinaryFormatter    formatter = new BinaryFormatter();
            ClientConfigObject cco       = (ClientConfigObject)formatter.Deserialize(message);

            // fire the event
            OnConfigRequestEvent.BeginInvoke(cco, null, null);

            // feedback for the client
            return("CONFIG RECIEVED");
        }
        /// <summary>
        /// sends a new config to a client
        /// </summary>
        /// <param name="pCco">the config object</param>
        public void sendConfig(ClientConfigObject pCco)
        {
            // send the CCO
            Task <responseStruct> t = new Task <responseStruct>(() => sendRequestThread(
                                                                    @"http://" + pCco.ownIP + ":" + pCco.clientConnectionConfig.listeningPort + @"/CONFIG",
                                                                    pCco,
                                                                    pCco, 10000));

            // if the task fails
            t.ContinueWith(TaskFaultedHandler, TaskContinuationOptions.OnlyOnFaulted);
            t.Start();
        }
        /// <summary>
        /// saves the config to a file
        /// </summary>
        /// <param name="inputObject">the config object to save</param>
        /// <param name="configFilePath">the filepath</param>
        /// <param name="configFileName">the filename</param>
        static void saveConfigToFile(ClientConfigObject inputObject, String configFilePath, String configFileName)
        {
            BinaryFormatter formatter = new BinaryFormatter();

            if (!checkForConfigFile(configFilePath + configFileName))
            {
                Directory.CreateDirectory(configFilePath);
            }
            FileStream stream = new FileStream(configFilePath + configFileName, FileMode.Create);

            formatter.Serialize(stream, inputObject);
            stream.Flush();
            stream.Close();
        }
 /// <summary>
 /// load a default config for the client
 /// </summary>
 /// <returns>a default config object</returns>
 public static ServerConfigObject GetDefaultConfig()
 {
     return(new ServerConfigObject()
     {
         ownIP = ClientConfigObject.getOwnIP(),
         gatewayAddress = String.Empty,
         signalrAddress = String.Empty,
         keepAliveInterval = 5000,
         listeningPort = 8999,
         debug = true,
         serverAlgorithmConfig = new ServerAlgorithmConfigObject()
         {
             downsamplingFactor = 0.005f,
             amountOfFrames = 10,
             ICP_perform = false,
             ICP_indis = -1,
             euclidean_ExtractionRadius = 0.1f,
             euclidean_MinimumVolume = 1,
             planar_Iterations = 10000,
             planar_ThresholdDistance = 0.05f,
             useAlgorithm = Algorithms.ConvexConcavEnsembled,
             calibratedPlanes = new List <DataIntegration.PlaneModel>(),
             calibratedObjects = new List <DataIntegration.PointCloud>(),
             planar_planeComparisonVarianceThreshold = 0.1f,
             concav_angleThreshold = 90,
             correctionValue = 0
         },
         serverKinectFusionConfig = new ServerKinectFusionConfigObject()
         {
             ProcessorType = Microsoft.Kinect.Fusion.ReconstructionProcessor.Cpu,
             DeviceToUse = -1,
             AutoResetReconstructionWhenLost = true,
             MaxTrackingErrors = 100,
             depthHeight = 424,
             depthWidth = 512,
             minDepthClip = FusionDepthProcessor.DefaultMinimumDepth,
             maxDepthClip = FusionDepthProcessor.DefaultMaximumDepth,
             translateResetPoseByMinDepthThreshold = true,
             VoxelsPerMeter = 32,
             VoxelResolutionX = 256,
             VoxelResolutionY = 256,
             VoxelResolutionZ = 256,
             integrationWeight = FusionDepthProcessor.DefaultIntegrationWeight,
             iterationCount = FusionDepthProcessor.DefaultAlignIterationCount
         }, calibratedContainers = new List <ContainerConfigObject>()
     });
 }
Exemple #15
0
        /// <summary>
        /// mute the selected client
        /// </summary>
        /// <param name="pID">the ID of the client</param>
        /// <param name="mute">the new mute status</param>
        public void muteClient(int pID, bool mute)
        {
            ClientConfigObject cco = _DBManager.getCcoByID(pID);

            cco.clientRequestObject.isMuted = mute;

            if (cco.clientRequestObject.isMuted)
            {
                Log.LogManager.writeLog("[DataManager:DataManager] Client " + cco.name + " has been muted.");
            }
            else
            {
                Log.LogManager.writeLog("[DataManager:DataManager] Client " + cco.name + " has been unmuted.");
            }

            _DBManager.updateClient(cco, true);
        }
Exemple #16
0
        private void _ButtonSettings_Click(object sender, RoutedEventArgs e)
        {
            //fetch CCO data
            ConnectionStatusListviewItem obj = ((FrameworkElement)sender).DataContext as ConnectionStatusListviewItem;
            List <ClientConfigObject>    connectedClients = _DataManager.getCurrentKinectClients();

            ClientConfigObject clientConfig = connectedClients.Find(t => t.ID == obj.ID);

            //create settings window
            if (lastActiveSettingsWindow == null || !lastActiveSettingsWindow.IsLoaded)
            {
                lastActiveSettingsWindow = new ClientSettingsWindow(clientConfig);
                lastActiveSettingsWindow.OnConfigChangeEvent += lastActiveSettingsWindow_OnConfigChangeEvent;
            }
            UpdateClientConnectionSatus();
            lastActiveSettingsWindow.Show();
        }
Exemple #17
0
        /// <summary>
        /// shutdown selected client
        /// </summary>
        /// <param name="pID">the ID of the client</param>
        public void shutdownClient(int pID)
        {
            ClientConfigObject cco = _DBManager.getCcoByID(pID);

            if (cco.clientRequestObject.isConnected == true)
            {
                cco.clientRequestObject.isConnected = false;
                Log.LogManager.writeLog("[DataManager:DataManager] Client " + cco.name + " has been shutdown.");
            }
            else
            {
                cco.clientRequestObject.isConnected = true;
                Log.LogManager.writeLog("[DataManager:DataManager] Attempting to start Client " + cco.name + ".");
            }

            _Webservice.sendShutdownToClient(cco);
            _DBManager.updateClient(cco, false);
        }
Exemple #18
0
        /// <summary>
        /// the selection if the kinect is the master kinect for the alignment of the pictures
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _CheckboxMaster_Checked(object sender, RoutedEventArgs e)
        {
            ConnectionStatusListviewItem obj = ((FrameworkElement)sender).DataContext as ConnectionStatusListviewItem;
            List <ClientConfigObject>    connectedClients = _DataManager.getCurrentKinectClients();

            ClientConfigObject clientConfig = connectedClients.Find(t => t.ID == obj.ID);

            // resets all other kinects
            foreach (ClientConfigObject cco in connectedClients)
            {
                if (cco.ID == clientConfig.ID)
                {
                    _DataManager.masterKinect(cco, true);
                    masterSet = true;
                }
                else
                {
                    _DataManager.masterKinect(cco, false);
                }
            }
            UpdateClientConnectionSatus();
        }
Exemple #19
0
        /// <summary>
        /// get the client list from the database
        /// </summary>
        /// <returns>a list with all CCOs</returns>
        public List <ClientConfigObject> recieveClientList()
        {
            DataTable currentDataTable = getClientDataTable();

            DataColumn[] primaryKeyArray = new DataColumn[1];
            primaryKeyArray[0]          = currentDataTable.Columns["ClientId"];
            currentDataTable.PrimaryKey = primaryKeyArray;

            List <ClientConfigObject> retList = new List <ClientConfigObject>();

            foreach (DataRow r in currentDataTable.Rows)
            {
                //get object from DB
                MemoryStream       memStream = new MemoryStream((byte[])r[3]);
                BinaryFormatter    formatter = new BinaryFormatter();
                ClientConfigObject cco       = (ClientConfigObject)formatter.Deserialize(memStream);
                memStream.Close();

                retList.Add(cco);
            }
            return(retList);
        }
Exemple #20
0
        /// <summary>
        /// returns a CCO based on the ID
        /// </summary>
        /// <param name="pID">the client ID</param>
        /// <returns>the CCO</returns>
        public ClientConfigObject getCcoByID(int pID)
        {
            DataTable currentDataTable = getClientDataTable();

            DataColumn[] primaryKeyArray = new DataColumn[1];
            primaryKeyArray[0]          = currentDataTable.Columns["ClientId"];
            currentDataTable.PrimaryKey = primaryKeyArray;

            try
            {
                //get object from DB
                MemoryStream       memStream = new MemoryStream((byte[])currentDataTable.Rows.Find(pID)[3]);
                BinaryFormatter    formatter = new BinaryFormatter();
                ClientConfigObject cco       = (ClientConfigObject)formatter.Deserialize(memStream);
                memStream.Close();
                return(cco);
            }
            catch (Exception ex)
            {
                Log.LogManager.writeLog("[DataManager:DBManager] " + ex.Message);
            }

            return(null);
        }
 /// <summary>
 /// constructor of the window
 /// </summary>
 /// <param name="pCco">the config to be changed</param>
 public ClientSettingsWindow(ClientConfigObject pCco)
 {
     InitializeComponent();
     currentConfig = pCco;
     loadConfigData();
 }
Exemple #22
0
 /// <summary>
 /// updates a CCO object in the data base
 /// </summary>
 /// <param name="config">the CCO</param>
 private void lastActiveSettingsWindow_OnConfigChangeEvent(ClientConfigObject config)
 {
     _DataManager.UpdateClient(config);
 }
Exemple #23
0
 /// <summary>
 /// the shutdown call for the client
 /// </summary>
 /// <param name="pCco">the CCO</param>
 public void sendShutdownToClient(ClientConfigObject pCco)
 {
     _WebserviceSender.sendShutdown(pCco);
 }
Exemple #24
0
 /// <summary>
 /// the transport of the config to the client
 /// </summary>
 /// <param name="pCco">the CCO</param>
 public void sendConfigToClient(ClientConfigObject pCco)
 {
     _WebserviceSender.sendConfig(pCco);
 }
 /// <summary>
 /// new config recieved from client
 /// </summary>
 /// <param name="pCco">the CCO</param>
 public void receiveConfigObject(ClientConfigObject pCco)
 {
     Log.LogManager.writeLog("[RegistrationService:RegistrationService] New configuration recieved from " + pCco.name);
     _DBManager.updateClient(pCco, true);
 }
 /// <summary>
 /// give the DBManager the ConfigRequestSend event
 /// </summary>
 /// <param name="pCco">the CCO</param>
 void _DBManager_OnClientUpdatedEvent(ClientConfigObject pCco)
 {
     OnConfigRequestSendingEvent(pCco);
 }
Exemple #27
0
 /// <summary>
 /// the scan request for the clients
 /// </summary>
 /// <param name="pCco">the CCO</param>
 public void sendScanRequestToClient(ClientConfigObject pCco)
 {
     _WebserviceSender.sendScanRequest(pCco);
 }
 /// <summary>
 /// updates the current config and saves it to a file
 /// </summary>
 /// <param name="inputConfig">the config object recieved from the server</param>
 public void writeConfig(ClientConfigObject inputConfig)
 {
     _ClientConfigObject = inputConfig;
     saveConfig();
 }
Exemple #29
0
 /// <summary>
 /// the webservice contract for the config objects
 /// </summary>
 /// <param name="EventArgs">the CCO</param>
 void ServerWebserviceContract_OnConfigRequestEvent(ClientConfigObject EventArgs)
 {
     _RegService.receiveConfigObject(EventArgs);
 }
Exemple #30
0
 /// <summary>
 /// creates a new data package to be filled with data
 /// </summary>
 /// <param name="pCco">the ClientConfigObject with the configuration data</param>
 internal void initializeDataPackage(ClientConfigObject pCco)
 {
     currentPackage = new KinectDataPackage(pCco);
     dataSent       = false;
     acceptsData    = true;
 }