aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/DigitalInItem.cs
blob: bf06aae95c9a19332bc8305c049555f71cf8ebfb (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using System.Xml.Serialization;
using Tango.BL.Entities;
using Tango.SharedUI.Helpers;

namespace Tango.MachineStudio.Technician.TechItems
{
    /// <summary>
    /// Represents a digital input pin item.
    /// </summary>
    /// <seealso cref="Tango.MachineStudio.Technician.TechItems.TechItem" />
    [TechItem(0)]
    public class DigitalInItem : TechItem
    {
        private TechIo _techIo;
        /// <summary>
        /// Gets or sets the DB tech item.
        /// </summary>
        [XmlIgnore]
        public TechIo TechIo
        {
            get { return _techIo; }
            set { _techIo = value; RaisePropertyChangedAuto(); TechName = _techIo != null ? _techIo.InterfaceName : null; ItemGuid = value != null ? value.Guid : null; }
        }

        private bool _value;
        /// <summary>
        /// Gets or sets whether the input is on.
        /// </summary>
        [XmlIgnore]
        public bool Value
        {
            get { return _value; }
            set { _value = value; RaisePropertyChangedAuto(); }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="DigitalInItem"/> class.
        /// </summary>
        public DigitalInItem() : base()
        {
            Name = "Digital Input Interface";
            Description = "Digital Input Interface LED";
            Image = ResourceHelper.GetImageFromResources("Images/digital-in.png");
            Color = Colors.White;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="DigitalInItem"/> class.
        /// </summary>
        /// <param name="techIo">The db tech.</param>
        public DigitalInItem(TechIo techIo) : this()
        {
            TechIo = techIo;
        }

        /// <summary>
        /// Clones this instance.
        /// </summary>
        /// <returns></returns>
        public override TechItem Clone()
        {
            DigitalInItem cloned = base.Clone() as DigitalInItem;
            cloned.TechIo = TechIo;
            return cloned;
        }
    }
}
s="p">)&&(isMotorConfigured(MotorId) == true)) { { switch (request->direction) { case MOTOR_DIRECTION__Forward: direction = 1-MotorsCfg[MotorId].directionthreadwize; break; case MOTOR_DIRECTION__Backward: direction = MotorsCfg[MotorId].directionthreadwize; break; } MotorSetDirection(MotorId,direction); MotorSetSpeed(MotorId, speed); } } else { status = ERROR; } } else { status = ERROR; } responseContainer = createContainer(MESSAGE_TYPE__MotorJoggingResponse, requestContainer->token, false, &response, &motor_jogging_response__pack, &motor_jogging_response__get_packed_size); if (status!= OK) { responseContainer.error = ERROR_CODE__INVALID_PROCESS_ID; responseContainer.errormessage = "JOb Active or incorrect parameters"; } 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); SendChars(container_buffer, container_size); return OK; } uint32_t MotorAbortJoggingRequestFunc(MessageContainer* requestContainer) { MessageContainer responseContainer; MotorAbortJoggingRequest* request = motor_abort_jogging_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); MotorAbortJoggingResponse response = MOTOR_ABORT_JOGGING_RESPONSE__INIT; TimerMotors_t MotorId = (TimerMotors_t)request->motortype; MotorStop(MotorId,Hard_Hiz); responseContainer = createContainer(MESSAGE_TYPE__MotorAbortJoggingResponse, requestContainer->token, false, &response, &motor_abort_jogging_response__pack, &motor_abort_jogging_response__get_packed_size); 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); SendChars(container_buffer, container_size); return OK; } /******************************************************************************** * Dispenser Jogging ********************************************************************************/ uint32_t DispenserJoggingRequestFunc(MessageContainer* requestContainer) { uint32_t status = OK; MessageContainer responseContainer; DispenserJoggingRequest* request = dispenser_jogging_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); DispenserJoggingResponse response = DISPENSER_JOGGING_RESPONSE__INIT; TimerMotors_t MotorId = (request->index)+HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_1; int speed = request->speed; if (speed == 0) speed = 150; bool direction; if (MotorId <= NUM_OF_MOTORS) { if ((JobIsActive() == false)&&(isMotorConfigured(MotorId) == true)) { switch (request->direction) { case MOTOR_DIRECTION__Forward: Control3WayValvesWithCallback ((Valves_t) request->index, Dispenser_Mixer, NULL); //direction: MidTank_Dispenser or Dispenser_Mixer direction = MotorsCfg[MotorId].directionthreadwize; break; case MOTOR_DIRECTION__Backward: Control3WayValvesWithCallback ((Valves_t) request->index, MidTank_Dispenser, NULL); //direction: MidTank_Dispenser or Dispenser_Mixer direction = 1-MotorsCfg[MotorId].directionthreadwize; break; } MotorSetDirection(MotorId,direction); MotorSetSpeed(MotorId, speed); } else { status = ERROR; } } else { status = ERROR; } responseContainer = createContainer(MESSAGE_TYPE__DispenserJoggingResponse, requestContainer->token, false, &response, &dispenser_jogging_response__pack, &dispenser_jogging_response__get_packed_size); if (status!= OK) { responseContainer.error = ERROR_CODE__INVALID_PROCESS_ID; responseContainer.errormessage = "JOb Active or incorrect parameters"; } 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); SendChars(container_buffer, container_size); return OK; } uint32_t DispenserAbortJoggingRequestFunc(MessageContainer* requestContainer) { MessageContainer responseContainer; DispenserAbortJoggingRequest* request = dispenser_abort_jogging_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); DispenserAbortJoggingResponse response = DISPENSER_ABORT_JOGGING_RESPONSE__INIT; TimerMotors_t MotorId = (request->index)+HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_1; MotorStop(MotorId,Hard_Hiz); Control3WayValvesWithCallback ((Valves_t) request->index, MidTank_Dispenser, NULL); //direction: MidTank_Dispenser or Dispenser_Mixer responseContainer = createContainer(MESSAGE_TYPE__DispenserAbortJoggingResponse, requestContainer->token, false, &response, &dispenser_abort_jogging_response__pack, &dispenser_abort_jogging_response__get_packed_size); 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); SendChars(container_buffer, container_size); return OK; }