aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/App.xaml
blob: cfd8febd4ee8eb73239686d4f64fd9fef89f1024 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
<Application x:Class="Tango.MachineStudio.Technician.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/Tango.MachineStudio.Common;component/Resources/MaterialDesign.xaml" />
                <ResourceDictionary Source="pack://application:,,,/Tango.MachineStudio.Common;component/Themes/LightThemeColors.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>
tor */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/*
 * FirmwareUpgrade.c
 *
 *  Created on: Dec 24, 2018
 *      Author: shlomo
 */

#include "include.h"
#include "Communication/CommunicationTask.h"
#include <DataDef.h>

#include  <Communication/PMR/FirmwareUpgrade/ActivateVersionRequest.pb-c.h>
#include  <Communication/PMR/FirmwareUpgrade/ActivateVersionResponse.pb-c.h>
#include  <Communication/PMR/FirmwareUpgrade/ActivateVersionRequest.pb-c.h>
#include  <Communication/PMR/FirmwareUpgrade/ActivateVersionResponse.pb-c.h>
#include  <Communication/PMR/FirmwareUpgrade/ValidateVersionRequest.pb-c.h>
#include  <Communication/PMR/FirmwareUpgrade/ValidateVersionResponse.pb-c.h>
#include  <Communication/PMR/FirmwareUpgrade/ValidateVersionRequest.pb-c.h>
#include  <Communication/PMR/FirmwareUpgrade/ValidateVersionResponse.pb-c.h>
#include  <Communication/PMR/FirmwareUpgrade/VersionFileDestination.pb-c.h>
#include  <Communication/PMR/FirmwareUpgrade/VersionFileDescriptor.pb-c.h>
#include  <Communication/PMR/FirmwareUpgrade/VersionPackageDescriptor.pb-c.h>

#include "drivers/FPGA/Full_Vme/FPGA_Programming_Up.h"
#include "Common/SWUpdate/FileSystem.h"

uint32_t    ActivateVersionRequestFunc(MessageContainer* requestContainer)
{
    void* buffer = NULL;
    uint32_t Bytes = 0;
    char SWUpgradePath[100];
    char FullPath[50];
    FRESULT Fresult = FR_OK;
    int File_i;
    bool Reboot = false;
    MessageContainer responseContainer;

    ActivateVersionRequest* request = activate_version_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data);

    ActivateVersionResponse response = ACTIVATE_VERSION_RESPONSE__INIT;
    VersionPackageDescriptor* VersionPackage;// = VERSION_PACKAGE_DESCRIPTOR__INIT;

    FPGA_ID FileDestinationToFPGAId[VERSION_FILE_DESTINATION__FPGA3+1] = {MAX_FPGA,FPGA1,FPGA2,FPGA3};


    strcpy (SWUpgradePath,request->path);
    strcat(SWUpgradePath,"/package.cfg");

    Fresult = FileRead(SWUpgradePath, &Bytes, &buffer);
    if (Fresult == FR_OK)
    {
        VersionPackage = version_package_descriptor__unpack(NULL,Bytes,buffer);
        for (File_i = 0;File_i<VersionPackage->n_filedescriptors;File_i++)
        {
            switch(VersionPackage->filedescriptors[File_i]->destination)
            {
            case   VERSION_FILE_DESTINATION__MCU:
                break;
            case VERSION_FILE_DESTINATION__FPGA1:
            case VERSION_FILE_DESTINATION__FPGA2:
            case VERSION_FILE_DESTINATION__FPGA3:
                //validate
                //update
                usnprintf(FullPath, 50,  "%s%s%s", request->path,"/", VersionPackage->filedescriptors[File_i]->filename);
                if (VersionPackage->filedescriptors[File_i]->destination == VERSION_FILE_DESTINATION__FPGA3)
                    Reboot = true;
                else
                    Reboot = false;
                Fresult = FPGA_Programming_Request( FileDestinationToFPGAId[VersionPackage->filedescriptors[File_i]->destination], FullPath, Reboot);
                break;
            case VERSION_FILE_DESTINATION__ConfigParams:
                    usnprintf(FullPath, 50,  "%s%s%s", request->path,"/", VersionPackage->filedescriptors[File_i]->filename);
                    Fresult = f_unlink("//SYSINFO//EMBPARAM.CFG");
                    Fresult |= f_rename (FullPath, "//SYSINFO//EMBPARAM.CFG");
                break;
            case     VERSION_FILE_DESTINATION__ProcessParams:
                    usnprintf(FullPath, 50,  "%s%s%s", request->path,"/", VersionPackage->filedescriptors[File_i]->filename);
                    Fresult = f_unlink("//SYSINFO//PROCESSP.CFG");
                    Fresult |= f_rename (FullPath, "//SYSINFO//PROCESSP.CFG");
                break;
            case     VERSION_FILE_DESTINATION__AlarmParams:
                    usnprintf(FullPath, 50,  "%s%s%s", request->path,"/", VersionPackage->filedescriptors[File_i]->filename);
                    Fresult = f_unlink("//SYSINFO//ALARMPRM.CFG");
                    Fresult |= f_rename (FullPath, "//SYSINFO//ALARMPRM.CFG");
                break;
            case     VERSION_FILE_DESTINATION__GeneralHWConfigParams:
                    usnprintf(FullPath, 50,  "%s%s%s", request->path,"/", VersionPackage->filedescriptors[File_i]->filename);
                    Fresult = f_unlink("//SYSINFO//GENHWCFG.CFG");
                    Fresult |= f_rename (FullPath, "//SYSINFO//GENHWCFG.CFG");
                break;
            default:
                LOG_ERROR (VersionPackage->filedescriptors[File_i]->destination,"wrong file update Destination");
                Fresult = FR_INVALID_NAME;
                break;
            }
        }
    }
    responseContainer = createContainer(MESSAGE_TYPE__ActivateVersionResponse,  requestContainer->token, false, &response, &activate_version_response__pack, &activate_version_response__get_packed_size);
    if (Fresult!= OK)
    {
        responseContainer.error = FileError_to_ErrorCode[Fresult];
        responseContainer.errormessage = "Activate Version Request error";
    }
    responseContainer.continuous = false;
    uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer));
    size_t container_size = message_container__pack(&responseContainer, container_buffer);
    my_free(responseContainer.data.data);
    activate_version_request__free_unpacked(request,NULL);
    SendChars(container_buffer, container_size);

    return OK;
}

uint32_t    ValidateVersionRequestFunc(MessageContainer* requestContainer)
{
    uint32_t status = OK;

    MessageContainer responseContainer;

    ValidateVersionRequest* request = validate_version_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data);

    ValidateVersionResponse response = VALIDATE_VERSION_RESPONSE__INIT;


    responseContainer = createContainer(MESSAGE_TYPE__ValidateVersionResponse,  requestContainer->token, false, &response, &validate_version_response__pack, &validate_version_response__get_packed_size);
    if (status!= OK)
    {
        responseContainer.error = ERROR_CODE__INVALID_UPLOAD_ID;
        responseContainer.errormessage = "Validate Version Request error";
    }
    responseContainer.continuous = false;
    uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer));
    size_t container_size = message_container__pack(&responseContainer, container_buffer);
    my_free(responseContainer.data.data);
    validate_version_request__free_unpacked(request,NULL);
    SendChars(container_buffer, container_size);

    return OK;
}