This commit is contained in:
2026-04-17 14:55:32 -04:00
commit bc3ac1d4c9
18017 changed files with 4371742 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
ALTER TABLE [dbo].[DAS] ADD [FirstUseDate] DATETIME NULL;
ALTER TABLE [dbo].[DAS] ADD [GroupId] INT NULL;
ALTER TABLE [dbo].[DAS] ADD [TestId] INT NULL;
ALTER TABLE [dbo].[DAS] ADD [StandIn] BIT NULL;

View File

@@ -0,0 +1,2 @@
ALTER TABLE dbo.Groups
ADD ExtraProperties nvarchar(MAX) NULL;

View File

@@ -0,0 +1,5 @@
ALTER TABLE dbo.SensorsAnalog
ADD FirstUseDate datetime NULL;
ALTER TABLE dbo.SensorsAnalog
ADD LatestCalibrationId int NULL;

View File

@@ -0,0 +1,2 @@
ALTER TABLE dbo.TestSetupHardware
ADD AntiAliasFilterRate float NOT NULL DEFAULT 0;

View File

@@ -0,0 +1,2 @@
ALTER TABLE dbo.TestSetups
ADD ExtraProperties nvarchar(MAX) NULL;

View File

@@ -0,0 +1,44 @@
ALTER PROCEDURE [dbo].[sp_DASGet]
@SerialNumber nvarchar(50) = null
,@position nvarchar(10) = null
AS
BEGIN
SET NOCOUNT ON;
SELECT [DASId]
,[SerialNumber]
,[Type]
,[MaxModules]
,[MaxMemory]
,[MaxSampleRate]
,[MinSampleRate]
,[FirmwareVersion]
,[CalDate]
,[ProtocolVersion]
,[LastModified]
,[LastModifiedBy]
,[Version]
,[LocalOnly]
,[LastUsed]
,[LastUsedBy]
,[Connection]
,[Channels]
,[Position]
,[ChannelTypes]
,[Reprogramable]
,[Reconfigurable]
,[IsModule]
,isnull([PositionOnDistributor], 0) as [PositionOnDistributor]
,isnull([PositionOnChain], 0) as [PositionOnChain]
,isnull([Port],0) as [Port]
,isnull([ParentDAS], space(0)) as [ParentDAS],
[FirstUseDate],
[TestId],
[GroupId],
[StandIn]
FROM [dbo].[DAS] where
(@SerialNumber is null or DASId = dbo.foo_IdGetDAS(@SerialNumber))
and
Position = case when @position is null then space(0) else @position end
END

View File

@@ -0,0 +1,107 @@
ALTER PROCEDURE [dbo].[sp_DASInsert]
@SerialNumber nvarchar(50) = null
,@Type int
,@MaxModules int
,@MaxMemory bigint
,@MaxSampleRate decimal(18,0)
,@MinSampleRate decimal(18,0)
,@FirmwareVersion nvarchar(50)
,@CalDate datetime
,@ProtocolVersion int
,@LastModified datetime
,@LastModifiedBy nvarchar(50)
,@Version int
,@LocalOnly bit
,@LastUsed datetime
,@LastUsedBy nvarchar(50)
,@Connection nvarchar(50)
,@Channels int
,@Position nvarchar(50)
,@ChannelTypes nvarchar(255)
,@Reprogramable bit
,@Reconfigurable bit
,@IsModule bit
,@PositionOnDistributor smallint
,@PositionOnChain smallint
,@Port smallint
,@ParentDAS nvarchar(50)
,@FirstUseDate datetime null
,@TestId int null
,@GroupId int null
,@StandIn bit null
,@new_id int OUTPUT
,@errorNumber int output
,@errorMessage nvarchar(250) output
AS
BEGIN
set @errorNumber = 0
set @errorMessage = space(0)
SET NOCOUNT ON;
if(@SerialNumber is null)
begin
RAISERROR(15600,-1,-1, 'sp_DASInsert') /* Error 1560 - An invalid parameter or option was specified for procedure*/
end
else
begin
INSERT INTO [dbo].[DAS]
([SerialNumber]
,[Type]
,[MaxModules]
,[MaxMemory]
,[MaxSampleRate]
,[MinSampleRate]
,[FirmwareVersion]
,[CalDate]
,[ProtocolVersion]
,[LastModified]
,[LastModifiedBy]
,[Version]
,[LocalOnly]
,[LastUsed]
,[LastUsedBy]
,[Connection]
,[Channels]
,[Position]
,[ChannelTypes]
,[Reprogramable]
,[Reconfigurable]
,[IsModule]
,[PositionOnDistributor]
,[PositionOnChain]
,[Port]
,[ParentDAS]
,[FirstUseDate])
VALUES
( @SerialNumber
,@Type
,@MaxModules
,@MaxMemory
,@MaxSampleRate
,@MinSampleRate
,@FirmwareVersion
,@CalDate
,@ProtocolVersion
,@LastModified
,@LastModifiedBy
,@Version
,@LocalOnly
,@LastUsed
,@LastUsedBy
,@Connection
,@Channels
,@Position
,@ChannelTypes
,@Reprogramable
,@Reconfigurable
,@IsModule
,@PositionOnDistributor
,@PositionOnChain
,@Port
,@ParentDAS
,@FirstUseDate)
set @new_id = scope_identity();
end
END

View File

@@ -0,0 +1,86 @@
ALTER PROCEDURE [dbo].[sp_DASUpdate]
@DASId int = 0
,@SerialNumber nvarchar(50) = null
,@Type int
,@MaxModules int
,@MaxMemory bigint
,@MaxSampleRate decimal(18,0)
,@MinSampleRate decimal(18,0)
,@FirmwareVersion nvarchar(50)
,@CalDate datetime
,@ProtocolVersion int
,@LastModified datetime
,@LastModifiedBy nvarchar(50)
,@Version int
,@LocalOnly bit
,@LastUsed datetime
,@LastUsedBy nvarchar(50)
,@Connection nvarchar(50)
,@Channels int
,@Position nvarchar(50)
,@ChannelTypes nvarchar(255)
,@Reprogramable bit
,@Reconfigurable bit
,@IsModule bit
,@PositionOnDistributor smallint
,@PositionOnChain smallint
,@Port smallint
,@ParentDAS nvarchar(50)
,@FirstUseDate datetime null
,@TestId int null
,@GroupId int null
,@StandIn bit null
,@new_id int output
,@errorNumber int output
,@errorMessage nvarchar(250) output
AS
BEGIN
set @errorNumber = 0
set @errorMessage = space(0)
SET NOCOUNT ON;
if(@SerialNumber is null)
begin
set @errorNumber = 15600
set @errorMessage = 'An invalid parameter or option was specified for procedure'
end
else
begin
if(@DASId = 0)
begin
set @DASId = dbo.foo_IdGetDAS(@SerialNumber)
end
SET @new_id = @DASId
UPDATE [dbo].[DAS]
SET [Type] = @Type
,[MaxModules] = @MaxModules
,[MaxMemory] = @MaxMemory
,[MaxSampleRate] = @MaxSampleRate
,[MinSampleRate] = @MinSampleRate
,[FirmwareVersion] = @FirmwareVersion
,[CalDate] = @CalDate
,[ProtocolVersion] = @ProtocolVersion
,[LastModified] = @LastModified
,[LastModifiedBy] = @LastModifiedBy
,[Version] = @Version
,[LocalOnly] = @LocalOnly
,[LastUsed] = @LastUsed
,[LastUsedBy] = @LastUsedBy
,[Connection] = @Connection
,[Channels] = @Channels
,[Position] = @Position
,[ChannelTypes] = @ChannelTypes
,[Reprogramable] = @Reprogramable
,[Reconfigurable] = @Reconfigurable
,[IsModule] = @IsModule
,[PositionOnDistributor]= @PositionOnDistributor
,[PositionOnChain] = @PositionOnChain
,[Port] = @Port
,[ParentDAS] = @ParentDAS
,[FirstUseDate] = @FirstUseDate
,[TestId] = @TestId
,[GroupId] = @GroupId
,[StandIn] = @StandIn
WHERE [DASId] = @DASId
end
END

View File

@@ -0,0 +1,120 @@
ALTER PROCEDURE [dbo].[sp_DASUpdateInsert]
@DASId int = 0
,@SerialNumber nvarchar(50) = null
,@Type int
,@MaxModules int
,@MaxMemory bigint
,@MaxSampleRate decimal(18,0)
,@MinSampleRate decimal(18,0)
,@FirmwareVersion nvarchar(50)
,@CalDate datetime
,@ProtocolVersion int
,@LastModified datetime
,@LastModifiedBy nvarchar(50)
,@Version int
,@LocalOnly bit
,@LastUsed datetime
,@LastUsedBy nvarchar(50)
,@Connection nvarchar(50)
,@Channels int
,@Position nvarchar(50)
,@ChannelTypes nvarchar(255)
,@Reprogramable bit
,@Reconfigurable bit
,@IsModule bit
,@PositionOnDistributor smallint
,@PositionOnChain smallint
,@Port smallint
,@ParentDAS nvarchar(50)
,@FirstUseDate datetime null
,@TestId int null
,@GroupId int null
,@StandIn bit null
,@new_id int OUTPUT
,@errorNumber int output
,@errorMessage nvarchar(250) output
AS
BEGIN
set @errorNumber = 0
set @errorMessage = space(0)
SET NOCOUNT ON;
if(@DASId = 0)
begin
set @DASId = dbo.foo_IdGetDAS(@SerialNumber)
end
if(@DASId != 0)
begin
exec dbo.sp_DASUpdate @DASId
,@SerialNumber
,@Type
,@MaxModules
,@MaxMemory
,@MaxSampleRate
,@MinSampleRate
,@FirmwareVersion
,@CalDate
,@ProtocolVersion
,@LastModified
,@LastModifiedBy
,@Version
,@LocalOnly
,@LastUsed
,@LastUsedBy
,@Connection
,@Channels
,@Position
,@ChannelTypes
,@Reprogramable
,@Reconfigurable
,@IsModule
,@PositionOnDistributor
,@PositionOnChain
,@Port
,@ParentDAS
,@FirstUseDate
,@TestId
,@GroupId
,@StandIn
,@new_id
,@errorNumber output, @errorMessage output
SET @new_id = @DASId
end
else
begin
exec dbo.sp_DASInsert @SerialNumber
,@Type
,@MaxModules
,@MaxMemory
,@MaxSampleRate
,@MinSampleRate
,@FirmwareVersion
,@CalDate
,@ProtocolVersion
,@LastModified
,@LastModifiedBy
,@Version
,@LocalOnly
,@LastUsed
,@LastUsedBy
,@Connection
,@Channels
,@Position
,@ChannelTypes
,@Reprogramable
,@Reconfigurable
,@IsModule
,@PositionOnDistributor
,@PositionOnChain
,@Port
,@ParentDAS
,@FirstUseDate
,@TestId
,@GroupId
,@StandIn
,@new_id output
,@errorNumber output, @errorMessage output
end
END

View File

@@ -0,0 +1,63 @@
ALTER PROCEDURE [dbo].[sp_GroupsGet]
@Id int = null,
@SerialNumber NVARCHAR (255) = null,
@DisplayName NVARCHAR (255) = null,
@Embedded BIT = null,
@TestSetupId int = null,
@TestSetupName NVARCHAR (255) = null,
@StaticGroupId int = null,
@ExtraProperties NVARCHAR (MAX) = null
AS
BEGIN
SET NOCOUNT ON;
IF( @Id IS NULL )
BEGIN
IF( @TestSetupId IS NULL)
BEGIN
IF NULLIF(@TestSetupName,'') IS NULL
BEGIN
IF NULLIF( @SerialNumber, '') IS NULL
BEGIN
IF NULLIF( @DisplayName, '') IS NULL
BEGIN
IF( @Embedded IS NULL )
BEGIN
IF( @StaticGroupId IS NULL )
BEGIN
SELECT A.Id, A.Picture, A.SerialNumber, A.DisplayName, A.[Description], A.Embedded, A.LastModifiedBy, A.LastModified, A.StaticGroupId, A.ExtraProperties FROM [dbo].Groups AS A
END
ELSE
BEGIN
SELECT A.Id, A.Picture, A.SerialNumber, A.DisplayName, A.[Description], A.Embedded, A.LastModifiedBy, A.LastModified, A.StaticGroupId, A.ExtraProperties FROM [dbo].Groups AS A WHERE A.StaticGroupId=@StaticGroupId
END
END
ELSE
BEGIN
SELECT A.Id, A.Picture, A.SerialNumber, A.DisplayName, A.[Description], A.Embedded, A.LastModifiedBy, A.LastModified, A.StaticGroupId, A.ExtraProperties FROM [dbo].Groups AS A WHERE A.Embedded=@Embedded
END
END
ELSE
BEGIN
SELECT A.Id, A.Picture, A.SerialNumber, A.DisplayName, A.[Description], A.Embedded, A.LastModifiedBy, A.LastModified, A.StaticGroupId, A.ExtraProperties FROM [dbo].Groups AS A WHERE A.DisplayName=@DisplayName
END
END
ELSE
BEGIN
SELECT A.Id, A.Picture, A.SerialNumber, A.DisplayName, A.[Description], A.Embedded, A.LastModifiedBy, A.LastModified, A.StaticGroupId, A.ExtraProperties FROM [dbo].Groups AS A WHERE A.SerialNumber=@SerialNumber
END
END
ELSE
BEGIN
SELECT A.Id, A.Picture, A.SerialNumber, A.DisplayName, A.[Description], A.Embedded, A.LastModifiedBy, A.LastModified, A.StaticGroupId, A.ExtraProperties FROM [dbo].Groups AS A INNER JOIN [dbo].TestSetupGroups as B ON A.Id=B.GroupId INNER JOIN [dbo].TestSetups AS C on C.TestSetupId=B.TestSetupId WHERE C.TestSetupName=@TestSetupName
END
END
ELSE
BEGIN
SELECT A.Id, A.Picture, A.SerialNumber, A.DisplayName, A.[Description], A.Embedded, A.LastModifiedBy, A.LastModified, A.StaticGroupId, A.ExtraProperties FROM [dbo].Groups AS A INNER JOIN [dbo].TestSetupGroups as B ON A.Id=B.GroupId WHERE B.TestSetupId=@TestSetupId
END
END
ELSE
BEGIN
SELECT A.Id, A.Picture, A.SerialNumber, A.DisplayName, A.[Description], A.Embedded, A.LastModifiedBy, A.LastModified, A.StaticGroupId, A.ExtraProperties FROM [dbo].Groups AS A WHERE A.Id=@Id
END
END

