aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Utilities/Tango.ILMerge.UI/MainWindow.xaml
blob: bab1a18eef9de965d0a4669f51f7e61b92fa76a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<Window x:Class="Tango.ILMerge.UI.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:Tango.ILMerge.UI"
        mc:Ignorable="d"
        Title="Assembly Merger Utility" Height="350" Width="525" d:DataContext="{d:DesignInstance Type=local:MainWindowVM, IsDesignTimeCreatable=False}">
    <Grid>
        <DockPanel>
            <Grid DockPanel.Dock="Top">
                <TextBlock FontSize="20" Margin="10">Assembly Merger</TextBlock>
                <Rectangle VerticalAlignment="Bottom" Stroke="Gainsboro" StrokeThickness="1"></Rectangle>
            </Grid>

            <DockPanel DockPanel.Dock="Bottom" Background="#F4F4F4">
                <Button DockPanel.Dock="Right" Padding="20 5" Margin="10" Command="{Binding MergeCommand}">MERGE</Button>
                <ProgressBar Height="10" Margin="10 0 0 0"></ProgressBar>
            </DockPanel>

            <Grid>
                <DockPanel Margin="10">
                    <StackPanel DockPanel.Dock="Top">
                        <DockPanel>
                            <Button DockPanel.Dock="Right" Padding="10 5" Margin="10 0 0 0" Command="{Binding BrowseOutputCommand}">
                                BROWSE
                            </Button>
                            <StackPanel>
                                <TextBlock>Output Assembly</TextBlock>
                                <TextBox Margin="0 5 0 0" Text="{Binding Output}"></TextBox>
                            </StackPanel>
                        </DockPanel>

                        <DockPanel Margin="0 10 0 0">
                            <Button DockPanel.Dock="Right" Padding="10 5" Margin="10 0 0 0" Command="{Binding BrowseMainCommand}">
                                BROWSE
                            </Button>
                            <StackPanel>
                                <TextBlock>Main Assembly</TextBlock>
                                <TextBox Margin="0 5 0 0" Text="{Binding Main}"></TextBox>
                            </StackPanel>
                        </DockPanel>
                    </StackPanel>

                    <Grid>
                        <DockPanel Margin="0 10 0 0">
                            <Button DockPanel.Dock="Right" VerticalAlignment="Top" Padding="20 5" Margin="10 0 0 0" Command="{Binding AddAssemblyCommand}">ADD</Button>
                            <ListBox ItemsSource="{Binding Assemblies}">
                                
                            </ListBox>
                        </DockPanel>
                    </Grid>
                </DockPanel>
            </Grid>

        </DockPanel>
    </Grid>
</Window>
ent.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .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 */
/*
 * process.c
 *
 *  Created on: 4 ���� 2018
 *      Author: shlomo
 */
//********************************************************************************************************************
#include <DataDef.h>
#include "include.h"
#include "process.h"

#include "heaters/heaters_ex.h"
#include "PMR/Printing/ProcessParameters.pb-c.h"
#include "PMR/Printing/UploadProcessParametersRequest.pb-c.h"
#include "PMR/Printing/UploadProcessParametersResponse.pb-c.h"
#include "PMR/Hardware/HardwarePidControlType.pb-c.h"
#include "PMR/common/MessageContainer.pb-c.h"

#include "drivers/Valves/Valve.h"
#include "drivers/I2C_Communication/ADC_MUX/ADC_MUX.h"

#include "modules/ids/ids_ex.h"
#include "third_party/fatfs/src/ffconf.h"
#include "Common/SWUpdate/FileSystem.h"
#include "StateMachines/Initialization/PowerIdle.h"

#include "drivers/Flash_ram/FlashProgram.h"


double dyeingspeed = 0;
double dryerbufferlength = 0;
double mininkuptake = 0;
double feedertension = 0;
double pullertension = 0;
double windertension = 0;
double headairflow = 0;
double dryerairflow = 0;
int32_t tableindex = 0;

double dryerbufferMeters = 0;
double dryerbufferCentimeters = 0;

#define MAX_ALLOWED_TEMPERATURE 280

char ProcessParamsConfigPath[50] = "0://SysInfo//ProcessP.cfg";

