Beispiel #1
0
        public async Task <bool> Receive()
        {
            string dataFromDriver = await valves[ActualProcessedValve].Receive();

            if (TestSettings.IsLogInDataSelected & (TestSettings.IsLogTimeoutSelected | !dataFromDriver.Equals("Timeout")))
            {
                CommunicationLogChanged?.Invoke(dataFromDriver + "\n");
            }
            return(true);
        }
Beispiel #2
0
        public async Task <bool> Send()
        {
            string dataToDriver = await valves[ActualProcessedValve].ExecuteStep();

            if (TestSettings.IsLogOutDataSelected & dataToDriver != null)
            {
                CommunicationLogChanged?.Invoke(dataToDriver + "\n");
            }
            return(true);
        }
Beispiel #3
0
        public async Task <(string, byte[])> ReadInputs()
        {
            try
            {
                errorCode = await Task <string> .Run(() => advantechDIControl.Read(startPort, portCount, buffer));

                OnInputsRead(this, errorCode.ToString(), buffer);
            }
            catch (Exception e)
            {
                CommunicationLogChanged?.Invoke($"Advantech read exception {e.Message} !\n");
            }
            return(errorCode.ToString(), buffer);
        }
Beispiel #4
0
 public ActionStatus Initialize()
 {
     try
     {
         advantechDIControl.SelectedDevice = new DeviceInformation(deviceDescription);
         errorCode = advantechDIControl.LoadProfile(profilePath);
         dioPort   = advantechDIControl.Ports;
     }
     catch (Exception e)
     {
         CommunicationLogChanged?.Invoke($"Advantech init exception {e.Message}!\n");
     }
     CommunicationLogChanged?.Invoke($"Advantech Init status: {errorCode}\n");
     return(ErrorCodeToActionStatus(errorCode));
 }
Beispiel #5
0
        public ActionStatus Initialize(int numberOfChannels)
        {
            bool initializationWithoutErrors = true;

            this.MasterMask              = new ulong[numberOfChannels];
            vectorHardware               = new VectorHardware(driver, driverConfig, applicationName, numberOfChannels);
            initializationWithoutErrors &= OpenDriver();
            initializationWithoutErrors &= GetDriverConfiguration();
            initializationWithoutErrors &= InitializeVectorHardware();
            permissionMask               = 0;
            for (int i = 0; i < numberOfChannels; i++)
            {
                permissionMask |= vectorHardware.accessMaskMaster[i];
                MasterMask[i]   = vectorHardware.accessMaskMaster[i];
            }
            initializationWithoutErrors &= OpenPort();
            initializationWithoutErrors &= SetLinChannelParameters();
            initializationWithoutErrors &= SetDataLengthControl();
            initializationWithoutErrors &= ActivateChannel();
            initializationWithoutErrors &= SetNotificationAndReadHandle();
            CommunicationLogChanged?.Invoke(InitializeInfo);
            return(initializationWithoutErrors ? ActionStatus.OK : ActionStatus.Error);
        }