View File

@@ -0,0 +1,28 @@
ALTER PROCEDURE [dbo].[sp_GroupsInsert]
@SerialNumber NVARCHAR (255),
@Picture NVARCHAR (255) = NULL,
@DisplayName NVARCHAR (255),
@Embedded BIT,
@Description NVARCHAR (255),
@LastModified DATETIME,
@LastModifiedBy NVARCHAR (255),
@StaticGroupId int = NULL,
@ExtraProperties NVARCHAR (MAX),
@errorNumber int OUTPUT,
@errorMessage NVARCHAR (255) OUTPUT,
@new_id int OUTPUT
AS
BEGIN
SET NOCOUNT ON;
SET @errorNumber=0
SET @errorMessage=''
INSERT INTO Groups (SerialNumber, [Picture], DisplayName, [Description], Embedded, LastModified, LastModifiedBy, StaticGroupId, ExtraProperties)
VALUES (@SerialNumber, @Picture, @DisplayName, @Description, @Embedded, @LastModified, @LastModifiedBy, @StaticGroupId, @ExtraProperties)
SET @new_id = scope_identity();
IF(@@error != 0)
BEGIN
SET @errorNumber = error_number()
SET @errorMessage = error_message()
END
END

View File

@@ -0,0 +1,27 @@
ALTER PROCEDURE [dbo].[sp_GroupsUpdate]
@Id INT,
@SerialNumber NVARCHAR (255),
@Picture NVARCHAR (255) = NULL,
@DisplayName NVARCHAR (255),
@Description NVARCHAR (255),
@Embedded BIT,
@LastModified DATETIME,
@LastModifiedBy NVARCHAR (255),
@StaticGroupId INT = NULL,
@ExtraProperties NVARCHAR (MAX),
@errorNumber INT OUTPUT,
@errorMessage NVARCHAR (255) OUTPUT
AS
BEGIN
SET NOCOUNT ON;
SET @errorNumber=0
SET @errorMessage=''
UPDATE [dbo].[Groups] SET [SerialNumber]=@SerialNumber, [Picture]=@Picture, [DisplayName]=@DisplayName, [LastModified]=@LastModified, [LastModifiedBy]=@LastModifiedBy, [Embedded]=@Embedded, [Description]=@Description, [StaticGroupId]=@StaticGroupId, [ExtraProperties]=@ExtraProperties WHERE [Id]=@Id
if(@@error != 0)
begin
set @errorNumber = error_number()
set @errorMessage = error_message()
end
END

View File

@@ -0,0 +1,54 @@
ALTER PROCEDURE [dbo].[sp_GroupsUpdateInsert]
@SerialNumber nvarchar(255) = null
,@Picture NVARCHAR(255) = null
,@DisplayName nvarchar(255)
,@Description nvarchar(255)
,@Embedded bit
,@LastModified datetime
,@LastModifiedBy nvarchar(50)
,@StaticGroupId int = NULL
,@ExtraProperties nvarchar(max)
,@new_id int output
,@errorNumber int output
,@errorMessage nvarchar(250) output
AS
BEGIN
set @errorNumber = 0; set @errorMessage = space(0);
declare @GroupId int
set @GroupId = dbo.foo_IdGetGroup(@SerialNumber)
--declare @TemplateId int
--set @TemplateId = dbo.foo_IdGetTemplate(@Template)
if(exists(select Id from [dbo].[Groups] where Id = @GroupId))
begin
set @new_id = @GroupId;
exec dbo.sp_GroupsUpdate @GroupId
,@SerialNumber
,@Picture
,@DisplayName
,@Description
,@Embedded
,@LastModified
,@LastModifiedBy
,@StaticGroupId
,@ExtraProperties
,@errorNumber output, @errorMessage output
end
else
begin
exec dbo.sp_GroupsInsert @SerialNumber
,@Picture
,@DisplayName
,@Embedded
,@Description
,@LastModified
,@LastModifiedBy
,@StaticGroupId
,@ExtraProperties
,@errorNumber output, @errorMessage output, @new_id output
end
END

View File

@@ -0,0 +1,54 @@
ALTER PROCEDURE [dbo].[sp_GroupsUpdateInsert]
@SerialNumber nvarchar(255) = null
,@Picture NVARCHAR(255) = null
,@DisplayName nvarchar(255)
,@Description nvarchar(255)
,@Embedded bit
,@LastModified datetime
,@LastModifiedBy nvarchar(50)
,@StaticGroupId int = NULL
,@ExtraProperties nvarchar(max)
,@new_id int output
,@errorNumber int output
,@errorMessage nvarchar(250) output
AS
BEGIN
set @errorNumber = 0; set @errorMessage = space(0);
declare @GroupId int
set @GroupId = dbo.foo_IdGetGroup(@SerialNumber)
--declare @TemplateId int
--set @TemplateId = dbo.foo_IdGetTemplate(@Template)
if(exists(select Id from [dbo].[Groups] where Id = @GroupId))
begin
set @new_id = @GroupId;
exec dbo.sp_GroupsUpdate @GroupId
,@SerialNumber
,@Picture
,@DisplayName
,@Description
,@Embedded
,@LastModified
,@LastModifiedBy
,@StaticGroupId
,@ExtraProperties
,@errorNumber output, @errorMessage output
end
else
begin
exec dbo.sp_GroupsInsert @SerialNumber
,@Picture
,@DisplayName
,@Embedded
,@Description
,@LastModified
,@LastModifiedBy
,@StaticGroupId
,@ExtraProperties
,@errorNumber output, @errorMessage output, @new_id output
end
END

View File

@@ -0,0 +1,22 @@
ALTER PROCEDURE [dbo].[sp_SensorCalibrationsGet]
@Id INT = NULL,
@SerialNumber NVARCHAR (50) = NULL
AS
BEGIN
SET NOCOUNT ON;
IF( @Id IS NULL)
BEGIN
IF NULLIF(@SerialNumber, '') IS NULL
BEGIN
SELECT A.SensorCalibrationId, B.SerialNumber, A.CalibrationDate, A.Username, A.LocalOnly, A.NonLinear, A.CalibrationRecords, A.ModifyDate, A.IsProportional, A.RemoveOffset, A.ZeroMethod, A.CertificationDocuments, A.InitialOffset FROM [dbo].SensorCalibrations as A INNER JOIN [dbo].Sensors AS B on A.SensorId=B.id
END
ELSE
BEGIN
SELECT A.SensorCalibrationId, B.SerialNumber, A.CalibrationDate, A.Username, A.LocalOnly, A.NonLinear, A.CalibrationRecords, A.ModifyDate, A.IsProportional, A.RemoveOffset, A.ZeroMethod, A.CertificationDocuments, A.InitialOffset FROM [dbo].SensorCalibrations as A INNER JOIN [dbo].Sensors AS B on A.SensorId=B.id WHERE B.SerialNumber=@SerialNumber
END
END
ELSE
BEGIN
SELECT A.SensorCalibrationId, B.SerialNumber, A.CalibrationDate, A.Username, A.LocalOnly, A.NonLinear, A.CalibrationRecords, A.ModifyDate, A.IsProportional, A.RemoveOffset, A.ZeroMethod, A.CertificationDocuments, A.InitialOffset FROM [dbo].SensorCalibrations as A INNER JOIN [dbo].Sensors AS B on A.SensorId=B.id WHERE B.id=@Id
END
END

View File

@@ -0,0 +1,86 @@
ALTER PROCEDURE [dbo].[sp_SensorCalibrationsInsert]
@Id INT = NULL,
@SensorSerialNumber NVARCHAR (50) = NULL,
@SensorType TinyInt = NULL,
@CalibrationDate DATETIME,
@Username NVARCHAR (50),
@LocalOnly BIT,
@NonLinear BIT,
@ModifyDate DATETIME,
@IsProportional BIT,
@RemoveOffset BIT,
@ZeroMethod NVARCHAR (255),
@CertificationDocuments NVARCHAR (2048),
@InitialOffset NVARCHAR (MAX),
@CalibrationRecords NVARCHAR (255),
@SetLatestCalibrationId BIT,
@new_id INT OUTPUT,
@errorNumber INT OUTPUT,
@errorMessage NVARCHAR (255) OUTPUT
AS
BEGIN
SET @errorNumber = 0
SET @errorMessage = space(0)
DECLARE @SensorId AS INT
SET @SensorId = @Id
IF( @Id IS NULL)
BEGIN
SELECT @SensorId = [Id] FROM [dbo].[Sensors] WHERE [SensorType]=@SensorType AND [SerialNumber]=@SensorSerialNumber
END
IF( @SensorId IS NULL)
BEGIN
SET @errorNumber=1
SET @errorMessage='Sensor not found'
END
ELSE
BEGIN
DECLARE @CalibrationTypeId AS INT
SET @CalibrationTypeId = [dbo].[foo_IdGetCalibrationType](@NonLinear, @CalibrationRecords)
INSERT INTO [dbo].[SensorCalibrations] (
[SensorId],
[CalibrationDate],
[Username],
[LocalOnly],
[NonLinear],
[CalibrationTypeId],
[CalibrationRecords],
[ModifyDate],
[IsProportional],
[RemoveOffset],
[ZeroMethod],
[CertificationDocuments],
[InitialOffset])
VALUES (
@SensorId,
@CalibrationDate,
@Username,
@LocalOnly,
@NonLinear,
@CalibrationTypeId,
@CalibrationRecords,
@ModifyDate,
@IsProportional,
@RemoveOffset,
@ZeroMethod,
@CertificationDocuments,
@InitialOffset)
SET @new_id = SCOPE_IDENTITY()
IF (@SetLatestCalibrationId = 1 )
BEGIN
UPDATE [dbo].[SensorsAnalog] SET [LatestCalibrationId]=@new_id WHERE [SensorId]=@SensorId
END
--IF(@CalibrationRecords != space(0) AND @SensorId !=0 AND @CalibrationTypeId != 0 AND @new_id !=0 )
--BEGIN
-- EXEC [dbo].[sp_SensorCalibrationRecordProsess] @SensorId, @new_id, @CalibrationTypeId, @CalibrationRecords, @errorNumber output, @errorMessage output
--END
IF(@@error!=0)
BEGIN
SET @errorNumber = error_number()
SET @errorMessage = error_message()
END
END
END

View File