ProcessParameters ProcessParametersKeep;
void HeatersStopControlOnHeatersOff(ProcessParameters* ProcessParams)
{
    uint32_t temp_sum = 0;
    temp_sum += ProcessParams->dryerzone1temp;
    temp_sum += ProcessParams->dryerzone2temp;
    temp_sum += ProcessParams->dryerzone3temp;
    temp_sum += ProcessParams->mixertemp;
    temp_sum += ProcessParams->headzone1temp;
    temp_sum += ProcessParams->headzone2temp;
    temp_sum += ProcessParams->headzone3temp;
    temp_sum += ProcessParams->headzone4temp;
    temp_sum += ProcessParams->headzone5temp;
    temp_sum += ProcessParams->headzone6temp;

    if (temp_sum == 0)// heating off
    {
        HeatersControlStop();
        REPORT_MSG(temp_sum,"Heating control off - temperatures off");
    }
}
uint32_t HandleProcessParameters(ProcessParameters* ProcessParams)
{
    uint32_t status = 0;
    if (ProcessParams==NULL)
        {
            status = ERROR_CODE__INVALID_PARAMETER;
            return status;
        }
    if (ProcessParams->dryerzone1temp > MAX_ALLOWED_TEMPERATURE) status = ERROR_CODE__INVALID_PARAMETER;
    if (ProcessParams->dryerzone2temp > MAX_ALLOWED_TEMPERATURE) status = ERROR_CODE__INVALID_PARAMETER;
    if (ProcessParams->dryerzone3temp > MAX_ALLOWED_TEMPERATURE) status = ERROR_CODE__INVALID_PARAMETER;
    if (ProcessParams->mixertemp > MAX_ALLOWED_TEMPERATURE) status = ERROR_CODE__INVALID_PARAMETER;
    if (ProcessParams->headzone1temp > MAX_ALLOWED_TEMPERATURE) status = ERROR_CODE__INVALID_PARAMETER;
    if (ProcessParams->headzone2temp > MAX_ALLOWED_TEMPERATURE) status = ERROR_CODE__INVALID_PARAMETER;
    if (ProcessParams->headzone3temp > MAX_ALLOWED_TEMPERATURE) status = ERROR_CODE__INVALID_PARAMETER;
    if (ProcessParams->headzone4temp > MAX_ALLOWED_TEMPERATURE) status = ERROR_CODE__INVALID_PARAMETER;
    if (ProcessParams->headzone5temp > MAX_ALLOWED_TEMPERATURE) status = ERROR_CODE__INVALID_PARAMETER;
    if (ProcessParams->headzone6temp > MAX_ALLOWED_TEMPERATURE) status = ERROR_CODE__INVALID_PARAMETER;
    if (status != 0)
        return status;
    if (ProcessParams)
    {
        memcpy (&ProcessParametersKeep,ProcessParams,sizeof(ProcessParameters));
    }
    if (ProcessParams->mixertemp)
        status |= HeaterCommandRequestMessage(
                HARDWARE_PID_CONTROL_TYPE__MixerHeater, true,
                ProcessParams->mixertemp);
    else
        status |= HeaterCommandRequestMessage(
                HARDWARE_PID_CONTROL_TYPE__MixerHeater, false,
                ProcessParams->mixertemp);
    if (ProcessParams->headzone1temp)
        status |= HeaterCommandRequestMessage(
                HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ1, true,
                ProcessParams->headzone1temp);
    else
        status |= HeaterCommandRequestMessage(
                HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ1, false,
                ProcessParams->headzone1temp);
    if (ProcessParams->headzone2temp)
        status |= HeaterCommandRequestMessage(
                HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ2, true,
                ProcessParams->headzone2temp);
    else
        status |= HeaterCommandRequestMessage(
                HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ2, false,
                ProcessParams->headzone2temp);
    if (ProcessParams->headzone3temp)
        status |= HeaterCommandRequestMessage(
                HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ3, true,
                ProcessParams->headzone3temp);
    else
        status |= HeaterCommandRequestMessage(
                HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ3, false,
                ProcessParams->headzone3temp);
    if (ProcessParams->headzone4temp)
        status |= HeaterCommandRequestMessage(
                HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ4, true,
                ProcessParams->headzone4temp);
    else
        status |= HeaterCommandRequestMessage(
                HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ4, false,
                ProcessParams->headzone4temp);
    if (ProcessParams->headzone5temp)
        status |= HeaterCommandRequestMessage(
                HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ5, true,
                ProcessParams->headzone5temp);
    else
        status |= HeaterCommandRequestMessage(
                HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ5, false,
                ProcessParams->headzone5temp);
    if (ProcessParams->headzone6temp)
        status |= HeaterCommandRequestMessage(
                HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ6, true,
                ProcessParams->headzone6temp);
    else
        status |= HeaterCommandRequestMessage(
                HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ6, false,
                ProcessParams->headzone6temp);
    if (ProcessParams->dryerzone1temp)
        status |= HeaterCommandRequestMessage(
                HARDWARE_PID_CONTROL_TYPE__DryerAirTemperature, true,
                ProcessParams->dryerzone1temp);
    else
        status |= HeaterCommandRequestMessage(
                HARDWARE_PID_CONTROL_TYPE__DryerAirTemperature, false,
                ProcessParams->dryerzone1temp);
/*    if (ProcessParams->dryerzone2temp)
        status |= HeaterCommandRequestMessage(
                HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain, true,
                ProcessParams->dryerzone2temp);
    else
        status |= HeaterCommandRequestMessage(
                HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain, false,
                ProcessParams->dryerzone2temp);
    if (ProcessParams->dryerzone3temp)
        status |= HeaterCommandRequestMessage(
                HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary, true,
                ProcessParams->dryerzone3temp);
    else
        status |= HeaterCommandRequestMessage(
                HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary, false,
                ProcessParams->dryerzone3temp);
                */
    HeatersStopControlOnHeatersOff(ProcessParams);
    dyeingspeed = ProcessParams->dyeingspeed;
    dryerbufferlength = ProcessParams->dryerbufferlength;
    dryerbufferMeters = dryerbufferlength*0.76+0.6;
    dryerbufferCentimeters = dryerbufferlength*76+60;

    Report("drier buffer length",__FILE__,(int)dryerbufferlength,(int)dryerbufferMeters*100,RpWarning,(int)dryerbufferCentimeters,0);

    mininkuptake = ProcessParams->mininkuptake;
    feedertension = ProcessParams->feedertension;
    pullertension = ProcessParams->pullertension;
    windertension = ProcessParams->windertension;
    headairflow = ProcessParams->headairflow;
    dryerairflow = ProcessParams->dryerairflow;

   return status;//status;
}

