aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/Dialogs/PowerUpView.xaml
blob: 08177843448b1a3c076a19d0c5421b3e98ad6b06 (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
<UserControl x:Class="Tango.PPC.UI.Dialogs.PowerUpView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch"
             xmlns:local="clr-namespace:Tango.PPC.UI.Dialogs"
             mc:Ignorable="d" 
             Background="{StaticResource TangoPrimaryBackgroundBrush}"  d:DesignHeight="555" d:DesignWidth="560" Width="600" Height="800" d:DataContext="{d:DesignInstance Type=local:PowerUpViewVM, IsDesignTimeCreatable=False}">
    <Grid>
        <StackPanel Margin="0 100 0 0" HorizontalAlignment="Center">
            <touch:TouchGifAnimation Source="../Images/powerup.gif" EnableAnimation="{Binding IsVisible}" />
            <TextBlock HorizontalAlignment="Center" FontSize="{StaticResource TangoTitleFontSize}" Margin="0 30 0 0">Continue getting ready for:</TextBlock>
            <DockPanel HorizontalAlignment="Center" Margin="0 40 0 0">
                <touch:TouchRadioButton IsChecked="{Binding IsSelectedRml}" />
                <touch:TouchComboBox Margin="20 0 0 0" Width="300" ItemsSource="{Binding Rmls}" SelectedItem="{Binding SelectedRml}" DisplayMemberPath="Name" Title="Select thread type"></touch:TouchComboBox>
            </DockPanel>
            <DockPanel HorizontalAlignment="Left" Margin="0 40 0 0">
                <touch:TouchRadioButton IsChecked="{Binding IsMinimalTemperature}" />
                <TextBlock VerticalAlignment="Center" Margin="20 0 0 0">Minimal temperature</TextBlock>
            </DockPanel>

            <touch:TouchButton Command="{Binding OKCommand}" Margin="0 150 0 0" Style="{StaticResource TangoHollowButton}" HorizontalAlignment="Center" Padding="60 15" CornerRadius="25">CONTINUE</touch:TouchButton>

            <TextBlock HorizontalAlignment="Center" Margin="0 10 0 0" Visibility="{Binding IsTimeoutEnabled,Converter={StaticResource BooleanToVisibilityConverter}}">
                <Run>auto select in</Run>
                <Run Text="{Binding RemainingSeconds}"></Run>
                <Run>sec</Run>
            </TextBlock>
        </StackPanel>
    </Grid>
</UserControl>
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 */
/************************************************************************************************************************
 * control.c
 * Control module
 *
************************************************************************************************************************/
#include <Container.h>
#include <DataDef.h>
#include "include.h"
#include "GeneralHardware.h"
#include "thread/thread.h"
#include "ids/ids.h"
#include "control/control.h"
#include "heaters/heaters_ex.h"
#include "StateMachines/Printing/PrintingSTM.h"

#include "heaters/heaters_ex.h"

#include "PMR/common/MessageContainer.pb-c.h"
#include "PMR/Hardware/UploadHardWareConfigurationRequest.pb-c.h"
#include "PMR/Hardware/UploadHardWareConfigurationResponse.pb-c.h"
#include "PMR/Hardware/SystemResetRequest.pb-c.h"
#include "PMR/Hardware/SystemResetResponse.pb-c.h"

#include "drivers/I2C_Communication/DAC/Blower.h"

uint32_t HWConfigurationFunc(MessageContainer* requestContainer)
{
    uint32_t status  = 0;
    int Motor_i, Dancer_i, Dispenser_i,PID_i;
    MessageContainer responseContainer;
    UploadHardwareConfigurationResponse response = UPLOAD_HARDWARE_CONFIGURATION_RESPONSE__INIT;

    UploadHardwareConfigurationRequest* UploadRequest = upload_hardware_configuration_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data);

    if (UploadRequest == NULL)
    {
        LOG_ERROR (0, "Wrong Data Allocation");
        return ERROR;
    }
    HardwareConfiguration *request =    UploadRequest->hardwareconfiguration;

    PrintingHWConfiguration(request);
    if (request->n_winders == 1)
        status += InternalWinderConfigMessage(request->winders);
    status += MotorsInit();

    if (request->n_motors < NUM_OF_MOTORS)
    {
        for (Motor_i = 0; Motor_i < request->n_motors ; Motor_i++)
        status += MotorsConfigMessage(request->motors[Motor_i]);
    }
    else
    {
        LOG_ERROR (request->n_motors, "Wrong Data");
        upload_hardware_configuration_request__free_unpacked(UploadRequest,NULL);
        return ERROR;
    }
    if (request->n_dancers <= NUM_OF_DANCERS)
    {
        for (Dancer_i = 0; Dancer_i < request->n_dancers ; Dancer_i++)
            status += DancerConfigMessage(request->dancers[Dancer_i]);
    }
    else
    {
        LOG_ERROR (request->n_dancers, "Wrong Data");
        upload_hardware_configuration_request__free_unpacked(UploadRequest,NULL);
        return ERROR;
    }
    if (request->n_pidcontrols <= HARDWARE_PID_CONTROL_TYPE__Dispenser8)
    {
        for (PID_i = 0; PID_i < request->n_pidcontrols ; PID_i++)
        {
            if (request->pidcontrols[PID_i]->hardwarepidcontroltype <= HARDWARE_PID_CONTROL_TYPE__MixerHeater)
                status += HeaterConfigRequestMessage(request->pidcontrols[PID_i]);
            else if ((request->pidcontrols[PID_i]->hardwarepidcontroltype >= HARDWARE_PID_CONTROL_TYPE__MotorDryer)&&
                    (request->pidcontrols[PID_i]->hardwarepidcontroltype < HARDWARE_PID_CONTROL_TYPE__Dispenser1))
                status += MotorPidRequestMessage(request->pidcontrols[PID_i]);
            else if (request->pidcontrols[PID_i]->hardwarepidcontroltype >= HARDWARE_PID_CONTROL_TYPE__Dispenser1)
                status += IDS_DispenserPidRequestMessage(request->pidcontrols[PID_i]);
        }
    }
    else
    {
        LOG_ERROR (request->n_pidcontrols, "Wrong Data");
        upload_hardware_configuration_request__free_unpacked(UploadRequest,NULL);
        return ERROR;
    }
    if (request->n_dispensers <= MAX_SYSTEM_DISPENSERS)
    {
        for (Dispenser_i = 0; Dispenser_i < request->n_dispensers ; Dispenser_i++)
            status += DispenserConfigMessage(request->dispensers[Dispenser_i]);
    }
    else
    {
        LOG_ERROR (request->n_dispensers, "Wrong Data");
        upload_hardware_configuration_request__free_unpacked(UploadRequest,NULL);
        return ERROR;
    }
    ThreadConfigBreakSensor(request->breaksensors);

    if(request->blowers[0]->enabled)
    {
        Turn_the_Blower_On();//Turn on with the Default_Voltage
        if (request->blowers[0]->voltage)
            Control_Voltage_To_Blower(request->blowers[0]->voltage);
    }

    ControlStart();
    //ThreadInitialTestStub(request);


    responseContainer = createContainer(MESSAGE_TYPE__UploadHardwareConfigurationResponse, requestContainer->token, true, &response, &upload_hardware_configuration_response__pack, &upload_hardware_configuration_response__get_packed_size);
    uint8_t* container_buffer = malloc(message_container__get_packed_size(&responseContainer));
    size_t container_size = message_container__pack(&responseContainer, container_buffer);
    free(responseContainer.data.data);
    upload_hardware_configuration_request__free_unpacked(UploadRequest,NULL);
    SendChars(container_buffer, container_size);
    //free(container_buffer);
    //free(requestContainer);

    return OK;



}

void HWSystemResetRequest(MessageContainer* requestContainer)
{
    uint32_t status = FAILED;

    MessageContainer responseContainer;
    SystemResetRequest* request = system_reset_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data);

    status = 0;

    SystemResetResponse response =   SYSTEM_RESET_RESPONSE__INIT;


    responseContainer = createContainer(MESSAGE_TYPE__SystemResetResponse, requestContainer->token, true, &response, &system_reset_response__pack, &system_reset_response__get_packed_size);

    //free(request);
    system_reset_request__free_unpacked(request,NULL);
    //-------------------------------------------------------------------------------------------
    uint8_t* container_buffer = malloc(message_container__get_packed_size(&responseContainer));
    size_t container_size = message_container__pack(&responseContainer, container_buffer);
    SendChars((char*)container_buffer, container_size);
    //free(container_buffer);
    //free(requestContainer);

    ROM_SysCtlDelay(SYS_CLK_FREQ);

    SysCtlReset();

    HWREG(NVIC_APINT) = NVIC_APINT_VECTKEY |  NVIC_APINT_SYSRESETREQ;

}