@@ -0,0 +1,31 @@
ALTER PROCEDURE [dbo].[sp_SensorsAnalogGet]
@Id INT = NULL,
@SerialNumber NVARCHAR (50) = NULL,
@EID NVARCHAR (50) = NULL
AS
BEGIN
SET NOCOUNT ON;
IF( @Id IS NULL)
BEGIN
IF NULLIF(@SerialNumber, '') IS NULL
BEGIN
IF( @EID IS NULL)
BEGIN
SELECT A.id, A.SerialNumber, C.AxisNumber, C.BridgeLegMode, C.BridgeResistance, C.BridgeType, C.Broken, C.BypassFilter, C.CalibrationSignal, C.CalInterval, C.Capacity, C.CheckOffset, C.Comment, C.CouplingMode, C.Created, C.DiagnosticsMode, C.DoNotUse, C.eId, C.ExternalShuntResistance, C.FilterClass, C.InitialEU, C.InternalShuntResistance, C.Invert, C.IsoChannelName, C.IsoCode, C.LastModified, C.LocalOnly, C.Manufacturer, C.MeasurementUnit, C.Model, C.ModifiedBy, C.NumberOfAxes, C.OffsetToleranceHigh, C.OffsetToleranceLow, C.RangeAve, C.RangeHigh, C.RangeLow, C.SensorCategory, C.SensorModelId, C.Shunt, C.[Status], C.SupportedExcitation, C.TimesUsed, C.UniPolar, C.UserChannelName, C.UserCode, C.UserSerialNumber, C.UserTags, C.UserValue1, C.UserValue2, C.UserValue3, C.[Version], C.LatestCalibrationId, C.FirstUseDate FROM [dbo].[Sensors] as A INNER JOIN [dbo].[SensorsType] as B ON A.SensorType=B.TypeId INNER JOIN [dbo].[SensorsAnalog] AS C on A.Id = C.SensorId WHERE B.SensorType='Analog'
END
ELSE
BEGIN
SELECT A.id, A.SerialNumber, C.AxisNumber, C.BridgeLegMode, C.BridgeResistance, C.BridgeType, C.Broken, C.BypassFilter, C.CalibrationSignal, C.CalInterval, C.Capacity, C.CheckOffset, C.Comment, C.CouplingMode, C.Created, C.DiagnosticsMode, C.DoNotUse, C.eId, C.ExternalShuntResistance, C.FilterClass, C.InitialEU, C.InternalShuntResistance, C.Invert, C.IsoChannelName, C.IsoCode, C.LastModified, C.LocalOnly, C.Manufacturer, C.MeasurementUnit, C.Model, C.ModifiedBy, C.NumberOfAxes, C.OffsetToleranceHigh, C.OffsetToleranceLow, C.RangeAve, C.RangeHigh, C.RangeLow, C.SensorCategory, C.SensorModelId, C.Shunt, C.[Status], C.SupportedExcitation, C.TimesUsed, C.UniPolar, C.UserChannelName, C.UserCode, C.UserSerialNumber, C.UserTags, C.UserValue1, C.UserValue2, C.UserValue3, C.[Version], C.LatestCalibrationId, C.FirstUseDate FROM [dbo].[Sensors] as A INNER JOIN [dbo].[SensorsType] as B ON A.SensorType=B.TypeId INNER JOIN [dbo].[SensorsAnalog] AS C on A.Id = C.SensorId WHERE B.SensorType='Analog' AND C.eId=@EID
END
END
ELSE
BEGIN
SELECT A.id, A.SerialNumber, C.AxisNumber, C.BridgeLegMode, C.BridgeResistance, C.BridgeType, C.Broken, C.BypassFilter, C.CalibrationSignal, C.CalInterval, C.Capacity, C.CheckOffset, C.Comment, C.CouplingMode, C.Created, C.DiagnosticsMode, C.DoNotUse, C.eId, C.ExternalShuntResistance, C.FilterClass, C.InitialEU, C.InternalShuntResistance, C.Invert, C.IsoChannelName, C.IsoCode, C.LastModified, C.LocalOnly, C.Manufacturer, C.MeasurementUnit, C.Model, C.ModifiedBy, C.NumberOfAxes, C.OffsetToleranceHigh, C.OffsetToleranceLow, C.RangeAve, C.RangeHigh, C.RangeLow, C.SensorCategory, C.SensorModelId, C.Shunt, C.[Status], C.SupportedExcitation, C.TimesUsed, C.UniPolar, C.UserChannelName, C.UserCode, C.UserSerialNumber, C.UserTags, C.UserValue1, C.UserValue2, C.UserValue3, C.[Version], C.LatestCalibrationId, C.FirstUseDate FROM [dbo].[Sensors] as A INNER JOIN [dbo].[SensorsType] as B ON A.SensorType=B.TypeId INNER JOIN [dbo].[SensorsAnalog] AS C on A.Id = C.SensorId WHERE B.SensorType='Analog' AND A.SerialNumber=@SerialNumber
END
END
ELSE
BEGIN
SELECT A.id, A.SerialNumber, C.AxisNumber, C.BridgeLegMode, C.BridgeResistance, C.BridgeType, C.Broken, C.BypassFilter, C.CalibrationSignal, C.CalInterval, C.Capacity, C.CheckOffset, C.Comment, C.CouplingMode, C.Created, C.DiagnosticsMode, C.DoNotUse, C.eId, C.ExternalShuntResistance, C.FilterClass, C.InitialEU, C.InternalShuntResistance, C.Invert, C.IsoChannelName, C.IsoCode, C.LastModified, C.LocalOnly, C.Manufacturer, C.MeasurementUnit, C.Model, C.ModifiedBy, C.NumberOfAxes, C.OffsetToleranceHigh, C.OffsetToleranceLow, C.RangeAve, C.RangeHigh, C.RangeLow, C.SensorCategory, C.SensorModelId, C.Shunt, C.[Status], C.SupportedExcitation, C.TimesUsed, C.UniPolar, C.UserChannelName, C.UserCode, C.UserSerialNumber, C.UserTags, C.UserValue1, C.UserValue2, C.UserValue3, C.[Version], C.LatestCalibrationId, C.FirstUseDate FROM [dbo].[Sensors] as A INNER JOIN [dbo].[SensorsType] as B ON A.SensorType=B.TypeId INNER JOIN [dbo].[SensorsAnalog] AS C on A.Id = C.SensorId WHERE B.SensorType='Analog' AND A.id=@id
END
END

View File

@@ -0,0 +1,188 @@
ALTER PROCEDURE [dbo].[sp_SensorsAnalogInsert]
@UserSerialNumber NVARCHAR (50),
@Model NVARCHAR (50),
@SensorModelId INT,
@Manufacturer NVARCHAR (50),
@Status NVARCHAR (50),
@MeasurementUnit NVARCHAR (50),
@OffsetToleranceLow FLOAT,
@OffsetToleranceHigh FLOAT,
@eId NVARCHAR (50),
@Capacity FLOAT,
@Comment NVARCHAR (50),
@BridgeType SMALLINT,
@BridgeLegMode SMALLINT,
@Shunt SMALLINT,
@Invert BIT,
@UserValue1 NVARCHAR (50),
@UserValue2 NVARCHAR (50),
@UserValue3 NVARCHAR (50),
@FilterClass NVARCHAR (50),
@BridgeResistance FLOAT,
@IsoCode NVARCHAR (50),
@IsoChannelName NVARCHAR (255),
@UserCode NVARCHAR (50),
@UserChannelName NVARCHAR (255),
@CheckOffset BIT,
@SupportedExcitation NVARCHAR (50),
@InitialEU FLOAT,
@CalInterval INT,
@CalibrationSignal BIT,
@InternalShuntResistance FLOAT,
@ExternalShuntResistance FLOAT,
@UniPolar BIT,
@RangeLow FLOAT,
@RangeAve FLOAT,
@RangeHigh FLOAT,
@Created DATETIME,
@TimesUsed BIGINT,
@SensorCategory INT,
@BypassFilter BIT,
@CouplingMode SMALLINT,
@Version INT,
@LastModified DATETIME,
@ModifiedBy NVARCHAR (50),
@LocalOnly BIT,
@AxisNumber SMALLINT,
@NumberOfAxes SMALLINT,
@UserTags VARBINARY (MAX),
@DoNotUse BIT,
@Broken BIT,
@DiagnosticsMode BIT,
@SerialNumber NVARCHAR (255),
@FirstUseDate DATETIME NULL,
@LatestCalibrationId INT NULL,
@errorNumber INT OUTPUT,
@errorMessage NVARCHAR (255) OUTPUT,
@new_id INT OUTPUT
AS
BEGIN
SET NOCOUNT ON
SET @errorNumber = 0
SET @errorMessage = ''
DECLARE @SensorType AS TINYINT
DECLARE @SensorId AS INT
SELECT @SensorType = [TypeId] FROM [dbo].[SensorsType] WHERE [SensorType]='Analog'
INSERT INTO [dbo].[Sensors] (SensorType, SerialNumber) VALUES (@SensorType, @SerialNumber)
SELECT @SensorId = SCOPE_IDENTITY()
INSERT INTO [dbo].[SensorsAnalog] (
[SensorId],
[UserSerialNumber],
[Model],
[SensorModelId],
[Manufacturer],
[Status],
[MeasurementUnit],
[OffsetToleranceLow],
[OffsetToleranceHigh],
[eId],
[Capacity],
[Comment],
[BridgeType],
[BridgeLegMode],
[Shunt],
[Invert],
[UserValue1],
[UserValue2],
[UserValue3],
[FilterClass],
[BridgeResistance],
[IsoCode],
[IsoChannelName],
[UserCode],
[UserChannelName],
[CheckOffset],
[SupportedExcitation],
[InitialEU],
[CalInterval],
[CalibrationSignal],
[InternalShuntResistance],
[ExternalShuntResistance],
[UniPolar],
[RangeLow],
[RangeAve],
[RangeHigh],
[Created],
[TimesUsed],
[SensorCategory],
[BypassFilter],
[CouplingMode],
[Version],
[LastModified],
[ModifiedBy],
[LocalOnly],
[AxisNumber],
[NumberOfAxes],
[UserTags],
[DoNotUse],
[Broken],
[DiagnosticsMode],
[FirstUseDate],
[LatestCalibrationId])
VALUES (
@SensorId,
@UserSerialNumber,
@Model,
@SensorModelId,
@Manufacturer,
@Status,
@MeasurementUnit,
@OffsetToleranceLow,
@OffsetToleranceHigh,
@eId,
@Capacity,
@Comment,
@BridgeType,
@BridgeLegMode,
@Shunt,
@Invert,
@UserValue1,
@UserValue2,
@UserValue3,
@FilterClass,
@BridgeResistance,
@IsoCode,
@IsoChannelName,
@UserCode,
@UserChannelName,
@CheckOffset,
@SupportedExcitation,
@InitialEU,
@CalInterval,
@CalibrationSignal,
@InternalShuntResistance,
@ExternalShuntResistance,
@UniPolar,
@RangeLow,
@RangeAve,
@RangeHigh,
@Created,
@TimesUsed,
@SensorCategory,
@BypassFilter,
@CouplingMode,
@Version,
@LastModified,
@ModifiedBy,
@LocalOnly,
@AxisNumber,
@NumberOfAxes,
@UserTags,
@DoNotUse,
@Broken,
@DiagnosticsMode,
@FirstUseDate,
@LatestCalibrationId)
if(@@error != 0)
begin
set @errorNumber = error_number()
set @errorMessage = error_message()
end
SET @new_id = @SensorId
END

View File

@@ -0,0 +1,258 @@
ALTER PROCEDURE [dbo].[sp_SensorsAnalogUpdateInsert]
@UserSerialNumber NVARCHAR (50),
@Model NVARCHAR (50),
@SensorModelId INT,
@Manufacturer NVARCHAR (50),
@Status NVARCHAR (50),
@MeasurementUnit NVARCHAR (50),
@OffsetToleranceLow FLOAT,
@OffsetToleranceHigh FLOAT,
@eId NVARCHAR (50),
@Capacity FLOAT,
@Comment NVARCHAR (50),
@BridgeType SMALLINT,
@BridgeLegMode SMALLINT,
@Shunt SMALLINT,
@Invert BIT,
@UserValue1 NVARCHAR (50),
@UserValue2 NVARCHAR (50),
@UserValue3 NVARCHAR (50),
@FilterClass NVARCHAR (50),
@BridgeResistance FLOAT,
@IsoCode NVARCHAR (50),
@IsoChannelName NVARCHAR (255),
@UserCode NVARCHAR (50),
@UserChannelName NVARCHAR (255),
@CheckOffset BIT,
@SupportedExcitation NVARCHAR (50),
@InitialEU FLOAT,
@CalInterval INT,
@CalibrationSignal BIT,
@InternalShuntResistance FLOAT,
@ExternalShuntResistance FLOAT,
@UniPolar BIT,
@RangeLow FLOAT,
@RangeAve FLOAT,
@RangeHigh FLOAT,
@Created DATETIME,
@TimesUsed BIGINT,
@SensorCategory INT,
@BypassFilter BIT,
@CouplingMode SMALLINT,
@Version INT,
@LastModified DATETIME,
@ModifiedBy NVARCHAR (50),
@LocalOnly BIT,
@AxisNumber SMALLINT,
@NumberOfAxes SMALLINT,
@UserTags VARBINARY (MAX),
@DoNotUse BIT,
@Broken BIT,
@DiagnosticsMode BIT,
@SerialNumber NVARCHAR (255),
@FirstUseDate DateTime NULL,
@LatestCalibrationId INT NULL,
@new_id INT OUTPUT,
@errorNumber INT OUTPUT,
@errorMessage NVARCHAR (255) OUTPUT
AS
BEGIN
BEGIN TRY
SET NOCOUNT ON
SET @errorNumber = 0
SET @errorMessage = ''
DECLARE @SensorType AS TINYINT
DECLARE @SensorId AS INT
DECLARE @MaxCalIntervalDays AS INT
-- FB14622 Maximum allowed interval days. When updating this value please update the _maxCalIntervalDays variable in SensitivityControl.xaml.cs
SET @MaxCalIntervalDays = 365 * 10
SELECT @SensorType = [TypeId] FROM [dbo].[SensorsType] WHERE [SensorType]='Analog'
SELECT @SensorId = A.[Id] from [dbo].[Sensors] AS A INNER JOIN [dbo].SensorsType AS B ON A.SensorType=B.TypeId WHERE B.SensorType='Analog' AND A.SerialNumber=@SerialNumber
-- FB14622 Validate the range of calibration intervals
IF(@CalInterval > @MaxCalIntervalDays OR @CalInterval <= 0 )
BEGIN
RAISERROR ('Invalid calibration inteval',16,1)
END
IF( @SensorId IS NULL)
BEGIN
INSERT INTO [dbo].[Sensors] (SensorType, SerialNumber) VALUES (@SensorType, @SerialNumber)
SELECT @SensorId = SCOPE_IDENTITY()
SET @new_id = @SensorId
INSERT INTO [dbo].[SensorsAnalog] (
[SensorId],
[UserSerialNumber],
[Model],
[SensorModelId],
[Manufacturer],
[Status],
[MeasurementUnit],
[OffsetToleranceLow],
[OffsetToleranceHigh],
[eId],
[Capacity],
[Comment],
[BridgeType],
[BridgeLegMode],
[Shunt],
[Invert],
[UserValue1],
[UserValue2],
[UserValue3],
[FilterClass],
[BridgeResistance],
[IsoCode],
[IsoChannelName],
[UserCode],
[UserChannelName],
[CheckOffset],
[SupportedExcitation],
[InitialEU],
[CalInterval],
[CalibrationSignal],
[InternalShuntResistance],
[ExternalShuntResistance],
[UniPolar],
[RangeLow],
[RangeAve],
[RangeHigh],
[Created],
[TimesUsed],
[SensorCategory],
[BypassFilter],
[CouplingMode],
[Version],
[LastModified],
[ModifiedBy],
[LocalOnly],
[AxisNumber],
[NumberOfAxes],
[UserTags],
[DoNotUse],
[Broken],
[DiagnosticsMode],
[FirstUseDate],
[LatestCalibrationId])
VALUES (
@SensorId,
@UserSerialNumber,
@Model,
@SensorModelId,
@Manufacturer,
@Status,
@MeasurementUnit,
@OffsetToleranceLow,
@OffsetToleranceHigh,
@eId,
@Capacity,
@Comment,
@BridgeType,
@BridgeLegMode,
@Shunt,
@Invert,
@UserValue1,
@UserValue2,
@UserValue3,
@FilterClass,
@BridgeResistance,
@IsoCode,
@IsoChannelName,
@UserCode,
@UserChannelName,
@CheckOffset,
@SupportedExcitation,
@InitialEU,
@CalInterval,
@CalibrationSignal,
@InternalShuntResistance,
@ExternalShuntResistance,
@UniPolar,
@RangeLow,
@RangeAve,
@RangeHigh,
@Created,
@TimesUsed,
@SensorCategory,
@BypassFilter,
@CouplingMode,
@Version,
@LastModified,
@ModifiedBy,
@LocalOnly,
@AxisNumber,
@NumberOfAxes,
@UserTags,
@DoNotUse,
@Broken,
@DiagnosticsMode,
@FirstUseDate,
@LatestCalibrationId)
END
ELSE
BEGIN
SET @new_id = @SensorId
UPDATE [dbo].[SensorsAnalog] SET
[SensorId] = @SensorId,
[UserSerialNumber] = @UserSerialNumber,
[Model] = @Model,
[SensorModelId] = @SensorModelId,
[Manufacturer] = @Manufacturer,
[Status] = @Status,
[MeasurementUnit] = @MeasurementUnit,
[OffsetToleranceLow] = @OffsetToleranceLow,
[OffsetToleranceHigh] = @OffsetToleranceHigh,
[eId] = @eId,
[Capacity] = @Capacity,
[Comment] = @Comment,
[BridgeType] = @BridgeType,
[BridgeLegMode] = @BridgeLegMode,
[Shunt] = @Shunt,
[Invert] = @Invert,
[UserValue1] = @UserValue1,
[UserValue2] = @UserValue2,
[UserValue3] = @UserValue3,
[FilterClass] = @FilterClass,
[BridgeResistance] = @BridgeResistance,
[IsoCode] = @IsoCode,
[IsoChannelName] = @IsoChannelName,
[UserCode] = @UserCode,
[UserChannelName] = @UserChannelName,
[CheckOffset] = @CheckOffset,
[SupportedExcitation] = @SupportedExcitation,
[InitialEU] = @InitialEU,
[CalInterval] = @CalInterval,
[CalibrationSignal] = @CalibrationSignal,
[InternalShuntResistance] = @InternalShuntResistance,
[ExternalShuntResistance] = @ExternalShuntResistance,
[UniPolar] = @UniPolar,
[RangeLow] = @RangeLow,
[RangeAve] = @RangeAve,
[RangeHigh] = @RangeHigh,
[Created] = @Created,
[TimesUsed] = @TimesUsed,
[SensorCategory] = @SensorCategory,
[BypassFilter] = @BypassFilter,
[CouplingMode] = @CouplingMode,
[Version] = @Version,
[LastModified] = @LastModified,
[ModifiedBy] = @ModifiedBy,
[LocalOnly] = @LocalOnly,
[AxisNumber] = @AxisNumber,
[NumberOfAxes] = @NumberOfAxes,
[UserTags] = @UserTags,
[DoNotUse] = @DoNotUse,
[Broken] = @Broken,
[DiagnosticsMode] = @DiagnosticsMode,
[FirstUseDate] = @FirstUseDate,
[LatestCalibrationId] = @LatestCalibrationId WHERE [SensorId]=@SensorId
END
END TRY
BEGIN CATCH
SET @errorNumber = error_number()
SET @errorMessage = error_message()
END CATCH
END