void ProcessRequestFunc(MessageContainer* requestContainer)
{
    MessageContainer responseContainer;
    uint8_t* container_buffer;
    uint32_t status = 0;
    uint32_t Bytes = 0;

    UploadProcessParametersRequest* request = upload_process_parameters_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data);
    ProcessParameters*  ProcessParams = request->processparameters;
    if ((ProcessParams->dryerzone1temp > 0.1)&&(ProcessParams->headzone2temp > 0.1)&&(ProcessParams->headzone3temp > 0.1)&&(ProcessParams->headzone4temp > 0.1))//NOT turning off heaters
    {
        FileWrite(requestContainer->data.data, requestContainer->data.len,ProcessParamsConfigPath,BIOS_WAIT_FOREVER);
        Bytes = sizeof(ProcessParameters);
        EraseFlashSection(PROCESS_PARAMETERS_MAP_IN_FLASH,Bytes+4);
        ReadAppAndProgram(PROCESS_PARAMETERS_MAP_IN_FLASH, 4,&Bytes);
        ReadAppAndProgram(PROCESS_PARAMETERS_MAP_IN_FLASH+4, Bytes, ProcessParams);
        REPORT_MSG(Bytes,"Bytes write to flash");

    }
    ////////////////////////////////////////////////////////////////////////
    /*UploadProcessParametersRequest* requesttest;
    uint8_t* buffer = NULL;
    uint32_t Bytes = 0;

    ProcessParameters*  ProcessParamsTest;
    FileRead(ProcessParamsConfigPath, &Bytes, &buffer);
    requesttest = upload_process_parameters_request__unpack(NULL, Bytes, buffer);
    //           ProcessParameters*  ProcessParams = process_parameters__unpack(NULL, Bytes, buffer);
           if (requesttest)
           {
               ProcessParamsTest = request->processparameters;
           }
       free (buffer);
       upload_process_parameters_request__free_unpacked(requesttest,NULL);
*/
/////////////////////////////////////////////////////////
    UploadProcessParametersResponse response = UPLOAD_PROCESS_PARAMETERS_RESPONSE__INIT;

    responseContainer = createContainer(MESSAGE_TYPE__UploadProcessParametersResponse, requestContainer->token, true, &response, &upload_process_parameters_response__pack, &upload_process_parameters_response__get_packed_size);
    container_buffer = my_malloc(message_container__get_packed_size(&responseContainer));


    //REPORT_MSG (ProcessParams->dryerzone1temp,"Process Params Dryer");
    PowerIdleOutOfIdleState();

    if (status == 0)
        status = HandleProcessParameters(ProcessParams);
    if (status)
    {
        responseContainer.has_error = true;
        responseContainer.error = (ErrorCode)status;
    }
    size_t container_size = message_container__pack(&responseContainer, container_buffer);
    my_free(responseContainer.data.data);
    SendChars(container_buffer, container_size);
    upload_process_parameters_request__free_unpacked(request,NULL);

}
uint32_t LoadProcessParamsFromFile(void)
{
    FRESULT Fresult = FR_OK;
    uint8_t* buffer = NULL;
    uint32_t Bytes = 0;

    Fresult = FileRead(ProcessParamsConfigPath, &Bytes, &buffer);
    if (Fresult == FR_OK)
    {
        UploadProcessParametersRequest* request = upload_process_parameters_request__unpack(NULL, Bytes, buffer);
        ProcessParameters*  ProcessParams = request->processparameters;

        if ((request!= NULL)&&(ProcessParams!=NULL))
        {
            if ((ProcessParams->dryerzone1temp > 0.1)&&(ProcessParams->headzone2temp > 0.1)&&(ProcessParams->headzone3temp > 0.1)&&(ProcessParams->headzone4temp > 0.1))//NOT turning off heaters
            {
                Bytes = sizeof(ProcessParameters);
                EraseFlashSection(PROCESS_PARAMETERS_MAP_IN_FLASH,Bytes+4);
                ReadAppAndProgram(PROCESS_PARAMETERS_MAP_IN_FLASH, 4,&Bytes);
                ReadAppAndProgram(PROCESS_PARAMETERS_MAP_IN_FLASH+4, Bytes, ProcessParams);
                REPORT_MSG(Bytes,"ProcessParameters Bytes write to flash");
                free (buffer);
            }
        }
        else
        {
            Report("process parameters not loaded",__FILE__,__LINE__,(int)request,RpWarning,(int)request,0);
            return ERROR;
        }
    }

    return Fresult;
}
uint32_t ProcessParamsInit(void)
{
    FRESULT Fresult = FR_OK;
    uint32_t Bytes;

    memcpy(&Bytes,(void *)PROCESS_PARAMETERS_MAP_IN_FLASH,sizeof(Bytes));
    REPORT_MSG(Bytes,"Bytes read from flash");

    if ((Bytes)&&(Bytes < 1000))
    {
        ProcessParameters*  ProcessParams = (ProcessParameters *)(PROCESS_PARAMETERS_MAP_IN_FLASH+4);
        Fresult = HandleProcessParameters(ProcessParams);
    }
    else
    {
        if (LoadProcessParamsFromFile()==OK)
        {
            memcpy(&Bytes,(void *)PROCESS_PARAMETERS_MAP_IN_FLASH,sizeof(Bytes));
            REPORT_MSG(Bytes,"ProcessParams Bytes read from flash");

            if ((Bytes)&&(Bytes < 1000))
            {
                ProcessParameters*  ProcessParams = (ProcessParameters *)(PROCESS_PARAMETERS_MAP_IN_FLASH+4);
                Fresult = HandleProcessParameters(ProcessParams);
            }
        }
    }

    return Fresult;
}