View File

@@ -0,0 +1,123 @@
ALTER PROCEDURE [dbo].[sp_SensorsAnalogUpdate]
@Id INT,
@UserSerialNumber NVARCHAR (50),
@Model NVARCHAR (50),
@SensorModelId INT,
@Manufacturer NVARCHAR (50),
@Status NVARCHAR (50),
@MeasurementUnit NVARCHAR (50),
@OffsetToleranceLow FLOAT,
@OffsetToleranceHigh FLOAT,
@eId NVARCHAR (50),
@Capacity FLOAT,
@Comment NVARCHAR (50),
@BridgeType SMALLINT,
@BridgeLegMode SMALLINT,
@Shunt SMALLINT,
@Invert BIT,
@UserValue1 NVARCHAR (50),
@UserValue2 NVARCHAR (50),
@UserValue3 NVARCHAR (50),
@FilterClass NVARCHAR (50),
@BridgeResistance FLOAT,
@IsoCode NVARCHAR (50),
@IsoChannelName NVARCHAR (255),
@UserCode NVARCHAR (50),
@UserChannelName NVARCHAR (255),
@CheckOffset BIT,
@SupportedExcitation NVARCHAR (50),
@InitialEU FLOAT,
@CalInterval INT,
@CalibrationSignal BIT,
@InternalShuntResistance FLOAT,
@ExternalShuntResistance FLOAT,
@UniPolar BIT,
@RangeLow FLOAT,
@RangeAve FLOAT,
@RangeHigh FLOAT,
@Created DATETIME,
@TimesUsed BIGINT,
@SensorCategory INT,
@BypassFilter BIT,
@CouplingMode SMALLINT,
@Version INT,
@LastModified DATETIME,
@ModifiedBy NVARCHAR (50),
@LocalOnly BIT,
@AxisNumber SMALLINT,
@NumberOfAxes SMALLINT,
@UserTags VARBINARY (MAX),
@DoNotUse BIT,
@Broken BIT,
@DiagnosticsMode BIT,
@FirstUseDate DATETIME NULL,
@LatestCalibrationId INT NULL,
@SerialNumber NVARCHAR (255),
@errorNumber INT OUTPUT,
@errorMessage NVARCHAR (255) OUTPUT
AS
BEGIN
SET NOCOUNT ON
SET @errorNumber = 0
SET @errorMessage = ''
UPDATE [dbo].[SensorsAnalog] SET
[UserSerialNumber] = @UserSerialNumber,
[Model] = @Model,
[SensorModelId] = @SensorModelId,
[Manufacturer] = @Manufacturer,
[Status] = @Status,
[MeasurementUnit] = @MeasurementUnit,
[OffsetToleranceLow] = @OffsetToleranceLow,
[OffsetToleranceHigh] = @OffsetToleranceHigh,
[eId] = @eId,
[Capacity] = @Capacity,
[Comment] = @Comment,
[BridgeType] = @BridgeType,
[BridgeLegMode] = @BridgeLegMode,
[Shunt] = @Shunt,
[Invert] = @Invert,
[UserValue1] = @UserValue1,
[UserValue2] = @UserValue2,
[UserValue3] = @UserValue3,
[FilterClass] = @FilterClass,
[BridgeResistance] = @BridgeResistance,
[IsoCode] = @IsoCode,
[IsoChannelName] = @IsoChannelName,
[UserCode] = @UserCode,
[UserChannelName] = @UserChannelName,
[CheckOffset] = @CheckOffset,
[SupportedExcitation] = @SupportedExcitation,
[InitialEU] = @InitialEU,
[CalInterval] = @CalInterval,
[CalibrationSignal] = @CalibrationSignal,
[InternalShuntResistance] = @InternalShuntResistance,
[ExternalShuntResistance] = @ExternalShuntResistance,
[UniPolar] = @UniPolar,
[RangeLow] = @RangeLow,
[RangeAve] = @RangeAve,
[RangeHigh] = @RangeHigh,
[Created] = @Created,
[TimesUsed] = @TimesUsed,
[SensorCategory] = @SensorCategory,
[BypassFilter] = @BypassFilter,
[CouplingMode] = @CouplingMode,
[Version] = @Version,
[LastModified] = @LastModified,
[ModifiedBy] = @ModifiedBy,
[LocalOnly] = @LocalOnly,
[AxisNumber] = @AxisNumber,
[NumberOfAxes] = @NumberOfAxes,
[UserTags] = @UserTags,
[DoNotUse] = @DoNotUse,
[Broken] = @Broken,
[DiagnosticsMode] = @DiagnosticsMode,
[FirstUseDate] = @FirstUseDate,
[LatestCalibrationId] = @LatestCalibrationId WHERE [Id]=@Id
if(@@error != 0)
begin
set @errorNumber = error_number()
set @errorMessage = error_message()
end
END

View File

@@ -0,0 +1,7 @@
ALTER PROCEDURE [dbo].[sp_TestSetupHardwareGet]
@TestSetupId INT
AS
BEGIN
SET NOCOUNT ON;
SELECT TestSetupHardwareId, DASId, TestSetupId, AddOrRemove, SamplesPerSecond, IsClockMaster, AntiAliasFilterRate FROM [dbo].TestSetupHardware WHERE [TestSetupId]=@TestSetupId
END

View File

@@ -0,0 +1,22 @@
ALTER PROCEDURE [dbo].[sp_TestSetupHardwareInsert]
@DASId INT,
@TestSetupId INT,
@AddOrRemove BIT,
@SamplesPerSecond FLOAT,
@IsClockMaster BIT,
@AntiAliasFilterRate FLOAT,
@errorNumber INT OUTPUT,
@errorMessage NVARCHAR(255) OUTPUT
AS
BEGIN
SET @errorNumber = 0;
SET @errorMessage = space(0);
INSERT INTO [dbo].[TestSetupHardware] ([DASId], [TestSetupId], [AddOrRemove], [SamplesPerSecond], [IsClockMaster], [AntiAliasFilterRate]) VALUES (@DASId, @TestSetupId, @AddOrRemove, @SamplesPerSecond, @IsClockMaster, @AntiAliasFilterRate)
IF(@@error != 0)
BEGIN
SET @errorNumber = ERROR_NUMBER()
SET @errorMessage = ERROR_MESSAGE()
END
END

View File

@@ -0,0 +1,22 @@
ALTER PROCEDURE [dbo].[sp_TestSetupHardwareUpdate]
@DASId INT,
@TestSetupId INT,
@AddOrRemove BIT,
@SamplesPerSecond FLOAT,
@IsClockMaster BIT,
@AntiAliasFilterRate FLOAT,
@errorNumber INT OUTPUT,
@errorMessage NVARCHAR(255) OUTPUT
AS
BEGIN
SET @errorNumber = 0;
SET @errorMessage = space(0);
UPDATE [dbo].[TestSetupHardware] SET [AddOrRemove]=@AddOrRemove, [SamplesPerSecond]=@SamplesPerSecond, [IsClockMaster]=@IsClockMaster, [AntiAliasFilterRate]=@AntiAliasFilterRate WHERE [DASId]=@DASId AND [TestSetupId]=@TestSetupId
IF(@@error != 0)
BEGIN
SET @errorNumber = ERROR_NUMBER()
SET @errorMessage = ERROR_MESSAGE()
END
END

View File

@@ -0,0 +1,54 @@
ALTER PROCEDURE [dbo].[sp_TestSetupsDelete]
@TestSetupId INT = 0,
@TestSetupName NVARCHAR(50) = NULL,
@errorNumber INT OUTPUT,
@errorMessage NVARCHAR(255) OUTPUT
AS
BEGIN
SET @errorNumber = 0;
SET @errorMessage = SPACE(0);
BEGIN TRY
BEGIN TRANSACTION [tDeleteTestSetups]
IF(@TestSetupId = 0)
BEGIN
SET @TestSetupId = [dbo].foo_IdGetTestSetup(@TestSetupName)
END
DELETE FROM [dbo].[TestSetupObjectMetaData] where TestSetupId = @TestSetupId
DELETE FROM [dbo].[TestSetupHardware] where TestSetupId = @TestSetupId
DELETE FROM [dbo].[LevelTriggers] where TestSetupId = @TestSetupId
DELETE FROM [dbo].[CalculatedChannels] where TestSetupId = @TestSetupId
DELETE FROM [dbo].[TestGraphs] where TestSetupId = @TestSetupId
/*Delete group channel settings*/
DELETE A FROM [dbo].[GroupChannelSettings] AS A INNER JOIN [dbo].[Channels] AS B ON A.ChannelId=B.Id
INNER JOIN [dbo].[Groups] AS C ON B.GroupId=C.Id INNER JOIN [dbo].TestSetupGroups AS D ON C.Id=D.GroupId WHERE D.TestSetupId=@TestSetupId
/*Delete group hardware*/
DELETE A FROM [dbo].[GroupHardware] AS A INNER JOIN [dbo].[TestSetupGroups] AS B ON A.GroupId=B.GroupId WHERE B.TestSetupId=@TestSetupId
/*Delete group channels*/
DELETE A FROM [dbo].[Channels] AS A INNER JOIN [dbo].[TestSetupGroups] AS B ON A.GroupId = B.GroupId WHERE B.TestSetupId=@TestSetupId
/*grab a copy of all groups associated with test so we can delete them*/
SELECT [GroupId] INTO #temptable FROM [dbo].[TestSetupGroups] WHERE [TestSetupId]=@TestSetupId
/*unassociate the group from the test setup*/
DELETE FROM [dbo].[TestSetupGroups] WHERE [TestSetupId] = @TestSetupId
/*delete the groups*/
DELETE FROM [dbo].[Groups] WHERE [Id] IN (SELECT [GroupId] FROM #tempTable)
/*delete test specific hardware */
UPDATE [dbo].[Channels] SET [DASId] = 0, [DASChannelIndex]=0 FROM [dbo].[Channels] AS A INNER JOIN [dbo].[DAS] AS B ON A.DASId=B.DASId WHERE B.TestId=@TestSetupId
DELETE A FROM [dbo].[TestSetupHardware] AS A INNER JOIN [dbo].[DAS] as B ON A.DASId=B.DASId WHERE B.TestId=@TestSetupId
DELETE A FROM [dbo].[GroupHardware] AS A INNER JOIN [dbo].[DAS] as B on A.DASId=B.DASId WHERE B.TestId=@TestSetupId
DELETE A FROM [dbo].[DASChannels] AS A INNER JOIN [dbo].[DAS] AS B on A.DASId=B.DASId WHERE B.TestId=@TestSetupId
DELETE [dbo].[DAS] WHERE [TestId]=@TestSetupId
/*finally delete the test setup*/
DELETE FROM [dbo].[TestSetups] where TestSetupId = @TestSetupId
COMMIT TRANSACTION [tDeleteTestSetups]
END TRY
BEGIN CATCH
SET @errorNumber = error_number()
SET @errorMessage = error_message()
ROLLBACK TRANSACTION [tDeleteTestSetups]
END CATCH
END

View File

@@ -0,0 +1,85 @@
ALTER PROCEDURE [dbo].[sp_TestSetupsGet]
@TestSetupId int = null,
@TestSetupName nvarchar(50) = null
AS
BEGIN
SET NOCOUNT ON;
if(@TestSetupName is not null)
begin
set @TestSetupId = dbo.foo_IdGetTestSetup(@TestSetupName)
end
SELECT [TestSetupId]
,[TestSetupName] as 'SetupName'
,[SetupDescription]
,[AutomaticTestProgression]
,[AutomaticProgressionDelayMS]
,[InvertTrigger]
,[InvertStart]
,[ViewDiagnostics]
,[VerifyChannels]
,[AutoVerifyChannels]
,[VerifyChannelsDelayMS]
,[RecordingMode]
,[SamplesPerSecond]
,[PreTriggerSeconds]
,[PostTriggerSeconds]
,[StrictDiagnostics]
,[RequireConfirmationOnErrors]
,[ROIDownload]
,[ViewROIDownload]
,[DownloadAll]
,[ViewRealtime]
,[RealtimePlotCount]
,[RegionsOfInterest]
,[ROIStart]
,[ROIEnd]
,[ViewDownloadAll]
,[Export]
,[ExportFormat]
,[LabDetails]
,[UseLabDetails]
,[CustomerDetails]
,[UseCustomerDetails]
,[AllowMissingSensors]
,[AllowSensorIdToBlankChannel]
,[CalibrationBehavior]
,[LocalOnly]
,[LastModified]
,[LastModifiedBy]
,[TurnOffExcitation]
,[TriggerCheckRealtime]
,[TriggerCheckStep]
,[PostTestDiagnostics]
,[ExportFolder]
,[DownloadFolder]
,[CommonStatusLine]
,[SameAsDownloadFolder]
,[UploadData]
,[UploadDataFolder]
,[UploadExportsOnly]
,[Settings]
,[WarnOnBatteryFail]
,[Dirty]
,[Complete]
,[ErrorMessage]
,[TestEngineerDetails]
,[UseTestEngineerDetails]
,[UserTags]
,isnull([DoAutoArm], 0) as [DoAutoArm]
,isnull([CheckoutMode], 0) as [CheckoutMode]
,isnull([ISFFile], 0) as [ISFFile]
,isnull([QuitTestWithoutWarning], 0) as [QuitTestWithoutWarning]
,isnull([NotAllChannelsRealTime], 0) as [NotAllChannelsRealTime]
,isnull([NotAllChannelsViewer], 0) as [NotAllChannelsViewer]
,isnull([SuppressMissingSensorsWarning], 0) as [SuppressMissingSensorsWarning]
,isnull([DoStreaming], 0) as [DoStreaming]
,[ClockSyncProfileMaster]
,[ClockSyncProfileSlave]
,[ExtraProperties]
,[TestSetup]
from [dbo].[TestSetups]
where ((@TestSetupId is null or @TestSetupId= 0) or TestSetupId = @TestSetupId)
and (@TestSetupName is null or TestSetupName = @TestSetupName);
END

View File

@@ -0,0 +1,264 @@
ALTER PROCEDURE [dbo].[sp_TestSetupsInsert]
@TestSetupName nvarchar(50) = Null
,@SetupDescription nvarchar(50)
,@AutomaticTestProgression bit
,@AutomaticProgressionDelayMS int
,@InvertTrigger bit
,@InvertStart bit
,@ViewDiagnostics bit
,@VerifyChannels bit
,@AutoVerifyChannels bit
,@VerifyChannelsDelayMS int
,@RecordingMode smallint
,@SamplesPerSecond float
,@PreTriggerSeconds float
,@PostTriggerSeconds float
,@StrictDiagnostics bit
,@RequireConfirmationOnErrors bit
,@ROIDownload bit
,@ViewROIDownload bit
,@DownloadAll bit
,@ViewRealtime bit
,@RealtimePlotCount smallint
,@RegionsOfInterest nvarchar(MAX)
,@ROIStart float
,@ROIEnd float
,@ViewDownloadAll bit
,@Export bit
,@ExportFormat bigint
,@LabDetails nvarchar(50)
,@UseLabDetails bit
,@CustomerDetails nvarchar(50)
,@UseCustomerDetails bit
,@AllowMissingSensors bit
,@AllowSensorIdToBlankChannel bit
,@CalibrationBehavior smallint
,@LocalOnly bit
,@LastModified datetime
,@LastModifiedBy nvarchar(50)
,@TurnOffExcitation bit
,@TriggerCheckRealtime bit
,@TriggerCheckStep bit
,@PostTestDiagnostics int
,@ExportFolder nvarchar(150)
,@DownloadFolder nvarchar(150)
,@CommonStatusLine bit
,@SameAsDownloadFolder bit
,@UploadData bit
,@UploadDataFolder nvarchar(150)
,@UploadExportsOnly bit
,@Settings nvarchar(4000)
,@WarnOnBatteryFail bit
,@Dirty bit
,@Complete bit
,@Error nvarchar(255)
,@TestEngineerDetails nvarchar(50)
,@UseTestEngineerDetails bit
,@UserTags varbinary(max)
,@DoAutoArm bit
,@CheckoutMode bit
,@ISFFile nvarchar(4000)
,@QuitTestWithoutWarning bit
,@NotAllChannelsRealTime bit
,@NotAllChannelsViewer bit
,@SuppressMissingSensorsWarning bit
,@DoStreaming bit
,@ClockSyncProfileMaster nvarchar(50)
,@ClockSyncProfileSlave nvarchar(50)
,@ExtraProperties nvarchar(max)
,@TestSetup varbinary(MAX)
,@new_id int output
,@errorNumber int output
,@errorMessage nvarchar(250) output
AS
BEGIN
set @errorNumber = 0; set @errorMessage = space(0);
/* Table (and stored procedure) is too big... */
begin try
if(@TestSetupName is null)
begin
set @errorMessage = 'An invalid parameter or option was specified for procedure'
set @errorNumber = 15600
end
else
begin
SET NOCOUNT ON;
declare @TestEngineerId int
declare @LabratoryId int
declare @CustomerId int
set @CustomerId = dbo.foo_IdGetCustomer(@CustomerDetails)
IF @CustomerId <= 0
BEGIN
SET @CustomerId = null
END
set @LabratoryId = dbo.foo_IdGetLabratory(@LabDetails)
IF @LabratoryId <= 0
BEGIN
SET @LabratoryId = null
END
set @TestEngineerId = dbo.foo_IdGetEngineer(@TestEngineerDetails);
IF @TestEngineerId <= 0
BEGIN
SET @TestEngineerId = null
END
insert into [dbo].[TestSetups]
([TestSetupName]
,[SetupDescription]
,[AutomaticTestProgression]
,[AutomaticProgressionDelayMS]
,[InvertTrigger]
,[InvertStart]
,[ViewDiagnostics]
,[VerifyChannels]
,[AutoVerifyChannels]
,[VerifyChannelsDelayMS]
,[RecordingMode]
,[SamplesPerSecond]
,[PreTriggerSeconds]
,[PostTriggerSeconds]
,[StrictDiagnostics]
,[RequireConfirmationOnErrors]
,[ROIDownload]
,[ViewROIDownload]
,[DownloadAll]
,[ViewRealtime]
,[RealtimePlotCount]
,[RegionsOfInterest]
,[ROIStart]
,[ROIEnd]
,[ViewDownloadAll]
,[Export]
,[ExportFormat]
,[CustomerId]
,[LabratoryId]
,[TestEngineerId]
,[LabDetails]
,[UseLabDetails]
,[CustomerDetails]
,[UseCustomerDetails]
,[TestEngineerDetails]
,[UseTestEngineerDetails]
,[AllowMissingSensors]
,[AllowSensorIdToBlankChannel]
,[CalibrationBehavior]
,[LocalOnly]
,[LastModified]
,[LastModifiedBy]
,[TurnOffExcitation]
,[TriggerCheckRealtime]
,[TriggerCheckStep]
,[PostTestDiagnostics]
,[ExportFolder]
,[DownloadFolder]
,[CommonStatusLine]
,[SameAsDownloadFolder]
,[UploadData]
,[UploadDataFolder]
,[UploadExportsOnly]
,[Settings]
,[WarnOnBatteryFail]
,[Dirty]
,[Complete]
,[ErrorMessage]
,[UserTags]
,[DoAutoArm]
,[CheckoutMode]
,[ISFFile]
,[QuitTestWithoutWarning]
,[NotAllChannelsRealTime]
,[NotAllChannelsViewer]
,[SuppressMissingSensorsWarning]
,[DoStreaming]
,[ClockSyncProfileMaster]
,[ClockSyncProfileSlave]
,[ExtraProperties]
,[TestSetup])
VALUES
( @TestSetupName
,@SetupDescription
,@AutomaticTestProgression
,@AutomaticProgressionDelayMS
,@InvertTrigger
,@InvertStart
,@ViewDiagnostics
,@VerifyChannels
,@AutoVerifyChannels
,@VerifyChannelsDelayMS
,@RecordingMode
,@SamplesPerSecond
,@PreTriggerSeconds
,@PostTriggerSeconds
,@StrictDiagnostics
,@RequireConfirmationOnErrors
,@ROIDownload
,@ViewROIDownload
,@DownloadAll
,@ViewRealtime
,@RealtimePlotCount
,@RegionsOfInterest
,@ROIStart
,@ROIEnd
,@ViewDownloadAll
,@Export
,@ExportFormat
,@CustomerId
,@LabratoryId
,@TestEngineerId
,@LabDetails
,@UseLabDetails
,@CustomerDetails
,@UseCustomerDetails
,@TestEngineerDetails
,@UseTestEngineerDetails
,@AllowMissingSensors
,@AllowSensorIdToBlankChannel
,@CalibrationBehavior
,@LocalOnly
,@LastModified
,@LastModifiedBy
,@TurnOffExcitation
,@TriggerCheckRealtime
,@TriggerCheckStep
,@PostTestDiagnostics
,@ExportFolder
,@DownloadFolder
,@CommonStatusLine
,@SameAsDownloadFolder
,@UploadData
,@UploadDataFolder
,@UploadExportsOnly
,@Settings
,@WarnOnBatteryFail
,@Dirty
,@Complete
,@Error
,@UserTags
,@DoAutoArm
,@CheckoutMode
,@ISFFile
,@QuitTestWithoutWarning
,@NotAllChannelsRealTime
,@NotAllChannelsViewer
,@SuppressMissingSensorsWarning
,@DoStreaming
,@ClockSyncProfileMaster
,@ClockSyncProfileSlave
,@ExtraProperties
,@TestSetup)
set @new_id = scope_identity()
end
end try
begin catch
set @errorMessage = error_message()
set @errorNumber = error_number()
end catch;
END

View File

@@ -0,0 +1,229 @@
ALTER PROCEDURE [dbo].[sp_TestSetupsInsertUpdate]
@TestSetupName nvarchar(50) = Null
,@SetupDescription nvarchar(50)
,@AutomaticTestProgression bit
,@AutomaticProgressionDelayMS int
,@InvertTrigger bit
,@InvertStart bit
,@ViewDiagnostics bit
,@VerifyChannels bit
,@AutoVerifyChannels bit
,@VerifyChannelsDelayMS int
,@RecordingMode smallint
,@SamplesPerSecond float
,@PreTriggerSeconds float
,@PostTriggerSeconds float
,@StrictDiagnostics bit
,@RequireConfirmationOnErrors bit
,@ROIDownload bit
,@ViewROIDownload bit
,@DownloadAll bit
,@ViewRealtime bit
,@RealtimePlotCount smallint
,@RegionsOfInterest nvarchar(MAX)
,@ROIStart float
,@ROIEnd float
,@ViewDownloadAll bit
,@Export bit
,@ExportFormat bigint
,@LabDetails nvarchar(50)
,@UseLabDetails bit
,@CustomerDetails nvarchar(50)
,@UseCustomerDetails bit
,@AllowMissingSensors bit
,@AllowSensorIdToBlankChannel bit
,@CalibrationBehavior smallint
,@LocalOnly bit
,@LastModified datetime
,@LastModifiedBy nvarchar(50)
,@TurnOffExcitation bit
,@TriggerCheckRealtime bit
,@TriggerCheckStep bit
,@PostTestDiagnostics int
,@ExportFolder nvarchar(150)
,@DownloadFolder nvarchar(150)
,@CommonStatusLine bit
,@SameAsDownloadFolder bit
,@UploadData bit
,@UploadDataFolder nvarchar(150)
,@UploadExportsOnly bit
,@Settings nvarchar(4000)
,@WarnOnBatteryFail bit
,@Dirty bit
,@Complete bit
,@Error nvarchar(255)
,@TestEngineerDetails nvarchar(50)
,@UseTestEngineerDetails bit
,@UserTags varbinary(max)
,@DoAutoArm bit
,@CheckoutMode bit
,@ISFFile nvarchar(4000)
,@QuitTestWithoutWarning bit
,@NotAllChannelsRealTime bit
,@NotAllChannelsViewer bit
,@SuppressMissingSensorsWarning bit
,@DoStreaming bit
,@ClockSyncProfileMaster nvarchar(50)
,@ClockSyncProfileSlave nvarchar(50)
,@ExtraProperties nvarchar(max)
,@TestSetup varbinary(MAX)
,@new_id int output
,@errorNumber int output
,@errorMessage nvarchar(250) output
AS
BEGIN
set @errorNumber = 0; set @errorMessage = space(0);
declare @TestSetupId int
set @TestSetupId = dbo.foo_IdGetTestSetup(@TestSetupName)
if(exists(select TestSetupId from [dbo].[TestSetups] where TestSetupId = @TestSetupId))
begin
set @new_id = @TestSetupId
exec dbo.sp_TestSetupsUpdate @TestSetupName
,@SetupDescription
,@AutomaticTestProgression
,@AutomaticProgressionDelayMS
,@InvertTrigger
,@InvertStart
,@ViewDiagnostics
,@VerifyChannels
,@AutoVerifyChannels
,@VerifyChannelsDelayMS
,@RecordingMode
,@SamplesPerSecond
,@PreTriggerSeconds
,@PostTriggerSeconds
,@StrictDiagnostics
,@RequireConfirmationOnErrors
,@ROIDownload
,@ViewROIDownload
,@DownloadAll
,@ViewRealtime
,@RealtimePlotCount
,@RegionsOfInterest
,@ROIStart
,@ROIEnd
,@ViewDownloadAll
,@Export
,@ExportFormat
,@LabDetails
,@UseLabDetails
,@CustomerDetails
,@UseCustomerDetails
,@AllowMissingSensors
,@AllowSensorIdToBlankChannel
,@CalibrationBehavior
,@LocalOnly
,@LastModified
,@LastModifiedBy
,@TurnOffExcitation
,@TriggerCheckRealtime
,@TriggerCheckStep
,@PostTestDiagnostics
,@ExportFolder
,@DownloadFolder
,@CommonStatusLine
,@SameAsDownloadFolder
,@UploadData
,@UploadDataFolder
,@UploadExportsOnly
,@Settings
,@WarnOnBatteryFail
,@Dirty
,@Complete
,@Error
,@TestEngineerDetails
,@UseTestEngineerDetails
,@UserTags
,@DoAutoArm
,@CheckoutMode
,@ISFFile
,@QuitTestWithoutWarning
,@NotAllChannelsRealTime
,@NotAllChannelsViewer
,@SuppressMissingSensorsWarning
,@DoStreaming
,@ClockSyncProfileMaster
,@ClockSyncProfileSlave
,@ExtraProperties
,@TestSetup
,@new_id output
,@errorNumber output
,@errorMessage output
end
else
begin
exec dbo.sp_TestSetupsInsert @TestSetupName
,@SetupDescription
,@AutomaticTestProgression
,@AutomaticProgressionDelayMS
,@InvertTrigger
,@InvertStart
,@ViewDiagnostics
,@VerifyChannels
,@AutoVerifyChannels
,@VerifyChannelsDelayMS
,@RecordingMode
,@SamplesPerSecond
,@PreTriggerSeconds
,@PostTriggerSeconds
,@StrictDiagnostics
,@RequireConfirmationOnErrors
,@ROIDownload
,@ViewROIDownload
,@DownloadAll
,@ViewRealtime
,@RealtimePlotCount
,@RegionsOfInterest
,@ROIStart
,@ROIEnd
,@ViewDownloadAll
,@Export
,@ExportFormat
,@LabDetails
,@UseLabDetails
,@CustomerDetails
,@UseCustomerDetails
,@AllowMissingSensors
,@AllowSensorIdToBlankChannel
,@CalibrationBehavior
,@LocalOnly
,@LastModified
,@LastModifiedBy
,@TurnOffExcitation
,@TriggerCheckRealtime
,@TriggerCheckStep
,@PostTestDiagnostics
,@ExportFolder
,@DownloadFolder
,@CommonStatusLine
,@SameAsDownloadFolder
,@UploadData
,@UploadDataFolder
,@UploadExportsOnly
,@Settings
,@WarnOnBatteryFail
,@Dirty
,@Complete
,@Error
,@TestEngineerDetails
,@UseTestEngineerDetails
,@UserTags
,@DoAutoArm
,@CheckoutMode
,@ISFFile
,@QuitTestWithoutWarning
,@NotAllChannelsRealTime
,@NotAllChannelsViewer
,@SuppressMissingSensorsWarning
,@DoStreaming
,@ClockSyncProfileMaster
,@ClockSyncProfileSlave
,@ExtraProperties
,@TestSetup
,@new_id output
,@errorNumber output
,@errorMessage output
end;
END

View File

@@ -0,0 +1,191 @@
ALTER PROCEDURE [dbo].[sp_TestSetupsUpdate]
@TestSetupName nvarchar(50) = Null
,@SetupDescription nvarchar(50)
,@AutomaticTestProgression bit
,@AutomaticProgressionDelayMS int
,@InvertTrigger bit
,@InvertStart bit
,@ViewDiagnostics bit
,@VerifyChannels bit
,@AutoVerifyChannels bit
,@VerifyChannelsDelayMS int
,@RecordingMode smallint
,@SamplesPerSecond float
,@PreTriggerSeconds float
,@PostTriggerSeconds float
,@StrictDiagnostics bit
,@RequireConfirmationOnErrors bit
,@ROIDownload bit
,@ViewROIDownload bit
,@DownloadAll bit
,@ViewRealtime bit
,@RealtimePlotCount smallint
,@RegionsOfInterest nvarchar(MAX)
,@ROIStart float
,@ROIEnd float
,@ViewDownloadAll bit
,@Export bit
,@ExportFormat bigint
,@LabDetails nvarchar(50)
,@UseLabDetails bit
,@CustomerDetails nvarchar(50)
,@UseCustomerDetails bit
,@AllowMissingSensors bit
,@AllowSensorIdToBlankChannel bit
,@CalibrationBehavior smallint
,@LocalOnly bit
,@LastModified datetime
,@LastModifiedBy nvarchar(50)
,@TurnOffExcitation bit
,@TriggerCheckRealtime bit
,@TriggerCheckStep bit
,@PostTestDiagnostics int
,@ExportFolder nvarchar(150)
,@DownloadFolder nvarchar(150)
,@CommonStatusLine bit
,@SameAsDownloadFolder bit
,@UploadData bit
,@UploadDataFolder nvarchar(150)
,@UploadExportsOnly bit
,@Settings nvarchar(4000)
,@WarnOnBatteryFail bit
,@Dirty bit
,@Complete bit
,@Error nvarchar(255)
,@TestEngineerDetails nvarchar(50)
,@UseTestEngineerDetails bit
,@UserTags varbinary(max)
,@DoAutoArm bit
,@CheckoutMode bit
,@ISFFile nvarchar(4000)
,@QuitTestWithoutWarning bit
,@NotAllChannelsRealTime bit
,@NotAllChannelsViewer bit
,@SuppressMissingSensorsWarning bit
,@DoStreaming bit
,@ClockSyncProfileMaster nvarchar(50)
,@ClockSyncProfileSlave nvarchar(50)
,@ExtraProperties nvarchar(max)
,@TestSetup varbinary(MAX)
,@new_id int output
,@errorNumber int output
,@errorMessage nvarchar(250) output
AS
BEGIN
set @errorNumber = 0; set @errorMessage = space(0); set @new_id = 0;
/* Table (ans stored procedure) is too big... */
begin try
if(@TestSetupName is null)
begin
set @errorMessage = 'An invalid parameter or option was specified for procedure'
set @errorNumber = 15600
end
else
begin
declare @TestSetupId int
declare @TestEngineerId int
declare @LabratoryId int
declare @CustomerId int
set @TestSetupId = dbo.foo_IdGetTestSetup(@TestSetupName)
set @CustomerId = dbo.foo_IdGetCustomer(@CustomerDetails)
IF @CustomerId <= 0
BEGIN
SET @CustomerId = null
END
set @LabratoryId = dbo.foo_IdGetLabratory(@LabDetails)
IF @LabratoryId <= 0
BEGIN
SET @LabratoryId = null
END
set @TestEngineerId = dbo.foo_IdGetEngineer(@TestEngineerDetails);
IF @TestEngineerId <= 0
BEGIN
SET @TestEngineerId = null
END
set @new_id = @TestSetupId
UPDATE [dbo].[TestSetups]
SET [SetupDescription] = @SetupDescription
,[AutomaticTestProgression] = @AutomaticTestProgression
,[AutomaticProgressionDelayMS] = @AutomaticProgressionDelayMS
,[InvertTrigger] = @InvertTrigger
,[InvertStart] = @InvertStart
,[ViewDiagnostics] = @ViewDiagnostics
,[VerifyChannels] = @VerifyChannels
,[AutoVerifyChannels] = @AutoVerifyChannels
,[VerifyChannelsDelayMS] = @VerifyChannelsDelayMS
,[RecordingMode] = @RecordingMode
,[SamplesPerSecond] = @SamplesPerSecond
,[PreTriggerSeconds] = @PreTriggerSeconds
,[PostTriggerSeconds] = @PostTriggerSeconds
,[StrictDiagnostics] = @StrictDiagnostics
,[RequireConfirmationOnErrors] = @RequireConfirmationOnErrors
,[ROIDownload] = @ROIDownload
,[ViewROIDownload] = @ViewROIDownload
,[DownloadAll] = @DownloadAll
,[ViewRealtime] = @ViewRealtime
,[RealtimePlotCount] = @RealtimePlotCount
,[RegionsOfInterest] = @RegionsOfInterest
,[ROIStart] = @ROIStart
,[ROIEnd] = @ROIEnd
,[ViewDownloadAll] = @ViewDownloadAll
,[Export] = @Export
,[ExportFormat] = @ExportFormat
,[CustomerId] = @CustomerId
,[LabratoryId] = @LabratoryId
,[TestEngineerId] = @TestEngineerId
,[LabDetails] = @LabDetails
,[UseLabDetails] = @UseLabDetails
,[CustomerDetails] = @CustomerDetails
,[UseCustomerDetails] = @UseCustomerDetails
,[AllowMissingSensors] = @AllowMissingSensors
,[AllowSensorIdToBlankChannel] = @AllowSensorIdToBlankChannel
,[CalibrationBehavior] = @CalibrationBehavior
,[LocalOnly] = @LocalOnly
,[LastModified] = @LastModified
,[LastModifiedBy] = @LastModifiedBy
,[TurnOffExcitation] = @TurnOffExcitation
,[TriggerCheckRealtime] = @TriggerCheckRealtime
,[TriggerCheckStep] = @TriggerCheckStep
,[PostTestDiagnostics] = @PostTestDiagnostics
,[ExportFolder] = @ExportFolder
,[DownloadFolder] = @DownloadFolder
,[CommonStatusLine] = @CommonStatusLine
,[SameAsDownloadFolder] = @SameAsDownloadFolder
,[UploadData] = @UploadData
,[UploadDataFolder] = @UploadDataFolder
,[UploadExportsOnly] = @UploadExportsOnly
,[Settings] = @Settings
,[WarnOnBatteryFail] = @WarnOnBatteryFail
,[Dirty] = @Dirty
,[Complete] = @Complete
,[ErrorMessage] = @Error
,[TestEngineerDetails] = @TestEngineerDetails
,[UseTestEngineerDetails] = @UseTestEngineerDetails
,[UserTags] = @UserTags
,[DoAutoArm] = @DoAutoArm
,[CheckoutMode] = @CheckoutMode
,[ISFFile] = @ISFFile
,[QuitTestWithoutWarning] = @QuitTestWithoutWarning
,[NotAllChannelsRealTime] = @NotAllChannelsRealTime
,[NotAllChannelsViewer] = @NotAllChannelsViewer
,[SuppressMissingSensorsWarning] = @SuppressMissingSensorsWarning
,[DoStreaming] = @DoStreaming
,[ClockSyncProfileMaster] = @ClockSyncProfileMaster
,[ClockSyncProfileSlave] = @ClockSyncProfileSlave
,[ExtraProperties] = @ExtraProperties
,[TestSetup] = @TestSetup
WHERE [TestSetupId] = @TestSetupId
end
end try
begin catch
set @errorMessage = error_message()
set @errorNumber = error_number()
end catch;
END

View File

@@ -0,0 +1,229 @@
ALTER PROCEDURE [dbo].[sp_TestSetupsUpdateInsert]
@TestSetupName nvarchar(50) = Null
,@SetupDescription nvarchar(50)
,@AutomaticTestProgression bit
,@AutomaticProgressionDelayMS int
,@InvertTrigger bit
,@InvertStart bit
,@ViewDiagnostics bit
,@VerifyChannels bit
,@AutoVerifyChannels bit
,@VerifyChannelsDelayMS int
,@RecordingMode smallint
,@SamplesPerSecond float
,@PreTriggerSeconds float
,@PostTriggerSeconds float
,@StrictDiagnostics bit
,@RequireConfirmationOnErrors bit
,@ROIDownload bit
,@ViewROIDownload bit
,@DownloadAll bit
,@ViewRealtime bit
,@RealtimePlotCount smallint
,@RegionsOfInterest nvarchar(MAX)
,@ROIStart float
,@ROIEnd float
,@ViewDownloadAll bit
,@Export bit
,@ExportFormat bigint
,@LabDetails nvarchar(50)
,@UseLabDetails bit
,@CustomerDetails nvarchar(50)
,@UseCustomerDetails bit
,@AllowMissingSensors bit
,@AllowSensorIdToBlankChannel bit
,@CalibrationBehavior smallint
,@LocalOnly bit
,@LastModified datetime
,@LastModifiedBy nvarchar(50)
,@TurnOffExcitation bit
,@TriggerCheckRealtime bit
,@TriggerCheckStep bit
,@PostTestDiagnostics int
,@ExportFolder nvarchar(150)
,@DownloadFolder nvarchar(150)
,@CommonStatusLine bit
,@SameAsDownloadFolder bit
,@UploadData bit
,@UploadDataFolder nvarchar(150)
,@UploadExportsOnly bit
,@Settings nvarchar(4000)
,@WarnOnBatteryFail bit
,@Dirty bit
,@Complete bit
,@Error nvarchar(255)
,@TestEngineerDetails nvarchar(50)
,@UseTestEngineerDetails bit
,@UserTags varbinary(max)
,@DoAutoArm bit
,@CheckoutMode bit
,@ISFFile nvarchar(4000)
,@QuitTestWithoutWarning bit
,@NotAllChannelsRealTime bit
,@NotAllChannelsViewer bit
,@SuppressMissingSensorsWarning bit
,@DoStreaming bit
,@ClockSyncProfileMaster nvarchar(50)
,@ClockSyncProfileSlave nvarchar(50)
,@ExtraProperties nvarchar(max)
,@TestSetup varbinary(MAX)
,@new_id int output
,@errorNumber int output
,@errorMessage nvarchar(250) output
AS
BEGIN
set @errorNumber = 0; set @errorMessage = space(0);
declare @TestSetupId int
set @TestSetupId = dbo.foo_IdGetTestSetup(@TestSetupName)
if(exists(select TestSetupId from [dbo].[TestSetups] where TestSetupId = @TestSetupId))
begin
set @new_id = @TestSetupId
exec dbo.sp_TestSetupsUpdate @TestSetupName
,@SetupDescription
,@AutomaticTestProgression
,@AutomaticProgressionDelayMS
,@InvertTrigger
,@InvertStart
,@ViewDiagnostics
,@VerifyChannels
,@AutoVerifyChannels
,@VerifyChannelsDelayMS
,@RecordingMode
,@SamplesPerSecond
,@PreTriggerSeconds
,@PostTriggerSeconds
,@StrictDiagnostics
,@RequireConfirmationOnErrors
,@ROIDownload
,@ViewROIDownload
,@DownloadAll
,@ViewRealtime
,@RealtimePlotCount
,@RegionsOfInterest
,@ROIStart
,@ROIEnd
,@ViewDownloadAll
,@Export
,@ExportFormat
,@LabDetails
,@UseLabDetails
,@CustomerDetails
,@UseCustomerDetails
,@AllowMissingSensors
,@AllowSensorIdToBlankChannel
,@CalibrationBehavior
,@LocalOnly
,@LastModified
,@LastModifiedBy
,@TurnOffExcitation
,@TriggerCheckRealtime
,@TriggerCheckStep
,@PostTestDiagnostics
,@ExportFolder
,@DownloadFolder
,@CommonStatusLine
,@SameAsDownloadFolder
,@UploadData
,@UploadDataFolder
,@UploadExportsOnly
,@Settings
,@WarnOnBatteryFail
,@Dirty
,@Complete
,@Error
,@TestEngineerDetails
,@UseTestEngineerDetails
,@UserTags
,@DoAutoArm
,@CheckoutMode
,@ISFFile
,@QuitTestWithoutWarning
,@NotAllChannelsRealTime
,@NotAllChannelsViewer
,@SuppressMissingSensorsWarning
,@DoStreaming
,@ClockSyncProfileMaster
,@ClockSyncProfileSlave
,@ExtraProperties
,@TestSetup
,@new_id output
,@errorNumber output
,@errorMessage output
end
else
begin
exec dbo.sp_TestSetupsInsert @TestSetupName
,@SetupDescription
,@AutomaticTestProgression
,@AutomaticProgressionDelayMS
,@InvertTrigger
,@InvertStart
,@ViewDiagnostics
,@VerifyChannels
,@AutoVerifyChannels
,@VerifyChannelsDelayMS
,@RecordingMode
,@SamplesPerSecond
,@PreTriggerSeconds
,@PostTriggerSeconds
,@StrictDiagnostics
,@RequireConfirmationOnErrors
,@ROIDownload
,@ViewROIDownload
,@DownloadAll
,@ViewRealtime
,@RealtimePlotCount
,@RegionsOfInterest
,@ROIStart
,@ROIEnd
,@ViewDownloadAll
,@Export
,@ExportFormat
,@LabDetails
,@UseLabDetails
,@CustomerDetails
,@UseCustomerDetails
,@AllowMissingSensors
,@AllowSensorIdToBlankChannel
,@CalibrationBehavior
,@LocalOnly
,@LastModified
,@LastModifiedBy
,@TurnOffExcitation
,@TriggerCheckRealtime
,@TriggerCheckStep
,@PostTestDiagnostics
,@ExportFolder
,@DownloadFolder
,@CommonStatusLine
,@SameAsDownloadFolder
,@UploadData
,@UploadDataFolder
,@UploadExportsOnly
,@Settings
,@WarnOnBatteryFail
,@Dirty
,@Complete
,@Error
,@TestEngineerDetails
,@UseTestEngineerDetails
,@UserTags
,@DoAutoArm
,@CheckoutMode
,@ISFFile
,@QuitTestWithoutWarning
,@NotAllChannelsRealTime
,@NotAllChannelsViewer
,@SuppressMissingSensorsWarning
,@DoStreaming
,@ClockSyncProfileMaster
,@ClockSyncProfileSlave
,@ExtraProperties
,@TestSetup
,@new_id output
,@errorNumber output
,@errorMessage output
end;
END

View File

@@ -0,0 +1,229 @@
ALTER PROCEDURE [dbo].[sp_TestSetupsUpdateInsert]
@TestSetupName nvarchar(50) = Null
,@SetupDescription nvarchar(50)
,@AutomaticTestProgression bit
,@AutomaticProgressionDelayMS int
,@InvertTrigger bit
,@InvertStart bit
,@ViewDiagnostics bit
,@VerifyChannels bit
,@AutoVerifyChannels bit
,@VerifyChannelsDelayMS int
,@RecordingMode smallint
,@SamplesPerSecond float
,@PreTriggerSeconds float
,@PostTriggerSeconds float
,@StrictDiagnostics bit
,@RequireConfirmationOnErrors bit
,@ROIDownload bit
,@ViewROIDownload bit
,@DownloadAll bit
,@ViewRealtime bit
,@RealtimePlotCount smallint
,@RegionsOfInterest nvarchar(MAX)
,@ROIStart float
,@ROIEnd float
,@ViewDownloadAll bit
,@Export bit
,@ExportFormat bigint
,@LabDetails nvarchar(50)
,@UseLabDetails bit
,@CustomerDetails nvarchar(50)
,@UseCustomerDetails bit
,@AllowMissingSensors bit
,@AllowSensorIdToBlankChannel bit
,@CalibrationBehavior smallint
,@LocalOnly bit
,@LastModified datetime
,@LastModifiedBy nvarchar(50)
,@TurnOffExcitation bit
,@TriggerCheckRealtime bit
,@TriggerCheckStep bit
,@PostTestDiagnostics int
,@ExportFolder nvarchar(150)
,@DownloadFolder nvarchar(150)
,@CommonStatusLine bit
,@SameAsDownloadFolder bit
,@UploadData bit
,@UploadDataFolder nvarchar(150)
,@UploadExportsOnly bit
,@Settings nvarchar(4000)
,@WarnOnBatteryFail bit
,@Dirty bit
,@Complete bit
,@Error nvarchar(255)
,@TestEngineerDetails nvarchar(50)
,@UseTestEngineerDetails bit
,@UserTags varbinary(max)
,@DoAutoArm bit
,@CheckoutMode bit
,@ISFFile nvarchar(4000)
,@QuitTestWithoutWarning bit
,@NotAllChannelsRealTime bit
,@NotAllChannelsViewer bit
,@SuppressMissingSensorsWarning bit
,@DoStreaming bit
,@ClockSyncProfileMaster nvarchar(50)
,@ClockSyncProfileSlave nvarchar(50)
,@ExtraProperties nvarchar(max)
,@TestSetup varbinary(MAX)
,@new_id int output
,@errorNumber int output
,@errorMessage nvarchar(250) output
AS
BEGIN
set @errorNumber = 0; set @errorMessage = space(0);
declare @TestSetupId int
set @TestSetupId = dbo.foo_IdGetTestSetup(@TestSetupName)
if(exists(select TestSetupId from [dbo].[TestSetups] where TestSetupId = @TestSetupId))
begin
set @new_id = @TestSetupId
exec dbo.sp_TestSetupsUpdate @TestSetupName
,@SetupDescription
,@AutomaticTestProgression
,@AutomaticProgressionDelayMS
,@InvertTrigger
,@InvertStart
,@ViewDiagnostics
,@VerifyChannels
,@AutoVerifyChannels
,@VerifyChannelsDelayMS
,@RecordingMode
,@SamplesPerSecond
,@PreTriggerSeconds
,@PostTriggerSeconds
,@StrictDiagnostics
,@RequireConfirmationOnErrors
,@ROIDownload
,@ViewROIDownload
,@DownloadAll
,@ViewRealtime
,@RealtimePlotCount
,@RegionsOfInterest
,@ROIStart
,@ROIEnd
,@ViewDownloadAll
,@Export
,@ExportFormat
,@LabDetails
,@UseLabDetails
,@CustomerDetails
,@UseCustomerDetails
,@AllowMissingSensors
,@AllowSensorIdToBlankChannel
,@CalibrationBehavior
,@LocalOnly
,@LastModified
,@LastModifiedBy
,@TurnOffExcitation
,@TriggerCheckRealtime
,@TriggerCheckStep
,@PostTestDiagnostics
,@ExportFolder
,@DownloadFolder
,@CommonStatusLine
,@SameAsDownloadFolder
,@UploadData
,@UploadDataFolder
,@UploadExportsOnly
,@Settings
,@WarnOnBatteryFail
,@Dirty
,@Complete
,@Error
,@TestEngineerDetails
,@UseTestEngineerDetails
,@UserTags
,@DoAutoArm
,@CheckoutMode
,@ISFFile
,@QuitTestWithoutWarning
,@NotAllChannelsRealTime
,@NotAllChannelsViewer
,@SuppressMissingSensorsWarning
,@DoStreaming
,@ClockSyncProfileMaster
,@ClockSyncProfileSlave
,@ExtraProperties
,@TestSetup
,@new_id output
,@errorNumber output
,@errorMessage output
end
else
begin
exec dbo.sp_TestSetupsInsert @TestSetupName
,@SetupDescription
,@AutomaticTestProgression
,@AutomaticProgressionDelayMS
,@InvertTrigger
,@InvertStart
,@ViewDiagnostics
,@VerifyChannels
,@AutoVerifyChannels
,@VerifyChannelsDelayMS
,@RecordingMode
,@SamplesPerSecond
,@PreTriggerSeconds
,@PostTriggerSeconds
,@StrictDiagnostics
,@RequireConfirmationOnErrors
,@ROIDownload
,@ViewROIDownload
,@DownloadAll
,@ViewRealtime
,@RealtimePlotCount
,@RegionsOfInterest
,@ROIStart
,@ROIEnd
,@ViewDownloadAll
,@Export
,@ExportFormat
,@LabDetails
,@UseLabDetails
,@CustomerDetails
,@UseCustomerDetails
,@AllowMissingSensors
,@AllowSensorIdToBlankChannel
,@CalibrationBehavior
,@LocalOnly
,@LastModified
,@LastModifiedBy
,@TurnOffExcitation
,@TriggerCheckRealtime
,@TriggerCheckStep
,@PostTestDiagnostics
,@ExportFolder
,@DownloadFolder
,@CommonStatusLine
,@SameAsDownloadFolder
,@UploadData
,@UploadDataFolder
,@UploadExportsOnly
,@Settings
,@WarnOnBatteryFail
,@Dirty
,@Complete
,@Error
,@TestEngineerDetails
,@UseTestEngineerDetails
,@UserTags
,@DoAutoArm
,@CheckoutMode
,@ISFFile
,@QuitTestWithoutWarning
,@NotAllChannelsRealTime
,@NotAllChannelsViewer
,@SuppressMissingSensorsWarning
,@DoStreaming
,@ClockSyncProfileMaster
,@ClockSyncProfileSlave
,@ExtraProperties
,@TestSetup
,@new_id output
,@errorNumber output
,@errorMessage output
end;
END

View File

@@ -0,0 +1,21 @@
CREATE PROCEDURE [dbo].[sp_DASFirstUseSet]
@DASId int
,@FirstUseDate DateTime null
,@errorNumber int output
,@errorMessage nvarchar(250) output
AS
BEGIN
SET @errorNumber = 0
SET @errorMessage = space(0)
SET NOCOUNT ON;
UPDATE [dbo].[DAS] SET [FirstUseDate]=@FirstUseDate WHERE [DASId]=@DASId;
IF(@@error != 0)
BEGIN
SET @errorNumber = error_number()
SET @errorMessage = error_message()
END
END

View File

@@ -0,0 +1,19 @@
CREATE PROCEDURE [dbo].[sp_SensorsAnalogFirstUseSet]
@SensorId INT,
@FirstUseDate DATETIME NULL,
@errorNumber INT OUTPUT,
@errorMessage NVARCHAR (255) OUTPUT
AS
BEGIN
SET NOCOUNT ON
SET @errorNumber = 0
SET @errorMessage = ''
UPDATE [dbo].[SensorsAnalog] SET [FirstUseDate]=@FirstUseDate WHERE [SensorId]=@SensorId;
if(@@error != 0)
begin
set @errorNumber = error_number()
set @errorMessage = error_message()
end
END

View File

@@ -0,0 +1,21 @@
CREATE PROCEDURE [dbo].[sp_SensorsAnalogUpdateCalibrationId]
@SensorId INT,
@LatestCalibrationId INT,
@errorNumber INT OUTPUT,
@errorMessage NVARCHAR (255) OUTPUT
AS
BEGIN
SET NOCOUNT ON
SET @errorNumber = 0
SET @errorMessage = ''
UPDATE [dbo].[SensorsAnalog] SET
[LatestCalibrationId] = @LatestCalibrationId WHERE [Id]=@SensorId
if(@@error != 0)
begin
set @errorNumber = error_number()
set @errorMessage = error_message()
end
END

View File

@@ -0,0 +1,83 @@
CREATE PROCEDURE [dbo].[sp_TestSetupsDeleteManyByDate]
@DeleteDateBefore DATETIME = NULL,
@errorNumber INT OUTPUT,
@errorMessage NVARCHAR(255) OUTPUT
AS
BEGIN
SET @errorNumber = 0;
SET @errorMessage = SPACE(0);
BEGIN TRY
BEGIN TRANSACTION [tDeleteTestSetupsMany]
DELETE TSOMD FROM [dbo].[TestSetupObjectMetaData] AS TSOMD
INNER JOIN [DataPro].[dbo].[TestSetups] TS ON TSOMD.TestSetupId = TS.TestSetupId
WHERE TS.LastModified < @DeleteDateBefore
DELETE TSH FROM [dbo].[TestSetupHardware] AS TSH
INNER JOIN [DataPro].[dbo].[TestSetups] TS ON TSH.TestSetupId = TS.TestSetupId
WHERE TS.LastModified < @DeleteDateBefore
DELETE LT FROM [dbo].[LevelTriggers] AS LT
INNER JOIN [DataPro].[dbo].[TestSetups] TS ON LT.TestSetupId = TS.TestSetupId
WHERE TS.LastModified < @DeleteDateBefore
DELETE CC FROM [dbo].[CalculatedChannels] AS CC
INNER JOIN [DataPro].[dbo].[TestSetups] TS ON CC.TestSetupId = TS.TestSetupId
WHERE TS.LastModified < @DeleteDateBefore
DELETE TG FROM [dbo].[TestGraphs] AS TG
INNER JOIN [DataPro].[dbo].[TestSetups] TS ON TG.TestSetupId = TS.TestSetupId
WHERE TS.LastModified < @DeleteDateBefore
/*Delete group channel settings*/
DELETE GCS FROM [dbo].[GroupChannelSettings] AS GCS
INNER JOIN [dbo].[Channels] AS C ON GCS.ChannelId=C.Id
INNER JOIN [dbo].[Groups] AS G ON C.GroupId=G.Id
INNER JOIN [dbo].TestSetupGroups AS TSG ON G.Id=TSG.GroupId
INNER JOIN [dbo].[TestSetups] TS ON TSG.TestSetupId = TS.TestSetupId
WHERE TS.LastModified < @DeleteDateBefore
/*Delete group hardware*/
DELETE GH FROM [dbo].[GroupHardware] AS GH
INNER JOIN [dbo].[TestSetupGroups] AS TSG ON GH.GroupId=TSG.GroupId
INNER JOIN [dbo].[TestSetups] TS ON TSG.TestSetupId = TS.TestSetupId
WHERE TS.LastModified < @DeleteDateBefore
/*Delete group channels*/
DELETE C FROM [dbo].[Channels] AS C
INNER JOIN [dbo].[TestSetupGroups] AS TSG ON C.GroupId = TSG.GroupId
INNER JOIN [dbo].[TestSetups] TS ON TSG.TestSetupId = TS.TestSetupId
WHERE TS.LastModified < @DeleteDateBefore
/*grab a copy of all groups associated with test so we can delete them*/
SELECT [GroupId] INTO #temptable
FROM [DataPro].[dbo].[TestSetupGroups] AS TSG
INNER JOIN [DataPro].[dbo].[TestSetups] TS ON TSG.TestSetupId = TS.TestSetupId
WHERE TS.LastModified < @DeleteDateBefore
/*unassociate the group from the test setup*/
DELETE TSG FROM [dbo].[TestSetupGroups] AS TSG
INNER JOIN [dbo].[TestSetups] TS ON TSG.TestSetupId = TS.TestSetupId
WHERE TS.LastModified < @DeleteDateBefore
/*delete the groups*/
DELETE FROM [dbo].[Groups] WHERE [Id] IN (SELECT [GroupId] FROM #tempTable)
DELETE TS FROM [dbo].[TestSetups] TS
WHERE TS.LastModified < @DeleteDateBefore
COMMIT TRANSACTION [tDeleteTestSetupsMany]
END TRY
BEGIN CATCH
SET @errorNumber = error_number()
SET @errorMessage = error_message()
ROLLBACK TRANSACTION [tDeleteTestSetupsMany]
END CATCH
END

View File

@@ -0,0 +1,52 @@
CREATE PROCEDURE [dbo].[sp_TestSetupsDeleteManyById]
@TestSetupIdList VARCHAR(MAX) = NULL,
@errorNumber INT OUTPUT,
@errorMessage NVARCHAR(255) OUTPUT
AS
BEGIN
SET @errorNumber = 0;
SET @errorMessage = SPACE(0);
DECLARE @TempIdTable TABLE (Element nvarchar(4000), Processed bit)
INSERT INTO @TempIdTable SELECT * FROM dbo.foo_SplitDelimitedString(@TestSetupIdList, ',')
BEGIN TRY
BEGIN TRANSACTION [tDeleteTestSetups]
DELETE FROM [dbo].[TestSetupObjectMetaData] WHERE TestSetupId IN ( SELECT Element FROM @TempIdTable)
DELETE FROM [dbo].[TestSetupHardware] WHERE TestSetupId IN ( SELECT Element FROM @TempIdTable)
DELETE FROM [dbo].[LevelTriggers] WHERE TestSetupId IN ( SELECT Element FROM @TempIdTable)
DELETE FROM [dbo].[CalculatedChannels] WHERE TestSetupId IN ( SELECT Element FROM @TempIdTable)
DELETE FROM [dbo].[TestGraphs] WHERE TestSetupId IN ( SELECT Element FROM @TempIdTable)
/*Delete group channel settings*/
DELETE A FROM [dbo].[GroupChannelSettings] AS A INNER JOIN [dbo].[Channels] AS B ON A.ChannelId=B.Id
INNER JOIN [dbo].[Groups] AS C ON B.GroupId=C.Id INNER JOIN [dbo].TestSetupGroups AS D ON C.Id=D.GroupId WHERE D.TestSetupId IN ( SELECT Element FROM @TempIdTable)
/*Delete group hardware*/
DELETE A FROM [dbo].[GroupHardware] AS A INNER JOIN [dbo].[TestSetupGroups] AS B ON A.GroupId=B.GroupId WHERE B.TestSetupId IN ( SELECT Element FROM @TempIdTable)
/*Delete group channels*/
DELETE A FROM [dbo].[Channels] AS A INNER JOIN [dbo].[TestSetupGroups] AS B ON A.GroupId = B.GroupId WHERE B.TestSetupId IN ( SELECT Element FROM @TempIdTable)
/*grab a copy of all groups associated with test so we can delete them*/
SELECT [GroupId] INTO #temptable FROM [dbo].[TestSetupGroups] WHERE [TestSetupId] IN ( SELECT Element FROM @TempIdTable)
/*unassociate the group from the test setup*/
DELETE FROM [dbo].[TestSetupGroups] WHERE [TestSetupId] IN ( SELECT Element FROM @TempIdTable)
/*delete the groups*/
DELETE FROM [dbo].[Groups] WHERE [Id] IN (SELECT [GroupId] FROM #tempTable)
/*delete test specific hardware */
UPDATE [dbo].[Channels] SET [DASId] = 0, [DASChannelIndex]=0 FROM [dbo].[Channels] AS A INNER JOIN [dbo].[DAS] AS B ON A.DASId=B.DASId WHERE B.TestId IN ( SELECT Element FROM @TempIdTable)
DELETE A FROM [dbo].[TestSetupHardware] AS A INNER JOIN [dbo].[DAS] as B ON A.DASId=B.DASId WHERE B.TestId IN ( SELECT Element FROM @TempIdTable)
DELETE A FROM [dbo].[GroupHardware] AS A INNER JOIN [dbo].[DAS] as B on A.DASId=B.DASId WHERE B.TestId IN ( SELECT Element FROM @TempIdTable)
DELETE A FROM [dbo].[DASChannels] AS A INNER JOIN [dbo].[DAS] AS B on A.DASId=B.DASId WHERE B.TestId IN ( SELECT Element FROM @TempIdTable)
DELETE [dbo].[DAS] WHERE [TestId] IN ( SELECT Element FROM @TempIdTable)
/*finally delete the test setup*/
DELETE FROM [dbo].[TestSetups] where TestSetupId IN ( SELECT Element FROM @TempIdTable)
COMMIT TRANSACTION [tDeleteTestSetups]
END TRY
BEGIN CATCH
SET @errorNumber = error_number()
SET @errorMessage = error_message()
ROLLBACK TRANSACTION [tDeleteTestSetups]
END CATCH
END

View File

@@ -0,0 +1,53 @@
CREATE PROCEDURE [dbo].[sp_TestSetupsDeleteManyByName]
@TestSetupNameList VARCHAR(MAX) = NULL,
@errorNumber INT OUTPUT,
@errorMessage NVARCHAR(255) OUTPUT
AS
BEGIN
SET @errorNumber = 0;
SET @errorMessage = SPACE(0);
DECLARE @TempIdTable TABLE (Element NVARCHAR(4000), Processed BIT, TestSetupId INT)
INSERT INTO @TempIdTable SELECT Element, Processed, TestSetupId FROM dbo.foo_SplitDelimitedString(@TestSetupNameList, ',') AS TEMP INNER JOIN
[dbo].TestSetups AS TS ON TS.TestSetupName = TEMP.Element
BEGIN TRY
BEGIN TRANSACTION [tDeleteTestSetups]
DELETE FROM [dbo].[TestSetupObjectMetaData] WHERE TestSetupId IN ( SELECT TestSetupId FROM @TempIdTable)
DELETE FROM [dbo].[TestSetupHardware] WHERE TestSetupId IN ( SELECT TestSetupId FROM @TempIdTable)
DELETE FROM [dbo].[LevelTriggers] WHERE TestSetupId IN ( SELECT TestSetupId FROM @TempIdTable)
DELETE FROM [dbo].[CalculatedChannels] WHERE TestSetupId IN ( SELECT TestSetupId FROM @TempIdTable)
DELETE FROM [dbo].[TestGraphs] WHERE TestSetupId IN ( SELECT TestSetupId FROM @TempIdTable)
/*Delete group channel settings*/
DELETE A FROM [dbo].[GroupChannelSettings] AS A INNER JOIN [dbo].[Channels] AS B ON A.ChannelId=B.Id
INNER JOIN [dbo].[Groups] AS C ON B.GroupId=C.Id INNER JOIN [dbo].TestSetupGroups AS D ON C.Id=D.GroupId WHERE D.TestSetupId IN ( SELECT TestSetupId FROM @TempIdTable)
/*Delete group hardware*/
DELETE A FROM [dbo].[GroupHardware] AS A INNER JOIN [dbo].[TestSetupGroups] AS B ON A.GroupId=B.GroupId WHERE B.TestSetupId IN ( SELECT TestSetupId FROM @TempIdTable)
/*Delete group channels*/
DELETE A FROM [dbo].[Channels] AS A INNER JOIN [dbo].[TestSetupGroups] AS B ON A.GroupId = B.GroupId WHERE B.TestSetupId IN ( SELECT TestSetupId FROM @TempIdTable)
/*grab a copy of all groups associated with test so we can delete them*/
SELECT [GroupId] INTO #temptable FROM [dbo].[TestSetupGroups] WHERE [TestSetupId] IN ( SELECT TestSetupId FROM @TempIdTable)
/*unassociate the group from the test setup*/
DELETE FROM [dbo].[TestSetupGroups] WHERE [TestSetupId] IN ( SELECT TestSetupId FROM @TempIdTable)
/*delete the groups*/
DELETE FROM [dbo].[Groups] WHERE [Id] IN (SELECT [GroupId] FROM #tempTable)
/*delete test specific hardware */
UPDATE [dbo].[Channels] SET [DASId] = 0, [DASChannelIndex]=0 FROM [dbo].[Channels] AS A INNER JOIN [dbo].[DAS] AS B ON A.DASId=B.DASId WHERE B.TestId IN ( SELECT TestSetupId FROM @TempIdTable)
DELETE A FROM [dbo].[TestSetupHardware] AS A INNER JOIN [dbo].[DAS] as B ON A.DASId=B.DASId WHERE B.TestId IN ( SELECT TestSetupId FROM @TempIdTable)
DELETE A FROM [dbo].[GroupHardware] AS A INNER JOIN [dbo].[DAS] as B on A.DASId=B.DASId WHERE B.TestId IN ( SELECT TestSetupId FROM @TempIdTable)
DELETE A FROM [dbo].[DASChannels] AS A INNER JOIN [dbo].[DAS] AS B on A.DASId=B.DASId WHERE B.TestId IN ( SELECT TestSetupId FROM @TempIdTable)
DELETE [dbo].[DAS] WHERE [TestId] IN ( SELECT TestSetupId FROM @TempIdTable)
/*finally delete the test setup*/
DELETE FROM [dbo].[TestSetups] where TestSetupId IN ( SELECT TestSetupId FROM @TempIdTable)
COMMIT TRANSACTION [tDeleteTestSetups]
END TRY
BEGIN CATCH
SET @errorNumber = error_number()
SET @errorMessage = error_message()
ROLLBACK TRANSACTION [tDeleteTestSetups]
END CATCH
END